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

EAC_init:
   71|    195|{
   72|       |    OpenSSL_add_all_algorithms();
   73|    195|    EAC_add_all_objects();
   74|    195|    EAC_set_x509_default_dir(X509DIR);
   75|    195|    EAC_set_cvc_default_dir(CVCDIR);
   76|    195|}

EAC_add_all_objects:
  174|    195|{
  175|    195|    int obj;
  176|       |
  177|    195|    if (objects_initialized)
  ------------------
  |  Branch (177:9): [True: 194, False: 1]
  ------------------
  178|    194|        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|    195|{
   64|    195|    if (default_dir) {
  ------------------
  |  Branch (64:9): [True: 195, False: 0]
  ------------------
   65|    195|        strncpy(x509_default_dir, default_dir, (sizeof x509_default_dir) - 1);
   66|    195|        x509_default_dir[(sizeof x509_default_dir) - 1] = '\0';
   67|    195|    }
   68|    195|}

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

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

list_init:
  235|  4.37k|int list_init(list_t *simclist_restrict l) {
  236|  4.37k|    if (l == NULL) {
  ------------------
  |  Branch (236:9): [True: 0, False: 4.37k]
  ------------------
  237|      0|        return -1;
  238|      0|    }
  239|       |
  240|  4.37k|    memset(l, 0, sizeof *l);
  241|       |
  242|  4.37k|    seed_random();
  243|       |
  244|  4.37k|    l->numels = 0;
  245|       |
  246|       |    /* head/tail sentinels and mid pointer */
  247|  4.37k|    l->head_sentinel = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  248|  4.37k|    l->tail_sentinel = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  249|  4.37k|    if (l->tail_sentinel == NULL || l->head_sentinel == NULL) {
  ------------------
  |  Branch (249:9): [True: 0, False: 4.37k]
  |  Branch (249:37): [True: 0, False: 4.37k]
  ------------------
  250|      0|        return -1;
  251|      0|    }
  252|  4.37k|    l->head_sentinel->next = l->tail_sentinel;
  253|  4.37k|    l->tail_sentinel->prev = l->head_sentinel;
  254|  4.37k|    l->head_sentinel->prev = l->tail_sentinel->next = l->mid = NULL;
  255|  4.37k|    l->head_sentinel->data = l->tail_sentinel->data = NULL;
  256|       |
  257|       |    /* iteration attributes */
  258|  4.37k|    l->iter_active = 0;
  259|  4.37k|    l->iter_pos = 0;
  260|  4.37k|    l->iter_curentry = NULL;
  261|       |
  262|       |    /* free-list attributes */
  263|  4.37k|    l->spareelsnum = 0;
  264|  4.37k|    l->spareels = (struct list_entry_s **)malloc(SIMCLIST_MAX_SPARE_ELEMS * sizeof(struct list_entry_s *));
  ------------------
  |  |  115|  4.37k|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  265|  4.37k|    if (l->spareels == NULL) {
  ------------------
  |  Branch (265:9): [True: 0, False: 4.37k]
  ------------------
  266|      0|        return -1;
  267|      0|    }
  268|       |
  269|       |#ifdef SIMCLIST_WITH_THREADS
  270|       |    l->threadcount = 0;
  271|       |#endif
  272|       |
  273|  4.37k|    if (0 != list_attributes_setdefaults(l)) {
  ------------------
  |  Branch (273:9): [True: 0, False: 4.37k]
  ------------------
  274|      0|        return -1;
  275|      0|    }
  276|       |
  277|  4.37k|    assert(list_repOk(l));
  278|  4.37k|    assert(list_attrOk(l));
  279|       |
  280|  4.37k|    return 0;
  281|  4.37k|}
list_destroy:
  283|  4.37k|void list_destroy(list_t *simclist_restrict l) {
  284|  4.37k|    unsigned int i;
  285|       |
  286|  4.37k|    list_clear(l);
  287|  8.91k|    for (i = 0; i < l->spareelsnum; i++) {
  ------------------
  |  Branch (287:17): [True: 4.53k, False: 4.37k]
  ------------------
  288|  4.53k|        free(l->spareels[i]);
  289|  4.53k|    }
  290|  4.37k|    free(l->spareels);
  291|  4.37k|    free(l->head_sentinel);
  292|  4.37k|    free(l->tail_sentinel);
  293|  4.37k|}
list_attributes_comparator:
  315|    412|int list_attributes_comparator(list_t *simclist_restrict l, element_comparator comparator_fun) {
  316|    412|    if (l == NULL) return -1;
  ------------------
  |  Branch (316:9): [True: 0, False: 412]
  ------------------
  317|       |
  318|    412|    l->attrs.comparator = comparator_fun;
  319|       |
  320|    412|    assert(list_attrOk(l));
  321|       |
  322|    412|    return 0;
  323|    412|}
list_attributes_seeker:
  325|  3.87k|int list_attributes_seeker(list_t *simclist_restrict l, element_seeker seeker_fun) {
  326|  3.87k|    if (l == NULL) return -1;
  ------------------
  |  Branch (326:9): [True: 0, False: 3.87k]
  ------------------
  327|       |
  328|  3.87k|    l->attrs.seeker = seeker_fun;
  329|  3.87k|    assert(list_attrOk(l));
  330|       |
  331|  3.87k|    return 0;
  332|  3.87k|}
list_attributes_copy:
  334|    682|int list_attributes_copy(list_t *simclist_restrict l, element_meter metric_fun, int copy_data) {
  335|    682|    if (l == NULL || (metric_fun == NULL && copy_data != 0)) return -1;
  ------------------
  |  Branch (335:9): [True: 0, False: 682]
  |  Branch (335:23): [True: 0, False: 682]
  |  Branch (335:45): [True: 0, False: 0]
  ------------------
  336|       |
  337|    682|    l->attrs.meter = metric_fun;
  338|    682|    l->attrs.copy_data = copy_data;
  339|       |
  340|    682|    assert(list_attrOk(l));
  341|       |
  342|    682|    return 0;
  343|    682|}
list_append:
  369|  59.7k|int list_append(list_t *simclist_restrict l, const void *data) {
  370|  59.7k|    return list_insert_at(l, data, l->numels);
  371|  59.7k|}
list_get_at:
  381|  8.77k|void *list_get_at(const list_t *simclist_restrict l, unsigned int pos) {
  382|  8.77k|    struct list_entry_s *tmp;
  383|       |
  384|  8.77k|    tmp = list_findpos(l, pos);
  385|       |
  386|  8.77k|    return (tmp != NULL ? tmp->data : NULL);
  ------------------
  |  Branch (386:13): [True: 8.77k, False: 0]
  ------------------
  387|  8.77k|}
list_insert_at:
  465|  59.7k|int list_insert_at(list_t *simclist_restrict l, const void *data, unsigned int pos) {
  466|  59.7k|    struct list_entry_s *lent, *succ, *prec;
  467|       |
  468|  59.7k|    if (l->iter_active || pos > l->numels) return -1;
  ------------------
  |  Branch (468:9): [True: 0, False: 59.7k]
  |  Branch (468:27): [True: 0, False: 59.7k]
  ------------------
  469|       |
  470|       |    /* this code optimizes malloc() with a free-list */
  471|  59.7k|    if (l->spareelsnum > 0) {
  ------------------
  |  Branch (471:9): [True: 0, False: 59.7k]
  ------------------
  472|      0|        lent = l->spareels[l->spareelsnum-1];
  473|      0|        l->spareelsnum--;
  474|  59.7k|    } else {
  475|  59.7k|        lent = (struct list_entry_s *)malloc(sizeof(struct list_entry_s));
  476|  59.7k|        if (lent == NULL) {
  ------------------
  |  Branch (476:13): [True: 0, False: 59.7k]
  ------------------
  477|      0|            return -1;
  478|      0|        }
  479|  59.7k|    }
  480|       |
  481|  59.7k|    if (l->attrs.copy_data) {
  ------------------
  |  Branch (481:9): [True: 56.0k, False: 3.69k]
  ------------------
  482|       |        /* make room for user' data (has to be copied) */
  483|  56.0k|        size_t datalen = l->attrs.meter(data);
  484|  56.0k|        lent->data = (struct list_entry_s *)malloc(datalen);
  485|  56.0k|        if (lent->data == NULL) {
  ------------------
  |  Branch (485:13): [True: 0, False: 56.0k]
  ------------------
  486|      0|            if (!(l->spareelsnum > 0)) {
  ------------------
  |  Branch (486:17): [True: 0, False: 0]
  ------------------
  487|      0|                free(lent);
  488|      0|            }
  489|      0|            return -1;
  490|      0|        }
  491|  56.0k|        memcpy(lent->data, data, datalen);
  492|  56.0k|    } else {
  493|  3.69k|        lent->data = (void*)data;
  494|  3.69k|    }
  495|       |
  496|       |    /* actually append element */
  497|  59.7k|    prec = list_findpos(l, pos-1);
  498|  59.7k|    if (prec == NULL) {
  ------------------
  |  Branch (498:9): [True: 0, False: 59.7k]
  ------------------
  499|      0|        if (l->attrs.copy_data) {
  ------------------
  |  Branch (499:13): [True: 0, False: 0]
  ------------------
  500|      0|            free(lent->data);
  501|      0|        }
  502|      0|        if (!(l->spareelsnum > 0)) {
  ------------------
  |  Branch (502:13): [True: 0, False: 0]
  ------------------
  503|      0|            free(lent);
  504|      0|        }
  505|      0|        return -1;
  506|      0|    }
  507|  59.7k|    succ = prec->next;
  508|       |
  509|  59.7k|    prec->next = lent;
  510|  59.7k|    lent->prev = prec;
  511|  59.7k|    lent->next = succ;
  512|  59.7k|    succ->prev = lent;
  513|       |
  514|  59.7k|    l->numels++;
  515|       |
  516|       |    /* fix mid pointer */
  517|  59.7k|    if (l->numels == 1) { /* first element, set pointer */
  ------------------
  |  Branch (517:9): [True: 3.90k, False: 55.8k]
  ------------------
  518|  3.90k|        l->mid = lent;
  519|  55.8k|    } else if (l->numels % 2) {    /* now odd */
  ------------------
  |  Branch (519:16): [True: 27.8k, False: 27.9k]
  ------------------
  520|  27.8k|        if (pos >= (l->numels-1)/2) l->mid = l->mid->next;
  ------------------
  |  Branch (520:13): [True: 27.8k, False: 0]
  ------------------
  521|  27.9k|    } else {                /* now even */
  522|  27.9k|        if (pos <= (l->numels-1)/2) l->mid = l->mid->prev;
  ------------------
  |  Branch (522:13): [True: 0, False: 27.9k]
  ------------------
  523|  27.9k|    }
  524|       |
  525|  59.7k|    assert(list_repOk(l));
  526|       |
  527|  59.7k|    return 1;
  528|  59.7k|}
list_delete:
  530|  3.69k|int list_delete(list_t *simclist_restrict l, const void *data) {
  531|  3.69k|	int pos, r;
  532|       |
  533|  3.69k|	pos = list_locate(l, data);
  534|  3.69k|	if (pos < 0)
  ------------------
  |  Branch (534:6): [True: 0, False: 3.69k]
  ------------------
  535|      0|		return -1;
  536|       |
  537|  3.69k|	r = list_delete_at(l, pos);
  538|  3.69k|	if (r < 0)
  ------------------
  |  Branch (538:6): [True: 0, False: 3.69k]
  ------------------
  539|      0|		return -1;
  540|       |
  541|  3.69k|    assert(list_repOk(l));
  542|       |
  543|  3.69k|	return 0;
  544|  3.69k|}
list_delete_at:
  546|  3.69k|int list_delete_at(list_t *simclist_restrict l, unsigned int pos) {
  547|  3.69k|    struct list_entry_s *delendo;
  548|       |
  549|       |
  550|  3.69k|    if (l->iter_active || pos >= l->numels) return -1;
  ------------------
  |  Branch (550:9): [True: 0, False: 3.69k]
  |  Branch (550:27): [True: 0, False: 3.69k]
  ------------------
  551|       |
  552|  3.69k|    delendo = list_findpos(l, pos);
  553|       |
  554|  3.69k|    list_drop_elem(l, delendo, pos);
  555|       |
  556|  3.69k|    l->numels--;
  557|       |
  558|       |
  559|  3.69k|    assert(list_repOk(l));
  560|       |
  561|  3.69k|    return  0;
  562|  3.69k|}
list_clear:
  629|  4.37k|int list_clear(list_t *simclist_restrict l) {
  630|  4.37k|    struct list_entry_s *s;
  631|       |
  632|  4.37k|    if (l->iter_active) return -1;
  ------------------
  |  Branch (632:9): [True: 0, False: 4.37k]
  ------------------
  633|       |
  634|  4.37k|    if (l->head_sentinel && l->tail_sentinel) {
  ------------------
  |  Branch (634:9): [True: 4.37k, False: 0]
  |  Branch (634:29): [True: 4.37k, False: 0]
  ------------------
  635|  4.37k|        if (l->attrs.copy_data) {        /* also free user data */
  ------------------
  |  Branch (635:13): [True: 682, False: 3.69k]
  ------------------
  636|       |            /* spare a loop conditional with two loops: spareing elems and freeing elems */
  637|  1.52k|            for (s = l->head_sentinel->next; l->spareelsnum < SIMCLIST_MAX_SPARE_ELEMS && s != l->tail_sentinel; s = s->next) {
  ------------------
  |  |  115|  3.05k|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  |  Branch (637:46): [True: 1.39k, False: 132]
  |  Branch (637:91): [True: 843, False: 550]
  ------------------
  638|       |                /* move elements as spares as long as there is room */
  639|    843|                if (s->data != NULL) free(s->data);
  ------------------
  |  Branch (639:21): [True: 843, False: 0]
  ------------------
  640|    843|                l->spareels[l->spareelsnum++] = s;
  641|    843|            }
  642|  55.8k|            while (s != l->tail_sentinel) {
  ------------------
  |  Branch (642:20): [True: 55.1k, False: 682]
  ------------------
  643|       |                /* free the remaining elems */
  644|  55.1k|                if (s->data != NULL) free(s->data);
  ------------------
  |  Branch (644:21): [True: 55.1k, False: 0]
  ------------------
  645|  55.1k|                s = s->next;
  646|  55.1k|                free(s->prev);
  647|  55.1k|            }
  648|    682|            l->head_sentinel->next = l->tail_sentinel;
  649|    682|            l->tail_sentinel->prev = l->head_sentinel;
  650|  3.69k|        } else { /* only free element containers */
  651|       |            /* spare a loop conditional with two loops: spareing elems and freeing elems */
  652|  3.69k|            for (s = l->head_sentinel->next; l->spareelsnum < SIMCLIST_MAX_SPARE_ELEMS && s != l->tail_sentinel; s = s->next) {
  ------------------
  |  |  115|  7.38k|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  |  Branch (652:46): [True: 3.69k, False: 0]
  |  Branch (652:91): [True: 0, False: 3.69k]
  ------------------
  653|       |                /* move elements as spares as long as there is room */
  654|      0|                l->spareels[l->spareelsnum++] = s;
  655|      0|            }
  656|  3.69k|            while (s != l->tail_sentinel) {
  ------------------
  |  Branch (656:20): [True: 0, False: 3.69k]
  ------------------
  657|       |                /* free the remaining elems */
  658|      0|                s = s->next;
  659|      0|                free(s->prev);
  660|      0|            }
  661|  3.69k|            l->head_sentinel->next = l->tail_sentinel;
  662|  3.69k|            l->tail_sentinel->prev = l->head_sentinel;
  663|  3.69k|        }
  664|  4.37k|    }
  665|  4.37k|    l->numels = 0;
  666|  4.37k|    l->mid = NULL;
  667|       |
  668|  4.37k|    assert(list_repOk(l));
  669|       |
  670|  4.37k|    return 0;
  671|  4.37k|}
list_size:
  673|  11.0k|unsigned int list_size(const list_t *simclist_restrict l) {
  674|  11.0k|    return l->numels;
  675|  11.0k|}
list_locate:
  681|  6.23k|int list_locate(const list_t *simclist_restrict l, const void *data) {
  682|  6.23k|    struct list_entry_s *el;
  683|  6.23k|    int pos = 0;
  684|       |
  685|  6.23k|    if (l->head_sentinel == NULL || l->tail_sentinel == NULL) return -1;
  ------------------
  |  Branch (685:9): [True: 0, False: 6.23k]
  |  Branch (685:37): [True: 0, False: 6.23k]
  ------------------
  686|       |
  687|  6.23k|    if (l->attrs.comparator != NULL) {
  ------------------
  |  Branch (687:9): [True: 2.54k, False: 3.69k]
  ------------------
  688|       |        /* use comparator */
  689|  21.1k|        for (el = l->head_sentinel->next; el != l->tail_sentinel; el = el->next, pos++) {
  ------------------
  |  Branch (689:43): [True: 20.0k, False: 1.12k]
  ------------------
  690|  20.0k|            if (l->attrs.comparator(data, el->data) == 0) break;
  ------------------
  |  Branch (690:17): [True: 1.41k, False: 18.5k]
  ------------------
  691|  20.0k|        }
  692|  3.69k|    } else {
  693|       |        /* compare references */
  694|  3.69k|        for (el = l->head_sentinel->next; el != l->tail_sentinel; el = el->next, pos++) {
  ------------------
  |  Branch (694:43): [True: 3.69k, False: 0]
  ------------------
  695|  3.69k|            if (el->data == data) break;
  ------------------
  |  Branch (695:17): [True: 3.69k, False: 0]
  ------------------
  696|  3.69k|        }
  697|  3.69k|    }
  698|  6.23k|    if (el == l->tail_sentinel) return -1;
  ------------------
  |  Branch (698:9): [True: 1.12k, False: 5.11k]
  ------------------
  699|       |
  700|  5.11k|    return pos;
  701|  6.23k|}
list_seek:
  703|    120|void *list_seek(list_t *simclist_restrict l, const void *indicator) {
  704|    120|    const struct list_entry_s *iter;
  705|       |
  706|    120|    if (l->attrs.seeker == NULL) return NULL;
  ------------------
  |  Branch (706:9): [True: 0, False: 120]
  ------------------
  707|       |
  708|    120|    if (l->head_sentinel == NULL || l->tail_sentinel == NULL) return NULL;
  ------------------
  |  Branch (708:9): [True: 0, False: 120]
  |  Branch (708:37): [True: 0, False: 120]
  ------------------
  709|       |
  710|  56.4k|    for (iter = l->head_sentinel->next; iter != l->tail_sentinel; iter = iter->next) {
  ------------------
  |  Branch (710:41): [True: 56.3k, False: 109]
  ------------------
  711|  56.3k|        if (l->attrs.seeker(iter->data, indicator) != 0) return iter->data;
  ------------------
  |  Branch (711:13): [True: 11, False: 56.3k]
  ------------------
  712|  56.3k|    }
  713|       |
  714|    109|    return NULL;
  715|    120|}
list_contains:
  717|    808|int list_contains(const list_t *simclist_restrict l, const void *data) {
  718|    808|    return (list_locate(l, data) >= 0);
  719|    808|}
list_iterator_start:
  962|     70|int list_iterator_start(list_t *simclist_restrict l) {
  963|     70|    if (l->iter_active) return 0;
  ------------------
  |  Branch (963:9): [True: 0, False: 70]
  ------------------
  964|     70|    if (l->head_sentinel == NULL) return -1;
  ------------------
  |  Branch (964:9): [True: 0, False: 70]
  ------------------
  965|     70|    l->iter_pos = 0;
  966|     70|    l->iter_active = 1;
  967|     70|    l->iter_curentry = l->head_sentinel->next;
  968|     70|    return 1;
  969|     70|}
list_iterator_next:
  971|    347|void *list_iterator_next(list_t *simclist_restrict l) {
  972|    347|    void *toret;
  973|       |
  974|    347|    if (! l->iter_active) return NULL;
  ------------------
  |  Branch (974:9): [True: 0, False: 347]
  ------------------
  975|       |
  976|    347|    toret = l->iter_curentry->data;
  977|    347|    l->iter_curentry = l->iter_curentry->next;
  978|    347|    l->iter_pos++;
  979|       |
  980|    347|    return toret;
  981|    347|}
list_iterator_hasnext:
  983|    417|int list_iterator_hasnext(const list_t *simclist_restrict l) {
  984|    417|    if (! l->iter_active) return 0;
  ------------------
  |  Branch (984:9): [True: 0, False: 417]
  ------------------
  985|    417|    return (l->iter_pos < l->numels);
  986|    417|}
list_iterator_stop:
  988|     70|int list_iterator_stop(list_t *simclist_restrict l) {
  989|     70|    if (! l->iter_active) return 0;
  ------------------
  |  Branch (989:9): [True: 0, False: 70]
  ------------------
  990|     70|    l->iter_pos = 0;
  991|     70|    l->iter_active = 0;
  992|     70|    return 1;
  993|     70|}
simclist.c:list_attributes_setdefaults:
  295|  4.37k|int list_attributes_setdefaults(list_t *simclist_restrict l) {
  296|  4.37k|    l->attrs.comparator = NULL;
  297|  4.37k|    l->attrs.seeker = NULL;
  298|       |
  299|       |    /* also free() element data when removing and element from the list */
  300|  4.37k|    l->attrs.meter = NULL;
  301|  4.37k|    l->attrs.copy_data = 0;
  302|       |
  303|  4.37k|    l->attrs.hasher = NULL;
  304|       |
  305|       |    /* serializer/unserializer */
  306|  4.37k|    l->attrs.serializer = NULL;
  307|  4.37k|    l->attrs.unserializer = NULL;
  308|       |
  309|  4.37k|    assert(list_attrOk(l));
  310|       |
  311|  4.37k|    return 0;
  312|  4.37k|}
simclist.c:list_findpos:
  416|  72.1k|static simclist_inline struct list_entry_s *list_findpos(const list_t *simclist_restrict l, int posstart) {
  417|  72.1k|    struct list_entry_s *ptr;
  418|  72.1k|    float x;
  419|  72.1k|    int i;
  420|       |
  421|  72.1k|    if (l->head_sentinel == NULL || l->tail_sentinel == NULL) return NULL;
  ------------------
  |  Branch (421:9): [True: 0, False: 72.1k]
  |  Branch (421:37): [True: 0, False: 72.1k]
  ------------------
  422|       |
  423|       |    /* accept 1 slot overflow for fetching head and tail sentinels */
  424|  72.1k|    if (posstart < -1 || posstart > (int)l->numels) return NULL;
  ------------------
  |  Branch (424:9): [True: 0, False: 72.1k]
  |  Branch (424:26): [True: 0, False: 72.1k]
  ------------------
  425|       |
  426|  72.1k|    x = l->numels ? (float)(posstart+1) / l->numels : 0;
  ------------------
  |  Branch (426:9): [True: 68.2k, False: 3.90k]
  ------------------
  427|  72.1k|    if (x <= 0.25) {
  ------------------
  |  Branch (427:9): [True: 4.21k, False: 67.9k]
  ------------------
  428|       |        /* first quarter: get to posstart from head */
  429|  4.93k|        for (i = -1, ptr = l->head_sentinel; i < posstart; ptr = ptr->next, i++);
  ------------------
  |  Branch (429:46): [True: 721, False: 4.21k]
  ------------------
  430|  67.9k|    } else if (x < 0.5) {
  ------------------
  |  Branch (430:16): [True: 446, False: 67.5k]
  ------------------
  431|       |        /* second quarter: get to posstart from mid */
  432|  1.47k|        for (i = (l->numels-1)/2, ptr = l->mid; i > posstart; ptr = ptr->prev, i--);
  ------------------
  |  Branch (432:49): [True: 1.03k, False: 446]
  ------------------
  433|  67.5k|    } else if (x <= 0.75) {
  ------------------
  |  Branch (433:16): [True: 502, False: 67.0k]
  ------------------
  434|       |        /* third quarter: get to posstart from mid */
  435|  1.17k|        for (i = (l->numels-1)/2, ptr = l->mid; i < posstart; ptr = ptr->next, i++);
  ------------------
  |  Branch (435:49): [True: 677, False: 502]
  ------------------
  436|  67.0k|    } else {
  437|       |        /* fourth quarter: get to posstart from tail */
  438|   134k|        for (i = l->numels, ptr = l->tail_sentinel; i > posstart; ptr = ptr->prev, i--);
  ------------------
  |  Branch (438:53): [True: 67.3k, False: 67.0k]
  ------------------
  439|  67.0k|    }
  440|       |
  441|  72.1k|    return ptr;
  442|  72.1k|}
simclist.c:list_drop_elem:
 1427|  3.69k|static int list_drop_elem(list_t *simclist_restrict l, struct list_entry_s *tmp, unsigned int pos) {
 1428|  3.69k|    if (tmp == NULL) return -1;
  ------------------
  |  Branch (1428:9): [True: 0, False: 3.69k]
  ------------------
 1429|       |
 1430|       |    /* fix mid pointer. This is wrt the PRE situation */
 1431|  3.69k|    if (l->numels % 2) {    /* now odd */
  ------------------
  |  Branch (1431:9): [True: 3.69k, False: 0]
  ------------------
 1432|       |        /* sort out the base case by hand */
 1433|  3.69k|        if (l->numels == 1) l->mid = NULL;
  ------------------
  |  Branch (1433:13): [True: 3.69k, False: 0]
  ------------------
 1434|      0|        else if (pos >= l->numels/2) l->mid = l->mid->prev;
  ------------------
  |  Branch (1434:18): [True: 0, False: 0]
  ------------------
 1435|  3.69k|    } else {                /* now even */
 1436|      0|        if (pos < l->numels/2) l->mid = l->mid->next;
  ------------------
  |  Branch (1436:13): [True: 0, False: 0]
  ------------------
 1437|      0|    }
 1438|       |
 1439|  3.69k|    tmp->prev->next = tmp->next;
 1440|  3.69k|    tmp->next->prev = tmp->prev;
 1441|       |
 1442|       |    /* free what's to be freed */
 1443|  3.69k|    if (l->attrs.copy_data && tmp->data != NULL)
  ------------------
  |  Branch (1443:9): [True: 0, False: 3.69k]
  |  Branch (1443:31): [True: 0, False: 0]
  ------------------
 1444|      0|        free(tmp->data);
 1445|       |
 1446|  3.69k|    if (l->spareels != NULL && l->spareelsnum < SIMCLIST_MAX_SPARE_ELEMS) {
  ------------------
  |  |  115|  3.69k|#define SIMCLIST_MAX_SPARE_ELEMS        5
  ------------------
  |  Branch (1446:9): [True: 3.69k, False: 0]
  |  Branch (1446:32): [True: 3.69k, False: 0]
  ------------------
 1447|  3.69k|        l->spareels[l->spareelsnum++] = tmp;
 1448|  3.69k|    } else {
 1449|      0|        free(tmp);
 1450|      0|    }
 1451|       |
 1452|  3.69k|    return 0;
 1453|  3.69k|}

sc_apdu_get_length:
   43|  6.16k|{
   44|  6.16k|	size_t ret = 4;
   45|       |
   46|  6.16k|	switch (apdu->cse) {
   47|      0|	case SC_APDU_CASE_1:
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  |  Branch (47:2): [True: 0, False: 6.16k]
  ------------------
   48|      0|		if (proto == SC_PROTO_T0)
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (48:7): [True: 0, False: 0]
  ------------------
   49|      0|			ret++;
   50|      0|		break;
   51|  4.79k|	case SC_APDU_CASE_2_SHORT:
  ------------------
  |  |  292|  4.79k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (51:2): [True: 4.79k, False: 1.36k]
  ------------------
   52|  4.79k|		ret++;
   53|  4.79k|		break;
   54|      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 (54:2): [True: 0, False: 6.16k]
  ------------------
   55|      0|		ret += (proto == SC_PROTO_T0 ? 1 : 3);
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (55:11): [True: 0, False: 0]
  ------------------
   56|      0|		break;
   57|  1.36k|	case SC_APDU_CASE_3_SHORT:
  ------------------
  |  |  293|  1.36k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (57:2): [True: 1.36k, False: 4.79k]
  ------------------
   58|  1.36k|		ret += 1 + apdu->lc;
   59|  1.36k|		break;
   60|      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 (60:2): [True: 0, False: 6.16k]
  ------------------
   61|      0|		ret += apdu->lc + (proto == SC_PROTO_T0 ? 1 : 3);
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (61:22): [True: 0, False: 0]
  ------------------
   62|      0|		break;
   63|      0|	case SC_APDU_CASE_4_SHORT:
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (63:2): [True: 0, False: 6.16k]
  ------------------
   64|      0|		ret += apdu->lc + (proto != SC_PROTO_T0 ? 2 : 1);
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (64:22): [True: 0, False: 0]
  ------------------
   65|      0|		break;
   66|      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 (66:2): [True: 0, False: 6.16k]
  ------------------
   67|      0|		ret += apdu->lc + (proto == SC_PROTO_T0 ? 1 : 5);
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (67:22): [True: 0, False: 0]
  ------------------
   68|      0|		break;
   69|      0|	default:
  ------------------
  |  Branch (69:2): [True: 0, False: 6.16k]
  ------------------
   70|      0|		return 0;
   71|  6.16k|	}
   72|  6.16k|	return ret;
   73|  6.16k|}
sc_apdu2bytes:
   85|  3.08k|{
   86|  3.08k|	u8     *p = out;
   87|       |
   88|  3.08k|	size_t len = sc_apdu_get_length(apdu, proto);
   89|       |
   90|  3.08k|	if (out == NULL || outlen < len)
  ------------------
  |  Branch (90:6): [True: 0, False: 3.08k]
  |  Branch (90:21): [True: 0, False: 3.08k]
  ------------------
   91|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   92|       |	/* CLA, INS, P1 and P2 */
   93|  3.08k|	*p++ = apdu->cla;
   94|  3.08k|	*p++ = apdu->ins;
   95|  3.08k|	*p++ = apdu->p1;
   96|  3.08k|	*p++ = apdu->p2;
   97|       |	/* case depend part */
   98|  3.08k|	switch (apdu->cse) {
  ------------------
  |  Branch (98:10): [True: 3.08k, False: 0]
  ------------------
   99|      0|	case SC_APDU_CASE_1:
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  |  Branch (99:2): [True: 0, False: 3.08k]
  ------------------
  100|       |		/* T0 needs an additional 0x00 byte */
  101|      0|		if (proto == SC_PROTO_T0)
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (101:7): [True: 0, False: 0]
  ------------------
  102|      0|			*p = (u8)0x00;
  103|      0|		break;
  104|  2.39k|	case SC_APDU_CASE_2_SHORT:
  ------------------
  |  |  292|  2.39k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (104:2): [True: 2.39k, False: 684]
  ------------------
  105|  2.39k|		*p = (u8)apdu->le;
  106|  2.39k|		break;
  107|      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 (107:2): [True: 0, False: 3.08k]
  ------------------
  108|      0|		if (proto == SC_PROTO_T0)
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (108:7): [True: 0, False: 0]
  ------------------
  109|       |			/* T0 extended APDUs look just like short APDUs */
  110|      0|			*p = (u8)apdu->le;
  111|      0|		else {
  112|       |			/* in case of T1 always use 3 bytes for length */
  113|      0|			*p++ = (u8)0x00;
  114|      0|			*p++ = (u8)(apdu->le >> 8);
  115|      0|			*p = (u8)apdu->le;
  116|      0|		}
  117|      0|		break;
  118|    684|	case SC_APDU_CASE_3_SHORT:
  ------------------
  |  |  293|    684|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (118:2): [True: 684, False: 2.39k]
  ------------------
  119|    684|		*p++ = (u8)apdu->lc;
  120|    684|		memcpy(p, apdu->data, apdu->lc);
  121|    684|		break;
  122|      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 (122:2): [True: 0, False: 3.08k]
  ------------------
  123|      0|		if (proto == SC_PROTO_T0) {
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (123:7): [True: 0, False: 0]
  ------------------
  124|       |			/* in case of T0 the command is transmitted in chunks
  125|       |			 * < 255 using the ENVELOPE command ... */
  126|      0|			if (apdu->lc > 255) {
  ------------------
  |  Branch (126:8): [True: 0, False: 0]
  ------------------
  127|       |				/* ... so if Lc is greater than 255 bytes
  128|       |				 * an error has occurred on a higher level */
  129|      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__
  |  |  ------------------
  ------------------
  130|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  131|      0|			}
  132|      0|		}
  133|      0|		else {
  134|       |			/* in case of T1 always use 3 bytes for length */
  135|      0|			*p++ = (u8)0x00;
  136|      0|			*p++ = (u8)(apdu->lc >> 8);
  137|      0|			*p++ = (u8)apdu->lc;
  138|      0|		}
  139|      0|		memcpy(p, apdu->data, apdu->lc);
  140|      0|		break;
  141|      0|	case SC_APDU_CASE_4_SHORT:
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (141:2): [True: 0, False: 3.08k]
  ------------------
  142|      0|		*p++ = (u8)apdu->lc;
  143|      0|		memcpy(p, apdu->data, apdu->lc);
  144|      0|		p += apdu->lc;
  145|       |		/* in case of T0 no Le byte is added */
  146|      0|		if (proto != SC_PROTO_T0)
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (146:7): [True: 0, False: 0]
  ------------------
  147|      0|			*p = (u8)apdu->le;
  148|      0|		break;
  149|      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 (149:2): [True: 0, False: 3.08k]
  ------------------
  150|      0|		if (proto == SC_PROTO_T0) {
  ------------------
  |  |  359|      0|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (150:7): [True: 0, False: 0]
  ------------------
  151|       |			/* again a T0 extended case 4 APDU looks just
  152|       |			 * like a short APDU, the additional data is
  153|       |			 * transferred using ENVELOPE and GET RESPONSE */
  154|      0|			*p++ = (u8)apdu->lc;
  155|      0|			memcpy(p, apdu->data, apdu->lc);
  156|      0|		}
  157|      0|		else {
  158|      0|			*p++ = (u8)0x00;
  159|      0|			*p++ = (u8)(apdu->lc >> 8);
  160|      0|			*p++ = (u8)apdu->lc;
  161|      0|			memcpy(p, apdu->data, apdu->lc);
  162|      0|			p += apdu->lc;
  163|       |			/* only 2 bytes are use to specify the length of the
  164|       |			 * expected data */
  165|      0|			*p++ = (u8)(apdu->le >> 8);
  166|      0|			*p = (u8)apdu->le;
  167|      0|		}
  168|      0|		break;
  169|  3.08k|	}
  170|       |
  171|  3.08k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.08k|#define SC_SUCCESS				0
  ------------------
  172|  3.08k|}
sc_apdu_get_octets:
  176|  3.08k|{
  177|  3.08k|	size_t	nlen;
  178|  3.08k|	u8	*nbuf;
  179|       |
  180|  3.08k|	if (apdu == NULL || buf == NULL || len == NULL)
  ------------------
  |  Branch (180:6): [True: 0, False: 3.08k]
  |  Branch (180:22): [True: 0, False: 3.08k]
  |  Branch (180:37): [True: 0, False: 3.08k]
  ------------------
  181|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  182|       |
  183|       |	/* get the estimated length of encoded APDU */
  184|  3.08k|	nlen = sc_apdu_get_length(apdu, proto);
  185|  3.08k|	if (nlen == 0)
  ------------------
  |  Branch (185:6): [True: 0, False: 3.08k]
  ------------------
  186|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  187|  3.08k|	nbuf = malloc(nlen);
  188|  3.08k|	if (nbuf == NULL)
  ------------------
  |  Branch (188:6): [True: 0, False: 3.08k]
  ------------------
  189|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  190|       |	/* encode the APDU in the buffer */
  191|  3.08k|	if (sc_apdu2bytes(ctx, apdu, proto, nbuf, nlen) != SC_SUCCESS) {
  ------------------
  |  |   28|  3.08k|#define SC_SUCCESS				0
  ------------------
  |  Branch (191:6): [True: 0, False: 3.08k]
  ------------------
  192|      0|		free(nbuf);
  193|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  194|      0|	}
  195|  3.08k|	*buf = nbuf;
  196|  3.08k|	*len = nlen;
  197|       |
  198|  3.08k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.08k|#define SC_SUCCESS				0
  ------------------
  199|  3.08k|}
sc_check_apdu:
  257|   778k|{
  258|   778k|	if ((apdu->cse & ~SC_APDU_SHORT_MASK) == 0) {
  ------------------
  |  |  295|   778k|#define SC_APDU_SHORT_MASK		0x0f
  ------------------
  |  Branch (258:6): [True: 772k, False: 5.88k]
  ------------------
  259|       |		/* length check for short APDU */
  260|   772k|		if (apdu->le > 256 || (apdu->lc > 255 && (apdu->flags & SC_APDU_FLAGS_CHAINING) == 0))   {
  ------------------
  |  |  306|      0|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  |  Branch (260:7): [True: 1.09k, False: 771k]
  |  Branch (260:26): [True: 0, False: 771k]
  |  Branch (260:44): [True: 0, False: 0]
  ------------------
  261|  1.09k|			sc_log(card->ctx, "failed length check for short APDU");
  ------------------
  |  |   71|  1.09k|#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|  1.09k|			goto error;
  263|  1.09k|		}
  264|   772k|	}
  265|  5.88k|	else if ((apdu->cse & SC_APDU_EXT) != 0) {
  ------------------
  |  |  296|  5.88k|#define SC_APDU_EXT			0x10
  ------------------
  |  Branch (265:11): [True: 5.88k, False: 0]
  ------------------
  266|       |		/* check if the card supports extended APDUs */
  267|  5.88k|		if ((card->caps & SC_CARD_CAP_APDU_EXT) == 0) {
  ------------------
  |  |  554|  5.88k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (267:7): [True: 0, False: 5.88k]
  ------------------
  268|      0|			sc_log(card->ctx, "card doesn't support extended APDUs");
  ------------------
  |  |   71|      0|#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|			goto error;
  270|      0|		}
  271|       |		/* length check for extended APDU */
  272|  5.88k|		if (apdu->le > 65536 || apdu->lc > 65535)   {
  ------------------
  |  Branch (272:7): [True: 0, False: 5.88k]
  |  Branch (272:27): [True: 0, False: 5.88k]
  ------------------
  273|      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__
  |  |  ------------------
  ------------------
  274|      0|			goto error;
  275|      0|		}
  276|  5.88k|	}
  277|      0|	else   {
  278|      0|		goto error;
  279|      0|	}
  280|       |
  281|   777k|	switch (apdu->cse & SC_APDU_SHORT_MASK) {
  ------------------
  |  |  295|   777k|#define SC_APDU_SHORT_MASK		0x0f
  ------------------
  282|  1.60k|	case SC_APDU_CASE_1:
  ------------------
  |  |  291|  1.60k|#define SC_APDU_CASE_1			0x01
  ------------------
  |  Branch (282:2): [True: 1.60k, False: 775k]
  ------------------
  283|       |		/* no data is sent or received */
  284|  1.60k|		if (apdu->datalen != 0 || apdu->lc != 0 || apdu->le != 0)
  ------------------
  |  Branch (284:7): [True: 0, False: 1.60k]
  |  Branch (284:29): [True: 0, False: 1.60k]
  |  Branch (284:46): [True: 0, False: 1.60k]
  ------------------
  285|      0|			goto error;
  286|  1.60k|		break;
  287|   293k|	case SC_APDU_CASE_2_SHORT:
  ------------------
  |  |  292|   293k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  |  Branch (287:2): [True: 293k, False: 483k]
  ------------------
  288|       |		/* no data is sent */
  289|   293k|		if (apdu->datalen != 0 || apdu->lc != 0)
  ------------------
  |  Branch (289:7): [True: 0, False: 293k]
  |  Branch (289:29): [True: 0, False: 293k]
  ------------------
  290|      0|			goto error;
  291|       |		/* data is expected       */
  292|   293k|		if (apdu->resplen == 0 || apdu->resp == NULL)
  ------------------
  |  Branch (292:7): [True: 0, False: 293k]
  |  Branch (292:29): [True: 0, False: 293k]
  ------------------
  293|      0|			goto error;
  294|   293k|		break;
  295|   293k|	case SC_APDU_CASE_3_SHORT:
  ------------------
  |  |  293|   139k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (295:2): [True: 139k, False: 638k]
  ------------------
  296|       |		/* data is sent */
  297|   139k|		if (apdu->datalen == 0 || apdu->data == NULL || apdu->lc == 0)
  ------------------
  |  Branch (297:7): [True: 0, False: 139k]
  |  Branch (297:29): [True: 0, False: 139k]
  |  Branch (297:51): [True: 0, False: 139k]
  ------------------
  298|      0|			goto error;
  299|       |		/* no data is expected    */
  300|   139k|		if (apdu->le != 0)
  ------------------
  |  Branch (300:7): [True: 0, False: 139k]
  ------------------
  301|      0|			goto error;
  302|       |		/* inconsistent datalen   */
  303|   139k|		if (apdu->datalen != apdu->lc)
  ------------------
  |  Branch (303:7): [True: 0, False: 139k]
  ------------------
  304|      0|			goto error;
  305|   139k|		break;
  306|   342k|	case SC_APDU_CASE_4_SHORT:
  ------------------
  |  |  294|   342k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (306:2): [True: 342k, False: 434k]
  ------------------
  307|       |		/* data is sent */
  308|   342k|		if (apdu->datalen == 0 || apdu->data == NULL || apdu->lc == 0)
  ------------------
  |  Branch (308:7): [True: 32.8k, False: 309k]
  |  Branch (308:29): [True: 0, False: 309k]
  |  Branch (308:51): [True: 0, False: 309k]
  ------------------
  309|  32.8k|			goto error;
  310|       |		/* data is expected       */
  311|   309k|		if (apdu->resplen == 0 || apdu->resp == NULL)
  ------------------
  |  Branch (311:7): [True: 0, False: 309k]
  |  Branch (311:29): [True: 0, False: 309k]
  ------------------
  312|      0|			goto error;
  313|       |		/* inconsistent datalen   */
  314|   309k|		if (apdu->datalen != apdu->lc)
  ------------------
  |  Branch (314:7): [True: 0, False: 309k]
  ------------------
  315|      0|			goto error;
  316|   309k|		break;
  317|   309k|	default:
  ------------------
  |  Branch (317:2): [True: 0, False: 777k]
  ------------------
  318|      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__
  |  |  ------------------
  ------------------
  319|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  320|   777k|	}
  321|   744k|	return SC_SUCCESS;
  ------------------
  |  |   28|   744k|#define SC_SUCCESS				0
  ------------------
  322|  33.9k|error:
  323|  33.9k|	sc_log(card->ctx, "Invalid Case %d %s APDU:\n"
  ------------------
  |  |   71|  33.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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  326|  67.9k|		apdu->cse & SC_APDU_SHORT_MASK,
  |  |  |  |  ------------------
  |  |  |  |  |  |  295|  33.9k|#define SC_APDU_SHORT_MASK		0x0f
  |  |  |  |  ------------------
  |  |  |  |  327|  67.9k|		(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
  |  |  |  |  ------------------
  |  |  |  |  |  |  296|  33.9k|#define SC_APDU_EXT			0x10
  |  |  |  |  ------------------
  |  |  |  |  328|  67.9k|		apdu->cse, apdu->cla, apdu->ins, apdu->p1, apdu->p2,
  |  |  |  |  329|  67.9k|		(unsigned long) apdu->lc, (unsigned long) apdu->le,
  |  |  |  |  330|  67.9k|		apdu->resp, (unsigned long) apdu->resplen,
  |  |  |  |  331|  67.9k|		apdu->data, (unsigned long) apdu->datalen, apdu->flags);
  |  |  ------------------
  ------------------
  324|  33.9k|		"cse=%02x cla=%02x ins=%02x p1=%02x p2=%02x lc=%lu le=%lu\n"
  325|  33.9k|		"resp=%p resplen=%lu data=%p datalen=%lu flags=0x%8.8lx",
  326|  33.9k|		apdu->cse & SC_APDU_SHORT_MASK,
  327|  33.9k|		(apdu->cse & SC_APDU_EXT) != 0 ? "extended" : "short",
  328|  33.9k|		apdu->cse, apdu->cla, apdu->ins, apdu->p1, apdu->p2,
  329|  33.9k|		(unsigned long) apdu->lc, (unsigned long) apdu->le,
  330|  33.9k|		apdu->resp, (unsigned long) apdu->resplen,
  331|  33.9k|		apdu->data, (unsigned long) apdu->datalen, apdu->flags);
  332|  33.9k|	return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  33.9k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  333|   777k|}
sc_transmit_apdu:
  544|   777k|{
  545|   777k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|   777k|#define SC_SUCCESS				0
  ------------------
  546|       |
  547|   777k|	if (card == NULL || apdu == NULL)
  ------------------
  |  Branch (547:6): [True: 0, False: 777k]
  |  Branch (547:22): [True: 0, False: 777k]
  ------------------
  548|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  549|       |
  550|   777k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|   777k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   777k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   777k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   777k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 777k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  551|       |
  552|       |	/* determine the APDU type if necessary, i.e. to use
  553|       |	 * short or extended APDUs  */
  554|   777k|	sc_detect_apdu_cse(card, apdu);
  555|       |	/* basic APDU consistency check */
  556|   777k|	r = sc_check_apdu(card, apdu);
  557|   777k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   777k|#define SC_SUCCESS				0
  ------------------
  |  Branch (557:6): [True: 33.9k, False: 743k]
  ------------------
  558|  33.9k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  33.9k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  559|       |
  560|   743k|	r = sc_lock(card);	/* acquire card lock*/
  561|   743k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|   743k|#define SC_SUCCESS				0
  ------------------
  |  Branch (561:6): [True: 0, False: 743k]
  ------------------
  562|      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__
  |  |  ------------------
  ------------------
  563|      0|		return r;
  564|      0|	}
  565|       |
  566|   743k|#if ENABLE_SM
  567|   743k|	if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT
  ------------------
  |  |   47|  1.48M|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (567:6): [True: 729, False: 743k]
  ------------------
  568|    729|			&& (apdu->flags & SC_APDU_FLAGS_CHAINING) != 0
  ------------------
  |  |  306|    729|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  |  Branch (568:7): [True: 0, False: 729]
  ------------------
  569|      0|			&& (apdu->flags & SC_APDU_FLAGS_SM_CHAINING) != 0) {
  ------------------
  |  |  316|      0|#define SC_APDU_FLAGS_SM_CHAINING	0x00000010UL
  ------------------
  |  Branch (569:7): [True: 0, False: 0]
  ------------------
  570|      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__
  |  |  ------------------
  ------------------
  571|      0|		r = sc_transmit(card, apdu);
  572|      0|	} else
  573|   743k|#endif
  574|   743k|	if ((apdu->flags & SC_APDU_FLAGS_CHAINING) != 0) {
  ------------------
  |  |  306|   743k|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  |  Branch (574:6): [True: 170, False: 743k]
  ------------------
  575|       |		/* divide et impera: transmit APDU in chunks with Lc <= max_send_size
  576|       |		 * bytes using command chaining */
  577|    170|		size_t    len  = apdu->datalen;
  578|    170|		const u8  *buf = apdu->data;
  579|    170|		size_t    max_send_size = sc_get_max_send_size(card);
  580|       |
  581|    467|		while (len != 0) {
  ------------------
  |  Branch (581:10): [True: 335, False: 132]
  ------------------
  582|    335|			size_t    plen;
  583|    335|			sc_apdu_t tapdu;
  584|    335|			int       last = 0;
  585|       |
  586|    335|			tapdu = *apdu;
  587|       |			/* clear chaining flag */
  588|    335|			tapdu.flags &= ~SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|    335|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  589|    335|			if (len > max_send_size) {
  ------------------
  |  Branch (589:8): [True: 188, False: 147]
  ------------------
  590|       |				/* adjust APDU case: in case of CASE 4 APDU
  591|       |				 * the intermediate APDU are of CASE 3 */
  592|    188|				if ((tapdu.cse & SC_APDU_SHORT_MASK) == SC_APDU_CASE_4_SHORT)
  ------------------
  |  |  295|    188|#define SC_APDU_SHORT_MASK		0x0f
  ------------------
              				if ((tapdu.cse & SC_APDU_SHORT_MASK) == SC_APDU_CASE_4_SHORT)
  ------------------
  |  |  294|    188|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (592:9): [True: 188, False: 0]
  ------------------
  593|    188|					tapdu.cse--;
  594|       |				/* XXX: the chunk size must be adjusted when
  595|       |				 *      secure messaging is used */
  596|    188|				plen          = max_send_size;
  597|    188|				tapdu.cla    |= 0x10;
  598|       |				/* the intermediate APDU don't expect response data */
  599|    188|				tapdu.le      = 0;
  600|    188|				tapdu.resplen = 0;
  601|    188|				tapdu.resp    = NULL;
  602|    188|			} else {
  603|    147|				plen = len;
  604|    147|				last = 1;
  605|    147|			}
  606|    335|			tapdu.data    = buf;
  607|    335|			tapdu.datalen = tapdu.lc = plen;
  608|       |
  609|    335|			r = sc_check_apdu(card, &tapdu);
  610|    335|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    335|#define SC_SUCCESS				0
  ------------------
  |  Branch (610:8): [True: 0, False: 335]
  ------------------
  611|      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__
  |  |  ------------------
  ------------------
  612|      0|				break;
  613|      0|			}
  614|       |
  615|    335|			r = sc_transmit(card, &tapdu);
  616|    335|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|    335|#define SC_SUCCESS				0
  ------------------
  |  Branch (616:8): [True: 15, False: 320]
  ------------------
  617|     15|				break;
  618|    320|			if (last != 0) {
  ------------------
  |  Branch (618:8): [True: 132, False: 188]
  ------------------
  619|       |				/* in case of the last APDU set the SW1
  620|       |				 * and SW2 bytes in the original APDU */
  621|    132|				apdu->sw1 = tapdu.sw1;
  622|    132|				apdu->sw2 = tapdu.sw2;
  623|    132|				apdu->resplen = tapdu.resplen;
  624|    188|			} else {
  625|       |				/* otherwise check the status bytes */
  626|    188|				r = sc_check_sw(card, tapdu.sw1, tapdu.sw2);
  627|    188|				if (r != SC_SUCCESS)
  ------------------
  |  |   28|    188|#define SC_SUCCESS				0
  ------------------
  |  Branch (627:9): [True: 23, False: 165]
  ------------------
  628|     23|					break;
  629|    188|			}
  630|    297|			len -= plen;
  631|    297|			buf += plen;
  632|    297|		}
  633|   743k|	} else {
  634|       |		/* transmit single APDU */
  635|   743k|		r = sc_transmit(card, apdu);
  636|   743k|	}
  637|       |
  638|   743k|	if (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   37|  1.48M|#define SC_ERROR_CARD_RESET			-1106
  ------------------
              	if (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   46|   743k|#define SC_ERROR_READER_REATTACHED		-1115
  ------------------
  |  Branch (638:6): [True: 0, False: 743k]
  |  Branch (638:34): [True: 0, False: 743k]
  ------------------
  639|       |		/* give card driver a chance to react on resets */
  640|      0|		if (card->ops->card_reader_lock_obtained)
  ------------------
  |  Branch (640:7): [True: 0, False: 0]
  ------------------
  641|      0|			card->ops->card_reader_lock_obtained(card, 1);
  642|      0|	}
  643|       |
  644|       |	/* all done => release lock */
  645|   743k|	if (sc_unlock(card) != SC_SUCCESS)
  ------------------
  |  |   28|   743k|#define SC_SUCCESS				0
  ------------------
  |  Branch (645:6): [True: 0, False: 743k]
  ------------------
  646|      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__
  |  |  ------------------
  ------------------
  647|       |
  648|   743k|	return r;
  649|   743k|}
apdu.c:sc_detect_apdu_cse:
  341|   777k|{
  342|   777k|	if (apdu->cse == SC_APDU_CASE_2 || apdu->cse == SC_APDU_CASE_3 ||
  ------------------
  |  |  301|  1.55M|#define SC_APDU_CASE_2			0x22
  ------------------
              	if (apdu->cse == SC_APDU_CASE_2 || apdu->cse == SC_APDU_CASE_3 ||
  ------------------
  |  |  302|  1.35M|#define SC_APDU_CASE_3			0x23
  ------------------
  |  Branch (342:6): [True: 198k, False: 579k]
  |  Branch (342:37): [True: 3.19k, False: 575k]
  ------------------
  343|   575k|	    apdu->cse == SC_APDU_CASE_4) {
  ------------------
  |  |  303|   575k|#define SC_APDU_CASE_4			0x24
  ------------------
  |  Branch (343:6): [True: 4.08k, False: 571k]
  ------------------
  344|   206k|		int btype = apdu->cse & SC_APDU_SHORT_MASK;
  ------------------
  |  |  295|   206k|#define SC_APDU_SHORT_MASK		0x0f
  ------------------
  345|       |		/* if either Lc or Le is bigger than the maximum for
  346|       |		 * short APDUs and the card supports extended APDUs
  347|       |		 * use extended APDUs (unless Lc is greater than
  348|       |		 * 255 and command chaining is activated) */
  349|   206k|		if ((apdu->le > 256 || (apdu->lc > 255 && (apdu->flags & SC_APDU_FLAGS_CHAINING) == 0)) &&
  ------------------
  |  |  306|    708|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  |  Branch (349:8): [True: 5.57k, False: 200k]
  |  Branch (349:27): [True: 708, False: 199k]
  |  Branch (349:45): [True: 708, False: 0]
  ------------------
  350|  6.28k|		    (card->caps & SC_CARD_CAP_APDU_EXT) != 0)
  ------------------
  |  |  554|  6.28k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (350:7): [True: 5.19k, False: 1.09k]
  ------------------
  351|  5.19k|			btype |= SC_APDU_EXT;
  ------------------
  |  |  296|  5.19k|#define SC_APDU_EXT			0x10
  ------------------
  352|   206k|		apdu->cse = btype;
  353|   206k|	}
  354|   777k|}
apdu.c:sc_transmit:
  510|   744k|{
  511|   744k|	struct sc_context *ctx  = card->ctx;
  512|   744k|	size_t       olen  = apdu->resplen;
  513|   744k|	int          r;
  514|       |
  515|   744k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|   744k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   744k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   744k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   744k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 744k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  516|       |
  517|   744k|	r = sc_single_transmit(card, apdu);
  518|   744k|	LOG_TEST_RET(ctx, r, "transmit APDU failed");
  ------------------
  |  |  174|   744k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   744k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   744k|	int _ret = (r); \
  |  |  |  |  168|   744k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 185, False: 743k]
  |  |  |  |  ------------------
  |  |  |  |  169|    185|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    185|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    185|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    185|		return _ret; \
  |  |  |  |  172|    185|	} \
  |  |  |  |  173|   744k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 743k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|       |
  520|       |	/* ok, the APDU was successfully transmitted. Now we have two special cases:
  521|       |	 * 1. the card returned 0x6Cxx: in this case APDU will be re-transmitted with Le set to SW2
  522|       |	 * (possible only if response buffer size is larger than new Le = SW2)
  523|       |	 */
  524|   743k|	if (apdu->sw1 == 0x6C && (apdu->flags & SC_APDU_FLAGS_NO_RETRY_WL) == 0) {
  ------------------
  |  |  312|    949|#define SC_APDU_FLAGS_NO_RETRY_WL	0x00000004UL
  ------------------
  |  Branch (524:6): [True: 949, False: 742k]
  |  Branch (524:27): [True: 909, False: 40]
  ------------------
  525|    909|		r = sc_set_le_and_transmit(card, apdu, olen);
  526|    909|		LOG_TEST_RET(ctx, r, "cannot re-transmit APDU ");
  ------------------
  |  |  174|    909|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    909|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    909|	int _ret = (r); \
  |  |  |  |  168|    909|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 604, False: 305]
  |  |  |  |  ------------------
  |  |  |  |  169|    604|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    604|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    604|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    604|		return _ret; \
  |  |  |  |  172|    604|	} \
  |  |  |  |  173|    909|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 305]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  527|    909|	}
  528|       |
  529|       |	/* 2. the card returned 0x61xx: more data can be read from the card
  530|       |	 *    using the GET RESPONSE command (mostly used in the T0 protocol).
  531|       |	 *    Unless the SC_APDU_FLAGS_NO_GET_RESP is set we try to read as
  532|       |	 *    much data as possible using GET RESPONSE.
  533|       |	 */
  534|   743k|	if (apdu->sw1 == 0x61 && (apdu->flags & SC_APDU_FLAGS_NO_GET_RESP) == 0) {
  ------------------
  |  |  308|  32.9k|#define SC_APDU_FLAGS_NO_GET_RESP	0x00000002UL
  ------------------
  |  Branch (534:6): [True: 32.9k, False: 710k]
  |  Branch (534:27): [True: 24.9k, False: 8.00k]
  ------------------
  535|  24.9k|		r = sc_get_response(card, apdu, olen);
  536|  24.9k|		LOG_TEST_RET(ctx, r, "cannot get all data with 'GET RESPONSE'");
  ------------------
  |  |  174|  24.9k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  24.9k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  24.9k|	int _ret = (r); \
  |  |  |  |  168|  24.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5.52k, False: 19.4k]
  |  |  |  |  ------------------
  |  |  |  |  169|  5.52k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.52k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  5.52k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  5.52k|		return _ret; \
  |  |  |  |  172|  5.52k|	} \
  |  |  |  |  173|  24.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19.4k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  537|  24.9k|	}
  538|       |
  539|   737k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|   737k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   737k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   737k|	int _ret = r; \
  |  |  |  |  155|   737k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 737k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   737k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 737k]
  |  |  |  |  ------------------
  |  |  |  |  157|   737k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   737k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|   737k|	return _ret; \
  |  |  |  |  163|   737k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  540|   737k|}
apdu.c:sc_single_transmit:
  359|   744k|{
  360|   744k|	struct sc_context *ctx  = card->ctx;
  361|   744k|	int rv;
  362|       |
  363|   744k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|   744k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   744k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   744k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   744k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 744k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  364|   744k|	if (card->reader->ops->transmit == NULL)
  ------------------
  |  Branch (364:6): [True: 0, False: 744k]
  ------------------
  365|   744k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  366|       |
  367|   744k|	sc_log(ctx,
  ------------------
  |  |   71|   744k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  368|   744k|	       "CLA:%X, INS:%X, P1:%X, P2:%X, data(%"SC_FORMAT_LEN_SIZE_T"u) %p",
  369|   744k|	       apdu->cla, apdu->ins, apdu->p1, apdu->p2, apdu->datalen,
  370|   744k|	       apdu->data);
  371|   744k|#ifdef ENABLE_SM
  372|   744k|	if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT
  ------------------
  |  |   47|  1.48M|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (372:6): [True: 736, False: 743k]
  ------------------
  373|    736|		   	&& (apdu->flags & SC_APDU_FLAGS_NO_SM) == 0) {
  ------------------
  |  |  314|    736|#define SC_APDU_FLAGS_NO_SM		0x00000008UL
  ------------------
  |  Branch (373:10): [True: 368, False: 368]
  ------------------
  374|    368|		LOG_FUNC_RETURN(ctx, sc_sm_single_transmit(card, apdu));
  ------------------
  |  |  164|    368|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    368|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    368|	int _ret = r; \
  |  |  |  |  155|    368|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 368, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    368|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    185|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 185, False: 183]
  |  |  |  |  ------------------
  |  |  |  |  157|    368|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    368|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    368|	return _ret; \
  |  |  |  |  163|    368|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  375|    368|	}
  376|   744k|#endif
  377|       |
  378|       |	/* send APDU to the reader driver */
  379|   744k|	rv = card->reader->ops->transmit(card->reader, apdu);
  380|   744k|	LOG_TEST_RET(ctx, rv, "unable to transmit APDU");
  ------------------
  |  |  174|   744k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   744k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   744k|	int _ret = (r); \
  |  |  |  |  168|   744k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 744k]
  |  |  |  |  ------------------
  |  |  |  |  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|   744k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 744k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  381|       |
  382|   744k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|   744k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   744k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   744k|	int _ret = r; \
  |  |  |  |  155|   744k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 744k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   744k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 744k]
  |  |  |  |  ------------------
  |  |  |  |  157|   744k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   744k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|   744k|	return _ret; \
  |  |  |  |  163|   744k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  383|   744k|}
apdu.c:sc_set_le_and_transmit:
  388|    909|{
  389|    909|	struct sc_context *ctx  = card->ctx;
  390|    909|	size_t nlen = apdu->sw2 ? (size_t)apdu->sw2 : 256;
  ------------------
  |  Branch (390:16): [True: 84, False: 825]
  ------------------
  391|    909|	int rv;
  392|       |
  393|    909|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    909|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    909|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    909|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    909|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 909]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  394|       |	/* we cannot re-transmit the APDU with the demanded Le value
  395|       |	 * as the buffer is too small => error */
  396|    909|	if (olen < nlen)
  ------------------
  |  Branch (396:6): [True: 604, False: 305]
  ------------------
  397|    909|		LOG_TEST_RET(ctx, SC_ERROR_WRONG_LENGTH, "wrong length: required length exceeds resplen");
  ------------------
  |  |  174|    604|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    604|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    604|	int _ret = (r); \
  |  |  |  |  168|    604|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 604, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    604|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    604|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    604|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    604|		return _ret; \
  |  |  |  |  172|    604|	} \
  |  |  |  |  173|    604|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|       |
  399|       |	/* don't try again if it doesn't work this time */
  400|    305|	apdu->flags  |= SC_APDU_FLAGS_NO_RETRY_WL;
  ------------------
  |  |  312|    305|#define SC_APDU_FLAGS_NO_RETRY_WL	0x00000004UL
  ------------------
  401|       |	/* set the new expected length */
  402|    305|	apdu->resplen = olen;
  403|    305|	apdu->le      = nlen;
  404|       |#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
  405|       |	/* Belpic V1 applets have a problem: if the card sends a 6C XX (only XX bytes available),
  406|       |	 * and we resend the command too soon (i.e. the reader is too fast), the card doesn't respond.
  407|       |	 * So we build in a delay. */
  408|       |	if (card->type == SC_CARD_TYPE_BELPIC_EID)
  409|       |		msleep(40);
  410|       |#endif
  411|       |
  412|       |	/* re-transmit the APDU with new Le length */
  413|    305|	rv = sc_single_transmit(card, apdu);
  414|    305|	LOG_TEST_RET(ctx, rv, "cannot re-transmit APDU");
  ------------------
  |  |  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: 0, False: 305]
  |  |  |  |  ------------------
  |  |  |  |  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|    305|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 305]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  415|       |
  416|    305|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 305]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  417|    305|}
apdu.c:sc_get_response:
  422|  24.9k|{
  423|  24.9k|	struct sc_context *ctx  = card->ctx;
  424|  24.9k|	size_t le, minlen, buflen;
  425|  24.9k|	unsigned char *buf;
  426|  24.9k|	int rv;
  427|       |
  428|  24.9k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  24.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  24.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  24.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  24.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 24.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  429|  24.9k|	if (apdu->le == 0) {
  ------------------
  |  Branch (429:6): [True: 4.63k, False: 20.3k]
  ------------------
  430|       |		/* no data is requested => change return value to 0x9000 and ignore the remaining data */
  431|  4.63k|		apdu->sw1 = 0x90;
  432|  4.63k|		apdu->sw2 = 0x00;
  433|  4.63k|		return SC_SUCCESS;
  ------------------
  |  |   28|  4.63k|#define SC_SUCCESS				0
  ------------------
  434|  4.63k|	}
  435|       |
  436|       |	/* this should _never_ happen */
  437|  20.3k|	if (!card->ops->get_response)
  ------------------
  |  Branch (437:6): [True: 5, False: 20.3k]
  ------------------
  438|  20.3k|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "no GET RESPONSE command");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  439|       |
  440|       |	/* call GET RESPONSE until we have read all data requested or until the card returns 0x9000,
  441|       |	 * whatever happens first. */
  442|       |
  443|       |	/* if there are already data in response append a new data to the end of the buffer */
  444|  20.3k|	buf = apdu->resp + apdu->resplen;
  445|       |
  446|       |	/* read as much data as fits in apdu->resp (i.e. min(apdu->resplen, amount of data available)). */
  447|  20.3k|	buflen = olen - apdu->resplen;
  448|       |
  449|       |	/* 0x6100 means at least 256 more bytes to read */
  450|  20.3k|	le = apdu->sw2 != 0 ? (size_t)apdu->sw2 : 256;
  ------------------
  |  Branch (450:7): [True: 11.4k, False: 8.92k]
  ------------------
  451|       |	/* we try to read at least as much as bytes as promised in the response bytes */
  452|  20.3k|	minlen = le;
  453|       |
  454|  28.1k|	do {
  455|  28.1k|		unsigned char resp[256];
  456|  28.1k|		size_t resp_len = le;
  457|       |
  458|       |		/* we have all the data the caller requested even if the card has more data */
  459|  28.1k|		if (buflen == 0)
  ------------------
  |  Branch (459:7): [True: 3.72k, False: 24.4k]
  ------------------
  460|  3.72k|			break;
  461|       |
  462|       |		/* call GET RESPONSE to get more date from the card;
  463|       |		 * note: GET RESPONSE returns the left amount of data (== SW2) */
  464|  24.4k|		memset(resp, 0, sizeof(resp));
  465|  24.4k|		rv = card->ops->get_response(card, &resp_len, resp);
  466|  24.4k|		if (rv < 0)   {
  ------------------
  |  Branch (466:7): [True: 5.51k, False: 18.9k]
  ------------------
  467|  5.51k|#ifdef ENABLE_SM
  468|  5.51k|			if (resp_len)   {
  ------------------
  |  Branch (468:8): [True: 3.97k, False: 1.54k]
  ------------------
  469|  3.97k|				sc_log_hex(ctx, "SM response data", resp, resp_len);
  ------------------
  |  |  129|  3.97k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  3.97k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|  3.97k|				sc_sm_update_apdu_response(card, resp, resp_len, rv, apdu);
  471|  3.97k|			}
  472|  5.51k|#endif
  473|  5.51k|			LOG_TEST_RET(ctx, rv, "GET RESPONSE error");
  ------------------
  |  |  174|  5.51k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  5.51k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  5.51k|	int _ret = (r); \
  |  |  |  |  168|  5.51k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5.51k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  5.51k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.51k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  5.51k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  5.51k|		return _ret; \
  |  |  |  |  172|  5.51k|	} \
  |  |  |  |  173|  5.51k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|  5.51k|		}
  475|       |
  476|  18.9k|		le = resp_len;
  477|       |		/* copy as much as will fit in requested buffer */
  478|  18.9k|		if (buflen < le)
  ------------------
  |  Branch (478:7): [True: 143, False: 18.7k]
  ------------------
  479|    143|			le = buflen;
  480|       |
  481|  18.9k|		memcpy(buf, resp, le);
  482|  18.9k|		buf    += le;
  483|  18.9k|		buflen -= le;
  484|       |
  485|  18.9k|		minlen -= le;
  486|  18.9k|		if (rv != 0)
  ------------------
  |  Branch (486:7): [True: 7.81k, False: 11.0k]
  ------------------
  487|  7.81k|			le = minlen = (size_t)rv;
  488|  11.0k|		else
  489|       |			/* if the card has returned 0x9000 but we still expect data ask for more
  490|       |			 * until we have read enough bytes */
  491|  11.0k|			le = minlen;
  492|  18.9k|	} while (rv != 0 && minlen != 0);
  ------------------
  |  Branch (492:11): [True: 7.81k, False: 11.0k]
  |  Branch (492:22): [True: 7.81k, False: 0]
  ------------------
  493|       |
  494|       |	/* we've read all data, let's return 0x9000 */
  495|  14.8k|	apdu->resplen = buf - apdu->resp;
  496|  14.8k|	apdu->sw1 = 0x90;
  497|  14.8k|	apdu->sw2 = 0x00;
  498|       |
  499|  14.8k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  14.8k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  14.8k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  14.8k|	int _ret = r; \
  |  |  |  |  155|  14.8k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 14.8k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  14.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: 14.8k]
  |  |  |  |  ------------------
  |  |  |  |  157|  14.8k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  14.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|  14.8k|	return _ret; \
  |  |  |  |  163|  14.8k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  500|  14.8k|}

sc_asn1_read_tag:
   64|   357k|{
   65|   357k|	const u8 *p = *buf;
   66|   357k|	size_t left = buflen, len;
   67|   357k|	unsigned int cla, tag, i;
   68|       |
   69|   357k|	*buf = NULL;
   70|       |
   71|   357k|	if (left == 0 || !p || buflen == 0)
  ------------------
  |  Branch (71:6): [True: 12.0k, False: 345k]
  |  Branch (71:19): [True: 0, False: 345k]
  |  Branch (71:25): [True: 0, False: 345k]
  ------------------
   72|  12.0k|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  12.0k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   73|   345k|	if (*p == 0xff || *p == 0) {
  ------------------
  |  Branch (73:6): [True: 3.20k, False: 342k]
  |  Branch (73:20): [True: 7.82k, False: 334k]
  ------------------
   74|       |		/* end of data reached */
   75|  11.0k|		*taglen = 0;
   76|  11.0k|		*tag_out = SC_ASN1_TAG_EOC;
  ------------------
  |  |  194|  11.0k|#define SC_ASN1_TAG_EOC			0
  ------------------
   77|  11.0k|		return SC_SUCCESS;
  ------------------
  |  |   28|  11.0k|#define SC_SUCCESS				0
  ------------------
   78|  11.0k|	}
   79|       |
   80|       |	/* parse tag byte(s)
   81|       |	 * Resulted tag is presented by integer that has not to be
   82|       |	 * confused with the 'tag number' part of ASN.1 tag.
   83|       |	 */
   84|   334k|	cla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);
  ------------------
  |  |  184|   334k|#define SC_ASN1_TAG_CLASS		0xC0
  ------------------
              	cla = (*p & SC_ASN1_TAG_CLASS) | (*p & SC_ASN1_TAG_CONSTRUCTED);
  ------------------
  |  |  190|   334k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
   85|   334k|	tag = *p & SC_ASN1_TAG_PRIMITIVE;
  ------------------
  |  |  191|   334k|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
   86|   334k|	if (left < 1)
  ------------------
  |  Branch (86:6): [True: 0, False: 334k]
  ------------------
   87|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   88|   334k|	p++;
   89|   334k|	left--;
   90|   334k|	if (tag == SC_ASN1_TAG_PRIMITIVE) {
  ------------------
  |  |  191|   334k|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
  |  Branch (90:6): [True: 4.03k, False: 330k]
  ------------------
   91|       |		/* high tag number */
   92|  4.03k|		size_t n = SC_ASN1_TAGNUM_SIZE - 1;
  ------------------
  |  |  145|  4.03k|#define SC_ASN1_TAGNUM_SIZE		3
  ------------------
   93|       |		/* search the last tag octet */
   94|  5.36k|		do {
   95|  5.36k|			if (left == 0 || n == 0)
  ------------------
  |  Branch (95:8): [True: 231, False: 5.13k]
  |  Branch (95:21): [True: 321, False: 4.81k]
  ------------------
   96|       |				/* either an invalid tag or it doesn't fit in
   97|       |				 * unsigned int */
   98|    552|				return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    552|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
   99|  4.81k|			tag <<= 8;
  100|  4.81k|			tag |= *p;
  101|  4.81k|			p++;
  102|  4.81k|			left--;
  103|  4.81k|			n--;
  104|  4.81k|		} while (tag & 0x80);
  ------------------
  |  Branch (104:12): [True: 1.33k, False: 3.48k]
  ------------------
  105|  4.03k|	}
  106|       |
  107|       |	/* parse length byte(s) */
  108|   334k|	if (left == 0)
  ------------------
  |  Branch (108:6): [True: 867, False: 333k]
  ------------------
  109|    867|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    867|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  110|   333k|	len = *p;
  111|   333k|	p++;
  112|   333k|	left--;
  113|   333k|	if (len & 0x80) {
  ------------------
  |  Branch (113:6): [True: 24.0k, False: 309k]
  ------------------
  114|  24.0k|		len &= 0x7f;
  115|  24.0k|		unsigned int a = 0;
  116|  24.0k|		if (len > sizeof a || len > left)
  ------------------
  |  Branch (116:7): [True: 8.90k, False: 15.1k]
  |  Branch (116:25): [True: 271, False: 14.9k]
  ------------------
  117|  9.17k|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  9.17k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  118|  21.0k|		for (i = 0; i < len; i++) {
  ------------------
  |  Branch (118:15): [True: 6.12k, False: 14.9k]
  ------------------
  119|  6.12k|			a <<= 8;
  120|  6.12k|			a |= *p;
  121|  6.12k|			p++;
  122|  6.12k|			left--;
  123|  6.12k|		}
  124|  14.9k|		len = a;
  125|  14.9k|	}
  126|       |
  127|   324k|	*cla_out = cla;
  128|   324k|	*tag_out = tag;
  129|   324k|	*taglen = len;
  130|   324k|	*buf = p;
  131|       |
  132|   324k|	if (len > left)
  ------------------
  |  Branch (132:6): [True: 20.5k, False: 303k]
  ------------------
  133|  20.5k|		return SC_ERROR_ASN1_END_OF_CONTENTS;
  ------------------
  |  |   84|  20.5k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  134|       |
  135|   303k|	return SC_SUCCESS;
  ------------------
  |  |   28|   303k|#define SC_SUCCESS				0
  ------------------
  136|   324k|}
sc_format_asn1_entry:
  140|   351k|{
  141|   351k|	entry->parm = parm;
  142|   351k|	entry->arg  = arg;
  143|   351k|	if (set_present)
  ------------------
  |  Branch (143:6): [True: 61.7k, False: 289k]
  ------------------
  144|  61.7k|		entry->flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|  61.7k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  145|   351k|}
sc_copy_asn1_entry:
  149|   107k|{
  150|   485k|	while (src->name != NULL) {
  ------------------
  |  Branch (150:9): [True: 378k, False: 107k]
  ------------------
  151|   378k|		*dest = *src;
  152|   378k|		dest++;
  153|   378k|		src++;
  154|   378k|	}
  155|       |	dest->name = NULL;
  156|   107k|}
sc_asn1_find_tag:
  486|  48.2k|{
  487|  48.2k|	size_t left = buflen, taglen;
  488|  48.2k|	const u8 *p = buf;
  489|       |
  490|  48.2k|	*taglen_in = 0;
  491|   118k|	while (left >= 2) {
  ------------------
  |  Branch (491:9): [True: 107k, False: 11.6k]
  ------------------
  492|   107k|		unsigned int cla = 0, tag, mask = 0xff00;
  493|       |
  494|   107k|		buf = p;
  495|       |		/* read a tag */
  496|   107k|		if (sc_asn1_read_tag(&p, left, &cla, &tag, &taglen) != SC_SUCCESS
  ------------------
  |  |   28|   214k|#define SC_SUCCESS				0
  ------------------
  |  Branch (496:7): [True: 9.08k, False: 98.0k]
  ------------------
  497|  98.0k|				|| p == NULL)
  ------------------
  |  Branch (497:8): [True: 3.51k, False: 94.5k]
  ------------------
  498|  12.5k|			return NULL;
  499|       |
  500|  94.5k|		left -= (p - buf);
  501|       |		/* we need to shift the class byte to the leftmost
  502|       |		 * byte of the tag */
  503|  94.7k|		while ((tag & mask) != 0) {
  ------------------
  |  Branch (503:10): [True: 186, False: 94.5k]
  ------------------
  504|    186|			cla  <<= 8;
  505|    186|			mask <<= 8;
  506|    186|		}
  507|       |		/* compare the read tag with the given tag */
  508|  94.5k|		if ((tag | cla) == tag_in) {
  ------------------
  |  Branch (508:7): [True: 23.9k, False: 70.5k]
  ------------------
  509|       |			/* we have a match => return length and value part */
  510|  23.9k|			if (taglen > left)
  ------------------
  |  Branch (510:8): [True: 0, False: 23.9k]
  ------------------
  511|      0|				return NULL;
  512|  23.9k|			*taglen_in = taglen;
  513|  23.9k|			return p;
  514|  23.9k|		}
  515|       |		/* otherwise continue reading tags */
  516|  70.5k|		left -= taglen;
  517|  70.5k|		p += taglen;
  518|  70.5k|	}
  519|  11.6k|	return NULL;
  520|  48.2k|}
sc_asn1_skip_tag:
  524|  93.4k|{
  525|  93.4k|	const u8 *p = *buf;
  526|  93.4k|	size_t len = *buflen, taglen;
  527|  93.4k|	unsigned int cla = 0, tag;
  528|       |
  529|  93.4k|	if (sc_asn1_read_tag((const u8 **) &p, len, &cla, &tag, &taglen) != SC_SUCCESS
  ------------------
  |  |   28|   186k|#define SC_SUCCESS				0
  ------------------
  |  Branch (529:6): [True: 22.0k, False: 71.3k]
  ------------------
  530|  71.3k|			|| p == NULL)
  ------------------
  |  Branch (530:7): [True: 2.86k, False: 68.5k]
  ------------------
  531|  24.9k|		return NULL;
  532|  68.5k|	switch (cla & 0xC0) {
  ------------------
  |  Branch (532:10): [True: 68.5k, False: 0]
  ------------------
  533|  31.8k|	case SC_ASN1_TAG_UNIVERSAL:
  ------------------
  |  |  185|  31.8k|#define SC_ASN1_TAG_UNIVERSAL		0x00
  ------------------
  |  Branch (533:2): [True: 31.8k, False: 36.6k]
  ------------------
  534|  31.8k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_UNI)
  ------------------
  |  |  136|  31.8k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_UNI)
  ------------------
  |  |  137|  31.8k|#define SC_ASN1_UNI			0x00000000 /* Universal */
  ------------------
  |  Branch (534:7): [True: 4.79k, False: 27.0k]
  ------------------
  535|  4.79k|			return NULL;
  536|  27.0k|		break;
  537|  27.0k|	case SC_ASN1_TAG_APPLICATION:
  ------------------
  |  |  186|  6.06k|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
  |  Branch (537:2): [True: 6.06k, False: 62.4k]
  ------------------
  538|  6.06k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_APP)
  ------------------
  |  |  136|  6.06k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_APP)
  ------------------
  |  |  138|  6.06k|#define SC_ASN1_APP			0x40000000 /* Application */
  ------------------
  |  Branch (538:7): [True: 4.91k, False: 1.14k]
  ------------------
  539|  4.91k|			return NULL;
  540|  1.14k|		break;
  541|  28.9k|	case SC_ASN1_TAG_CONTEXT:
  ------------------
  |  |  187|  28.9k|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
  |  Branch (541:2): [True: 28.9k, False: 39.5k]
  ------------------
  542|  28.9k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_CTX)
  ------------------
  |  |  136|  28.9k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_CTX)
  ------------------
  |  |  139|  28.9k|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
  |  Branch (542:7): [True: 1.66k, False: 27.3k]
  ------------------
  543|  1.66k|			return NULL;
  544|  27.3k|		break;
  545|  27.3k|	case SC_ASN1_TAG_PRIVATE:
  ------------------
  |  |  188|  1.59k|#define SC_ASN1_TAG_PRIVATE		0xC0
  ------------------
  |  Branch (545:2): [True: 1.59k, False: 66.9k]
  ------------------
  546|  1.59k|		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_PRV)
  ------------------
  |  |  136|  1.59k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
              		if ((tag_in & SC_ASN1_CLASS_MASK) != SC_ASN1_PRV)
  ------------------
  |  |  140|  1.59k|#define SC_ASN1_PRV			0xC0000000 /* Private */
  ------------------
  |  Branch (546:7): [True: 1.59k, False: 0]
  ------------------
  547|  1.59k|			return NULL;
  548|      0|		break;
  549|  68.5k|	}
  550|  55.5k|	if (cla & SC_ASN1_TAG_CONSTRUCTED) {
  ------------------
  |  |  190|  55.5k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  |  Branch (550:6): [True: 35.0k, False: 20.4k]
  ------------------
  551|  35.0k|		if ((tag_in & SC_ASN1_CONS) == 0)
  ------------------
  |  |  141|  35.0k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (551:7): [True: 1.34k, False: 33.7k]
  ------------------
  552|  1.34k|			return NULL;
  553|  35.0k|	} else
  554|  20.4k|		if (tag_in & SC_ASN1_CONS)
  ------------------
  |  |  141|  20.4k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (554:7): [True: 1.56k, False: 18.9k]
  ------------------
  555|  1.56k|			return NULL;
  556|  52.6k|	if ((tag_in & SC_ASN1_TAG_MASK) != tag)
  ------------------
  |  |  144|  52.6k|#define SC_ASN1_TAG_MASK		0x00FFFFFF
  ------------------
  |  Branch (556:6): [True: 22.0k, False: 30.5k]
  ------------------
  557|  22.0k|		return NULL;
  558|  30.5k|	len -= (p - *buf);	/* header size */
  559|  30.5k|	if (taglen > len) {
  ------------------
  |  Branch (559:6): [True: 0, False: 30.5k]
  ------------------
  560|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  561|      0|			 "too long ASN.1 object (size %"SC_FORMAT_LEN_SIZE_T"u while only %"SC_FORMAT_LEN_SIZE_T"u available)\n",
  562|      0|			 taglen, len);
  563|      0|		return NULL;
  564|      0|	}
  565|  30.5k|	*buflen -= (p - *buf) + taglen;
  566|  30.5k|	*buf = p + taglen;	/* point to next tag */
  567|  30.5k|	*taglen_out = taglen;
  568|  30.5k|	return p;
  569|  30.5k|}
sc_asn1_verify_tag:
  573|      6|{
  574|      6|	return sc_asn1_skip_tag(ctx, &buf, &buflen, tag_in, taglen_out);
  575|      6|}
sc_asn1_decode_integer:
  734|  2.61k|{
  735|  2.61k|	int    a = 0, is_negative = 0;
  736|  2.61k|	size_t i = 0;
  737|       |
  738|  2.61k|	if (inlen == 0) {
  ------------------
  |  Branch (738:6): [True: 4, False: 2.61k]
  ------------------
  739|      4|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      4|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  740|      4|	}
  741|  2.61k|	if (inlen > sizeof(int)) {
  ------------------
  |  Branch (741:6): [True: 2, False: 2.60k]
  ------------------
  742|      2|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      2|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  743|      2|	}
  744|  2.60k|	if (inbuf[0] & 0x80) {
  ------------------
  |  Branch (744:6): [True: 816, False: 1.79k]
  ------------------
  745|    816|		if (strict && inlen > 1 && inbuf[0] == 0xff && (inbuf[1] & 0x80)) {
  ------------------
  |  Branch (745:7): [True: 0, False: 816]
  |  Branch (745:17): [True: 0, False: 0]
  |  Branch (745:30): [True: 0, False: 0]
  |  Branch (745:50): [True: 0, False: 0]
  ------------------
  746|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  747|      0|		}
  748|    816|		is_negative = 1;
  749|    816|		a |= 0xff^(*inbuf++);
  750|    816|		i = 1;
  751|  1.79k|	} else {
  752|  1.79k|		if (strict && inlen > 1 && inbuf[0] == 0x00 && (inbuf[1] & 0x80) == 0) {
  ------------------
  |  Branch (752:7): [True: 0, False: 1.79k]
  |  Branch (752:17): [True: 0, False: 0]
  |  Branch (752:30): [True: 0, False: 0]
  |  Branch (752:50): [True: 0, False: 0]
  ------------------
  753|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  754|      0|		}
  755|  1.79k|	}
  756|  5.51k|	for (; i < inlen; i++) {
  ------------------
  |  Branch (756:9): [True: 2.90k, False: 2.60k]
  ------------------
  757|  2.90k|		if (a > (INT_MAX >> 8) || a < (INT_MIN + (1<<8))) {
  ------------------
  |  Branch (757:7): [True: 0, False: 2.90k]
  |  Branch (757:29): [True: 0, False: 2.90k]
  ------------------
  758|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  759|      0|		}
  760|  2.90k|		a <<= 8;
  761|  2.90k|		if (is_negative) {
  ------------------
  |  Branch (761:7): [True: 453, False: 2.44k]
  ------------------
  762|    453|			a |= 0xff^(*inbuf++);
  763|  2.44k|		} else {
  764|  2.44k|			a |= *inbuf++;
  765|  2.44k|		}
  766|  2.90k|	}
  767|  2.60k|	if (is_negative) {
  ------------------
  |  Branch (767:6): [True: 816, False: 1.79k]
  ------------------
  768|       |		/* Calculate Two's complement from previously positive number */
  769|    816|		a = (-1 * a) - 1;
  770|    816|	}
  771|  2.60k|	*out = a;
  772|  2.60k|	return 0;
  773|  2.60k|}
sc_asn1_decode_object_id:
  834|  6.32k|{
  835|  6.32k|	int large_second_octet = 0;
  836|  6.32k|	unsigned int a = 0;
  837|  6.32k|	const u8 *p = inbuf;
  838|  6.32k|	int *octet;
  839|       |
  840|  6.32k|	if (inlen == 0 || inbuf == NULL || id == NULL)
  ------------------
  |  Branch (840:6): [True: 501, False: 5.82k]
  |  Branch (840:20): [True: 3, False: 5.81k]
  |  Branch (840:37): [True: 0, False: 5.81k]
  ------------------
  841|    504|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    504|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  842|       |
  843|  5.81k|	sc_init_oid(id);
  844|  5.81k|	octet = id->value;
  845|       |
  846|       |	/* The first octet can be 0, 1 or 2 and is derived from the first byte */
  847|  5.81k|	a = MIN(*p / 40, 2);
  ------------------
  |  |   70|  5.81k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 3.96k, False: 1.85k]
  |  |  ------------------
  ------------------
  848|  5.81k|	*octet++ = a;
  849|       |
  850|       |	/* The second octet fits here if the previous was 0 or 1 and second one is smaller than 40.
  851|       |	 * for the value 2 we can go up to 47. Otherwise the first bit needs to be set
  852|       |	 * and we continue reading further */
  853|  5.81k|	if ((*p & 0x80) == 0) {
  ------------------
  |  Branch (853:6): [True: 4.12k, False: 1.69k]
  ------------------
  854|  4.12k|		*octet++ = *p - (a * 40);
  855|  4.12k|		inlen--;
  856|  4.12k|	} else {
  857|  1.69k|		large_second_octet = 1;
  858|  1.69k|	}
  859|       |
  860|  22.0k|	while (inlen) {
  ------------------
  |  Branch (860:9): [True: 18.2k, False: 3.72k]
  ------------------
  861|  18.2k|		if (!large_second_octet)
  ------------------
  |  Branch (861:7): [True: 16.5k, False: 1.69k]
  ------------------
  862|  16.5k|			p++;
  863|       |		/* This signalizes empty most significant bits, which means
  864|       |		 * the unsigned integer encoding is not minimal */
  865|  18.2k|		if (*p == 0x80) {
  ------------------
  |  Branch (865:7): [True: 579, False: 17.7k]
  ------------------
  866|    579|			sc_init_oid(id);
  867|    579|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    579|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  868|    579|		}
  869|       |		/* Use unsigned type here so we can process the whole INT range.
  870|       |		 * Values can not be negative */
  871|  17.7k|		a = *p & 0x7F;
  872|  17.7k|		inlen--;
  873|  24.1k|		while (inlen && *p & 0x80) {
  ------------------
  |  Branch (873:10): [True: 19.8k, False: 4.28k]
  |  Branch (873:19): [True: 6.82k, False: 13.0k]
  ------------------
  874|       |			/* Limit the OID values to int size and do not overflow */
  875|  6.82k|			if (a > (UINT_MAX>>7)) {
  ------------------
  |  Branch (875:8): [True: 361, False: 6.46k]
  ------------------
  876|    361|				sc_init_oid(id);
  877|    361|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    361|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  878|    361|			}
  879|  6.46k|			p++;
  880|  6.46k|			a <<= 7;
  881|  6.46k|			a |= *p & 0x7F;
  882|  6.46k|			inlen--;
  883|  6.46k|		}
  884|  17.3k|		if (*p & 0x80) {
  ------------------
  |  Branch (884:7): [True: 594, False: 16.7k]
  ------------------
  885|       |			/* We dropped out from previous cycle on the end of
  886|       |			 * data while still expecting continuation of value */
  887|    594|			sc_init_oid(id);
  888|    594|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    594|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  889|    594|		}
  890|  16.7k|		if (large_second_octet) {
  ------------------
  |  Branch (890:7): [True: 618, False: 16.1k]
  ------------------
  891|    618|			a -= (2 * 40);
  892|    618|		}
  893|  16.7k|		if (a > INT_MAX) {
  ------------------
  |  Branch (893:7): [True: 296, False: 16.4k]
  ------------------
  894|    296|			sc_init_oid(id);
  895|    296|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    296|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  896|    296|		}
  897|  16.4k|		*octet++ = a;
  898|  16.4k|		if (octet - id->value >= SC_MAX_OBJECT_ID_OCTETS)   {
  ------------------
  |  |   46|  16.4k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (898:7): [True: 268, False: 16.1k]
  ------------------
  899|    268|			sc_init_oid(id);
  900|    268|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    268|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  901|    268|		}
  902|  16.1k|		large_second_octet = 0;
  903|  16.1k|	}
  904|       |
  905|  3.72k|	return 0;
  906|  5.81k|}
sc_asn1_encode_object_id:
  910|  8.50k|{
  911|  8.50k|	u8 temp[SC_MAX_OBJECT_ID_OCTETS*5], *p = temp;
  912|  8.50k|	int	i;
  913|       |
  914|  8.50k|	if (!buflen || !id)
  ------------------
  |  Branch (914:6): [True: 0, False: 8.50k]
  |  Branch (914:17): [True: 0, False: 8.50k]
  ------------------
  915|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  916|       |
  917|       |	/* an OID must have at least two components */
  918|  8.50k|	if (id->value[0] == -1 || id->value[1] == -1)
  ------------------
  |  Branch (918:6): [True: 0, False: 8.50k]
  |  Branch (918:28): [True: 0, False: 8.50k]
  ------------------
  919|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  920|       |
  921|  66.2k|	for (i = 0; i < SC_MAX_OBJECT_ID_OCTETS; i++) {
  ------------------
  |  |   46|  66.2k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (921:14): [True: 66.1k, False: 100]
  ------------------
  922|  66.1k|		unsigned int k, shift;
  923|       |
  924|  66.1k|		if (id->value[i] == -1)
  ------------------
  |  Branch (924:7): [True: 8.39k, False: 57.7k]
  ------------------
  925|  8.39k|			break;
  926|       |
  927|  57.7k|		k = id->value[i];
  928|  57.7k|		switch (i) {
  929|  8.50k|		case 0:
  ------------------
  |  Branch (929:3): [True: 8.50k, False: 49.2k]
  ------------------
  930|  8.50k|			if (k > 2)
  ------------------
  |  Branch (930:8): [True: 10, False: 8.49k]
  ------------------
  931|     10|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     10|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  932|  8.49k|			*p = k * 40;
  933|  8.49k|			break;
  934|  8.49k|		case 1:
  ------------------
  |  Branch (934:3): [True: 8.49k, False: 49.2k]
  ------------------
  935|  8.49k|			if (k > 39 && id->value[0] < 2) {
  ------------------
  |  Branch (935:8): [True: 21, False: 8.47k]
  |  Branch (935:18): [True: 0, False: 21]
  ------------------
  936|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  937|      0|			}
  938|       |			/* We can encode larger IDs to multiple bytes
  939|       |			 * similarly as the following IDs */
  940|  8.49k|			k += *p;
  941|       |			/* fall through */
  942|  49.2k|		default:
  ------------------
  |  Branch (942:3): [True: 40.7k, False: 17.0k]
  ------------------
  943|  49.2k|			shift = 28;
  944|   235k|			while (shift && (k >> shift) == 0)
  ------------------
  |  Branch (944:11): [True: 196k, False: 38.3k]
  |  Branch (944:20): [True: 185k, False: 10.8k]
  ------------------
  945|   185k|				shift -= 7;
  946|  60.1k|			while (shift) {
  ------------------
  |  Branch (946:11): [True: 10.9k, False: 49.2k]
  ------------------
  947|  10.9k|				*p++ = 0x80 | ((k >> shift) & 0x7f);
  948|  10.9k|				shift -= 7;
  949|  10.9k|			}
  950|  49.2k|			*p++ = k & 0x7F;
  951|  49.2k|			break;
  952|  57.7k|		}
  953|  57.7k|	}
  954|       |
  955|  8.49k|	*buflen = p - temp;
  956|       |
  957|  8.49k|	if (buf)   {
  ------------------
  |  Branch (957:6): [True: 8.49k, False: 0]
  ------------------
  958|  8.49k|		*buf = malloc(*buflen);
  959|  8.49k|		if (!*buf)
  ------------------
  |  Branch (959:7): [True: 0, False: 8.49k]
  ------------------
  960|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  961|  8.49k|		memcpy(*buf, temp, *buflen);
  962|  8.49k|	}
  963|  8.49k|	return 0;
  964|  8.49k|}
sc_asn1_put_tag:
  981|  1.10k|{
  982|  1.10k|	size_t c = 0;
  983|  1.10k|	unsigned int tag_len, ii;
  984|  1.10k|	u8 *p = out;
  985|  1.10k|	u8 tag_char[4] = {0, 0, 0, 0};
  986|       |
  987|       |	/* Check tag */
  988|  1.10k|	if (tag == 0 || tag > 0xFFFFFFFF) {
  ------------------
  |  Branch (988:6): [True: 0, False: 1.10k]
  |  Branch (988:18): [True: 0, False: 1.10k]
  ------------------
  989|       |		/* A tag of 0x00 is not valid and at most 4-byte tag names are supported. */
  990|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  991|      0|	}
  992|  2.21k|	for (tag_len = 0; tag; tag >>= 8) {
  ------------------
  |  Branch (992:20): [True: 1.10k, False: 1.10k]
  ------------------
  993|       |		/* Note: tag char will be reversed order. */
  994|  1.10k|		tag_char[tag_len++] = tag & 0xFF;
  995|  1.10k|	}
  996|       |
  997|  1.10k|	if (tag_len > 1)   {
  ------------------
  |  Branch (997:6): [True: 0, False: 1.10k]
  ------------------
  998|      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 (998:7): [True: 0, False: 0]
  ------------------
  999|       |			/* First byte is not escape marker. */
 1000|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1001|      0|		}
 1002|      0|		for (ii = 1; ii < tag_len - 1; ii++) {
  ------------------
  |  Branch (1002:16): [True: 0, False: 0]
  ------------------
 1003|      0|			if ((tag_char[ii] & 0x80) != 0x80) {
  ------------------
  |  Branch (1003:8): [True: 0, False: 0]
  ------------------
 1004|       |				/* MS bit is not 'one'. */
 1005|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1006|      0|			}
 1007|      0|		}
 1008|      0|		if ((tag_char[0] & 0x80) != 0x00) {
  ------------------
  |  Branch (1008:7): [True: 0, False: 0]
  ------------------
 1009|       |			/* MS bit of the last byte is not 'zero'. */
 1010|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1011|      0|		}
 1012|      0|	}
 1013|       |
 1014|       |	/* Calculate the number of additional bytes necessary to encode the length. */
 1015|       |	/* c+1 is the size of the length field. */
 1016|  1.10k|	if (datalen > 127) {
  ------------------
  |  Branch (1016:6): [True: 0, False: 1.10k]
  ------------------
 1017|      0|		c = 1;
 1018|      0|		while (datalen >> (c << 3))
  ------------------
  |  Branch (1018:10): [True: 0, False: 0]
  ------------------
 1019|      0|			c++;
 1020|      0|	}
 1021|  1.10k|	if (outlen == 0 || out == NULL) {
  ------------------
  |  Branch (1021:6): [True: 0, False: 1.10k]
  |  Branch (1021:21): [True: 0, False: 1.10k]
  ------------------
 1022|       |		/* Caller only asks for the length that would be written. */
 1023|      0|		return (int)(tag_len + (c + 1) + datalen);
 1024|      0|	}
 1025|       |	/* We will write the tag, so check the length. */
 1026|  1.10k|	if (outlen < tag_len + (c+1) + datalen)
  ------------------
  |  Branch (1026:6): [True: 0, False: 1.10k]
  ------------------
 1027|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 1028|  2.21k|	for (ii=0;ii<tag_len;ii++)
  ------------------
  |  Branch (1028:12): [True: 1.10k, False: 1.10k]
  ------------------
 1029|  1.10k|		*p++ = tag_char[tag_len - ii - 1];
 1030|       |
 1031|  1.10k|	if (c > 0) {
  ------------------
  |  Branch (1031:6): [True: 0, False: 1.10k]
  ------------------
 1032|      0|		*p++ = 0x80 | c;
 1033|      0|		while (c--)
  ------------------
  |  Branch (1033:10): [True: 0, False: 0]
  ------------------
 1034|      0|			*p++ = (datalen >> (c << 3)) & 0xFF;
 1035|      0|	}
 1036|  1.10k|	else {
 1037|  1.10k|		*p++ = datalen & 0x7F;
 1038|  1.10k|	}
 1039|  1.10k|	if(data && datalen > 0) {
  ------------------
  |  Branch (1039:5): [True: 1.10k, False: 0]
  |  Branch (1039:13): [True: 1.10k, False: 0]
  ------------------
 1040|  1.10k|		memcpy(p, data, datalen);
 1041|  1.10k|		p += datalen;
 1042|  1.10k|	}
 1043|  1.10k|	if (ptr != NULL)
  ------------------
  |  Branch (1043:6): [True: 1.10k, False: 0]
  ------------------
 1044|  1.10k|		*ptr = p;
 1045|  1.10k|	return 0;
 1046|  1.10k|}
sc_asn1_decode:
 1816|  9.52k|{
 1817|  9.52k|	return asn1_decode(ctx, asn1, in, len, newp, len_left, 0, 0);
 1818|  9.52k|}
sc_asn1_decode_choice:
 1822|  6.38k|{
 1823|  6.38k|	return asn1_decode(ctx, asn1, in, len, newp, len_left, 1, 0);
 1824|  6.38k|}
sc_asn1_encode:
 2088|  4.23k|{
 2089|  4.23k|	return asn1_encode(ctx, asn1, ptr, size, 0);
 2090|  4.23k|}
_sc_asn1_encode:
 2094|  7.41k|{
 2095|  7.41k|	return asn1_encode(ctx, asn1, ptr, size, depth);
 2096|  7.41k|}
sc_der_copy:
 2108|  2.21k|{
 2109|  2.21k|	if (!dst || !src)
  ------------------
  |  Branch (2109:6): [True: 0, False: 2.21k]
  |  Branch (2109:14): [True: 0, False: 2.21k]
  ------------------
 2110|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2111|  2.21k|	memset(dst, 0, sizeof(*dst));
 2112|  2.21k|	if (src->len) {
  ------------------
  |  Branch (2112:6): [True: 2.21k, False: 0]
  ------------------
 2113|  2.21k|		if (!src->value)
  ------------------
  |  Branch (2113:7): [True: 0, False: 2.21k]
  ------------------
 2114|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2115|  2.21k|		dst->value = malloc(src->len);
 2116|  2.21k|		if (!dst->value)
  ------------------
  |  Branch (2116:7): [True: 0, False: 2.21k]
  ------------------
 2117|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2118|  2.21k|		dst->len = src->len;
 2119|  2.21k|		memcpy(dst->value, src->value, src->len);
 2120|  2.21k|	}
 2121|  2.21k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.21k|#define SC_SUCCESS				0
  ------------------
 2122|  2.21k|}
sc_encode_oid:
 2127|  7.38k|{
 2128|  7.38k|	static const struct sc_asn1_entry c_asn1_object_id[2] = {
 2129|  7.38k|		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  159|  7.38k|#define SC_ASN1_OBJECT                  6
  ------------------
              		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  200|  7.38k|#define SC_ASN1_TAG_OBJECT		6
  ------------------
              		{ "oid", SC_ASN1_OBJECT, SC_ASN1_TAG_OBJECT, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|  7.38k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
 2130|  7.38k|		{ NULL, 0, 0, 0, NULL, NULL }
 2131|  7.38k|	};
 2132|  7.38k|	struct sc_asn1_entry asn1_object_id[2];
 2133|  7.38k|	int rv;
 2134|       |
 2135|  7.38k|	sc_copy_asn1_entry(c_asn1_object_id, asn1_object_id);
 2136|  7.38k|	sc_format_asn1_entry(asn1_object_id + 0, id, NULL, 1);
 2137|       |
 2138|  7.38k|	rv = _sc_asn1_encode(ctx, asn1_object_id, out, size, 1);
 2139|  7.38k|	LOG_TEST_RET(ctx, rv, "Cannot encode object ID");
  ------------------
  |  |  174|  7.38k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  7.38k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  7.38k|	int _ret = (r); \
  |  |  |  |  168|  7.38k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 7.38k]
  |  |  |  |  ------------------
  |  |  |  |  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.38k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7.38k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2140|       |
 2141|  7.38k|	return SC_SUCCESS;
  ------------------
  |  |   28|  7.38k|#define SC_SUCCESS				0
  ------------------
 2142|  7.38k|}
asn1.c:decode_bit_string:
  579|  2.18k|{
  580|  2.18k|	const u8 *in = inbuf;
  581|  2.18k|	u8 *out = (u8 *) outbuf;
  582|  2.18k|	int i, count = 0;
  583|  2.18k|	int zero_bits;
  584|  2.18k|	size_t octets_left;
  585|       |
  586|  2.18k|	if (inlen < 1)
  ------------------
  |  Branch (586:6): [True: 10, False: 2.17k]
  ------------------
  587|     10|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     10|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  588|       |
  589|       |	/* The formatting is only enforced by SHALL keyword so we should accept
  590|       |	 * by default also non-strict values. */
  591|  2.17k|	if (strict) {
  ------------------
  |  Branch (591:6): [True: 0, False: 2.17k]
  ------------------
  592|       |		/* 8.6.2.3 If the bitstring is empty, there shall be no
  593|       |		 * subsequent octets,and the initial octet shall be zero. */
  594|      0|		if (inlen == 1 && *in != 0)
  ------------------
  |  Branch (594:7): [True: 0, False: 0]
  |  Branch (594:21): [True: 0, False: 0]
  ------------------
  595|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  596|       |		/* ITU-T Rec. X.690 8.6.2.2: The number shall be in the range zero to seven. */
  597|      0|		if ((*in & ~0x07) != 0)
  ------------------
  |  Branch (597:7): [True: 0, False: 0]
  ------------------
  598|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  599|      0|	}
  600|       |
  601|  2.17k|	memset(outbuf, 0, outlen);
  602|  2.17k|	zero_bits = *in & 0x07;
  603|  2.17k|	in++;
  604|  2.17k|	octets_left = inlen - 1;
  605|  2.17k|	if (outlen < octets_left)
  ------------------
  |  Branch (605:6): [True: 12, False: 2.16k]
  ------------------
  606|     12|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|     12|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  607|       |
  608|  5.05k|	while (octets_left) {
  ------------------
  |  Branch (608:9): [True: 2.90k, False: 2.14k]
  ------------------
  609|       |		/* 1st octet of input:  ABCDEFGH, where A is the MSB */
  610|       |		/* 1st octet of output: HGFEDCBA, where A is the LSB */
  611|       |		/* first bit in bit string is the LSB in first resulting octet */
  612|  2.90k|		int bits_to_go;
  613|       |
  614|  2.90k|		*out = 0;
  615|  2.90k|		if (octets_left == 1 && zero_bits > 0) {
  ------------------
  |  Branch (615:7): [True: 2.14k, False: 762]
  |  Branch (615:27): [True: 1.86k, False: 284]
  ------------------
  616|  1.86k|			bits_to_go = 8 - zero_bits;
  617|       |			/* Verify the padding is zero bits */
  618|  1.86k|			if (*in & (1 << (zero_bits-1))) {
  ------------------
  |  Branch (618:8): [True: 21, False: 1.84k]
  ------------------
  619|     21|				return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     21|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  620|     21|			}
  621|  1.86k|		} else
  622|  1.04k|			bits_to_go = 8;
  623|  2.88k|		if (invert)
  ------------------
  |  Branch (623:7): [True: 2.88k, False: 0]
  ------------------
  624|  18.9k|			for (i = 0; i < bits_to_go; i++) {
  ------------------
  |  Branch (624:16): [True: 16.0k, False: 2.88k]
  ------------------
  625|  16.0k|				*out |= ((*in >> (7 - i)) & 1) << i;
  626|  16.0k|			}
  627|      0|		else {
  628|      0|			*out = *in;
  629|      0|		}
  630|  2.88k|		out++;
  631|  2.88k|		in++;
  632|  2.88k|		octets_left--;
  633|  2.88k|		count++;
  634|  2.88k|	}
  635|  2.14k|	return (count * 8) - zero_bits;
  636|  2.16k|}
asn1.c:asn1_write_element:
 1056|  38.9k|{
 1057|  38.9k|	unsigned char t;
 1058|  38.9k|	unsigned char *buf, *p;
 1059|  38.9k|	int c = 0;
 1060|  38.9k|	unsigned short_tag;
 1061|  38.9k|	unsigned char tag_char[3] = {0, 0, 0};
 1062|  38.9k|	size_t tag_len, ii;
 1063|       |
 1064|  38.9k|	short_tag = tag & SC_ASN1_TAG_MASK;
  ------------------
  |  |  144|  38.9k|#define SC_ASN1_TAG_MASK		0x00FFFFFF
  ------------------
 1065|  77.4k|	for (tag_len = 0; short_tag >> (8 * tag_len); tag_len++)
  ------------------
  |  Branch (1065:20): [True: 38.5k, False: 38.9k]
  ------------------
 1066|  38.5k|		tag_char[tag_len] = (short_tag >> (8 * tag_len)) & 0xFF;
 1067|  38.9k|	if (!tag_len)
  ------------------
  |  Branch (1067:6): [True: 1.68k, False: 37.2k]
  ------------------
 1068|  1.68k|		tag_len = 1;
 1069|       |
 1070|  38.9k|	if (tag_len > 1)   {
  ------------------
  |  Branch (1070:6): [True: 1.29k, False: 37.6k]
  ------------------
 1071|  1.29k|		if ((tag_char[tag_len - 1] & SC_ASN1_TAG_PRIMITIVE) != SC_ASN1_TAG_ESCAPE_MARKER)
  ------------------
  |  |  191|  1.29k|#define SC_ASN1_TAG_PRIMITIVE		0x1F
  ------------------
              		if ((tag_char[tag_len - 1] & SC_ASN1_TAG_PRIMITIVE) != SC_ASN1_TAG_ESCAPE_MARKER)
  ------------------
  |  |  222|  1.29k|#define SC_ASN1_TAG_ESCAPE_MARKER	31
  ------------------
  |  Branch (1071:7): [True: 0, False: 1.29k]
  ------------------
 1072|      0|			SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "First byte of the long tag is not 'escape marker'");
  ------------------
  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1073|       |
 1074|  1.29k|		for (ii = 1; ii < tag_len - 1; ii++)
  ------------------
  |  Branch (1074:16): [True: 0, False: 1.29k]
  ------------------
 1075|      0|			if (!(tag_char[ii] & 0x80))
  ------------------
  |  Branch (1075:8): [True: 0, False: 0]
  ------------------
 1076|      0|				SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "MS bit expected to be 'one'");
  ------------------
  |  |  166|  1.29k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1077|       |
 1078|  1.29k|		if (tag_char[0] & 0x80)
  ------------------
  |  Branch (1078:7): [True: 0, False: 1.29k]
  ------------------
 1079|      0|			SC_TEST_RET(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_INVALID_DATA, "MS bit of the last byte expected to be 'zero'");
  ------------------
  |  |  166|      0|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  167|      0|	int _ret = (r); \
  |  |  168|      0|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (168:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  169|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  170|      0|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  171|      0|		return _ret; \
  |  |  172|      0|	} \
  |  |  173|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1080|  1.29k|	}
 1081|       |
 1082|  38.9k|	t = tag_char[tag_len - 1] & 0x1F;
 1083|       |
 1084|  38.9k|	switch (tag & SC_ASN1_CLASS_MASK) {
  ------------------
  |  |  136|  38.9k|#define SC_ASN1_CLASS_MASK		0xC0000000
  ------------------
  |  Branch (1084:10): [True: 38.9k, False: 0]
  ------------------
 1085|  29.4k|	case SC_ASN1_UNI:
  ------------------
  |  |  137|  29.4k|#define SC_ASN1_UNI			0x00000000 /* Universal */
  ------------------
  |  Branch (1085:2): [True: 29.4k, False: 9.47k]
  ------------------
 1086|  29.4k|		break;
 1087|  3.35k|	case SC_ASN1_APP:
  ------------------
  |  |  138|  3.35k|#define SC_ASN1_APP			0x40000000 /* Application */
  ------------------
  |  Branch (1087:2): [True: 3.35k, False: 35.5k]
  ------------------
 1088|  3.35k|		t |= SC_ASN1_TAG_APPLICATION;
  ------------------
  |  |  186|  3.35k|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
 1089|  3.35k|		break;
 1090|  6.12k|	case SC_ASN1_CTX:
  ------------------
  |  |  139|  6.12k|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
  |  Branch (1090:2): [True: 6.12k, False: 32.8k]
  ------------------
 1091|  6.12k|		t |= SC_ASN1_TAG_CONTEXT;
  ------------------
  |  |  187|  6.12k|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
 1092|  6.12k|		break;
 1093|      0|	case SC_ASN1_PRV:
  ------------------
  |  |  140|      0|#define SC_ASN1_PRV			0xC0000000 /* Private */
  ------------------
  |  Branch (1093:2): [True: 0, False: 38.9k]
  ------------------
 1094|      0|		t |= SC_ASN1_TAG_PRIVATE;
  ------------------
  |  |  188|      0|#define SC_ASN1_TAG_PRIVATE		0xC0
  ------------------
 1095|      0|		break;
 1096|  38.9k|	}
 1097|  38.9k|	if (tag & SC_ASN1_CONS)
  ------------------
  |  |  141|  38.9k|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (1097:6): [True: 12.1k, False: 26.7k]
  ------------------
 1098|  12.1k|		t |= SC_ASN1_TAG_CONSTRUCTED;
  ------------------
  |  |  190|  12.1k|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
 1099|  38.9k|	if (datalen > 127) {
  ------------------
  |  Branch (1099:6): [True: 1.00k, False: 37.9k]
  ------------------
 1100|  1.00k|		c = 1;
 1101|  1.26k|		while (datalen >> (c << 3))
  ------------------
  |  Branch (1101:10): [True: 261, False: 1.00k]
  ------------------
 1102|    261|			c++;
 1103|  1.00k|	}
 1104|       |
 1105|  38.9k|	*outlen = tag_len + 1 + c + datalen;
 1106|  38.9k|	buf = malloc(*outlen);
 1107|  38.9k|	if (buf == NULL)
  ------------------
  |  Branch (1107:6): [True: 0, False: 38.9k]
  ------------------
 1108|      0|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1109|       |
 1110|  38.9k|	*out = p = buf;
 1111|  38.9k|	*p++ = t;
 1112|  40.2k|	for (ii=1;ii<tag_len;ii++)
  ------------------
  |  Branch (1112:12): [True: 1.29k, False: 38.9k]
  ------------------
 1113|  1.29k|		*p++ = tag_char[tag_len - ii - 1];
 1114|       |
 1115|  38.9k|	if (c) {
  ------------------
  |  Branch (1115:6): [True: 1.00k, False: 37.9k]
  ------------------
 1116|  1.00k|		*p++ = 0x80 | c;
 1117|  2.27k|		while (c--)
  ------------------
  |  Branch (1117:10): [True: 1.26k, False: 1.00k]
  ------------------
 1118|  1.26k|			*p++ = (datalen >> (c << 3)) & 0xFF;
 1119|  1.00k|	}
 1120|  37.9k|	else   {
 1121|  37.9k|		*p++ = datalen & 0x7F;
 1122|  37.9k|	}
 1123|  38.9k|	if (datalen && data) {
  ------------------
  |  Branch (1123:6): [True: 38.0k, False: 885]
  |  Branch (1123:17): [True: 38.0k, False: 0]
  ------------------
 1124|  38.0k|		memcpy(p, data, datalen);
 1125|  38.0k|	}
 1126|       |
 1127|  38.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  38.9k|#define SC_SUCCESS				0
  ------------------
 1128|  38.9k|}
asn1.c:asn1_decode:
 1724|  31.8k|{
 1725|  31.8k|	int r, idx = 0;
 1726|  31.8k|	const u8 *p = in, *obj;
 1727|  31.8k|	struct sc_asn1_entry *entry = asn1;
 1728|  31.8k|	size_t left = len, objlen;
 1729|       |
 1730|  31.8k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|  63.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: 7.35k, False: 24.4k]
  |  |  ------------------
  ------------------
 1731|  31.8k|		 "%*.*s""called, left=%"SC_FORMAT_LEN_SIZE_T"u, depth %d%s\n",
 1732|  31.8k|		 depth, depth, "", left, depth, choice ? ", choice" : "");
 1733|       |
 1734|  31.8k|	if (!p)
  ------------------
  |  Branch (1734:6): [True: 0, False: 31.8k]
  ------------------
 1735|      0|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|      0|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1736|  31.8k|	if (left < 2) {
  ------------------
  |  Branch (1736:6): [True: 1.79k, False: 30.0k]
  ------------------
 1737|  5.17k|		while (asn1->name && (asn1->flags & SC_ASN1_OPTIONAL))
  ------------------
  |  |  148|  3.69k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1737:10): [True: 3.69k, False: 1.47k]
  |  Branch (1737:24): [True: 3.38k, False: 317]
  ------------------
 1738|  3.38k|			asn1++;
 1739|       |		/* If all elements were optional, there's nothing
 1740|       |		 * to complain about */
 1741|  1.79k|		if (asn1->name == NULL)
  ------------------
  |  Branch (1741:7): [True: 1.47k, False: 317]
  ------------------
 1742|  1.47k|			return 0;
 1743|    317|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "End of ASN.1 stream, "
  ------------------
  |  |   70|    317|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1744|    317|			      "non-optional field \"%s\" not found\n",
 1745|    317|			      asn1->name);
 1746|    317|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|    317|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1747|  1.79k|	}
 1748|  30.0k|	if (p[0] == 0 || p[0] == 0xFF || len == 0)
  ------------------
  |  Branch (1748:6): [True: 1.86k, False: 28.1k]
  |  Branch (1748:19): [True: 233, False: 27.9k]
  |  Branch (1748:35): [True: 0, False: 27.9k]
  ------------------
 1749|  2.09k|		return SC_ERROR_ASN1_END_OF_CONTENTS;
  ------------------
  |  |   84|  2.09k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
 1750|       |
 1751|   112k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (1751:16): [True: 94.4k, False: 17.8k]
  ------------------
 1752|  94.4k|		entry = &asn1[idx];
 1753|       |
 1754|  94.4k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "Looking for '%s', tag 0x%x%s%s\n",
  ------------------
  |  |   70|  94.4k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               #define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  | 1755|  94.4k|			entry->name, entry->tag, choice? ", CHOICE" : "",
  |  |  |  | 1756|  94.4k|			(entry->flags & SC_ASN1_OPTIONAL)? ", OPTIONAL": "");
  |  |  |  |  ------------------
  |  |  |  |  |  |  148|  94.4k|#define SC_ASN1_OPTIONAL		0x00000002
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1755|  94.4k|			entry->name, entry->tag, choice? ", CHOICE" : "",
 1756|  94.4k|			(entry->flags & SC_ASN1_OPTIONAL)? ", OPTIONAL": "");
 1757|       |
 1758|       |		/* Special case CHOICE has no tag */
 1759|  94.4k|		if (entry->type == SC_ASN1_CHOICE) {
  ------------------
  |  |  170|  94.4k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1759:7): [True: 968, False: 93.4k]
  ------------------
 1760|    968|			r = asn1_decode(ctx,
 1761|    968|				(struct sc_asn1_entry *) entry->parm,
 1762|    968|				p, left, &p, &left, 1, depth + 1);
 1763|       |			/* When the inner call fails it returns before writing
 1764|       |			 * back to *newp and *len_left, so the caller's p/left are
 1765|       |			 * unchanged.  Swallowing the error for an optional
 1766|       |			 * CHOICE is therefore safe: the next field will be
 1767|       |			 * attempted at the same position. */
 1768|    968|			if (r >= 0 || (entry->flags & SC_ASN1_OPTIONAL))
  ------------------
  |  |  148|    349|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1768:8): [True: 619, False: 349]
  |  Branch (1768:18): [True: 11, False: 338]
  ------------------
 1769|    630|				r = 0;
 1770|    968|			goto decode_ok;
 1771|    968|		}
 1772|       |
 1773|  93.4k|		obj = sc_asn1_skip_tag(ctx, &p, &left, entry->tag, &objlen);
 1774|  93.4k|		if (obj == NULL) {
  ------------------
  |  Branch (1774:7): [True: 62.8k, False: 30.5k]
  ------------------
 1775|  62.8k|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "'%s' not present\n", entry->name);
  ------------------
  |  |   70|  62.8k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1776|  62.8k|			if (choice)
  ------------------
  |  Branch (1776:8): [True: 16.8k, False: 46.0k]
  ------------------
 1777|  16.8k|				continue;
 1778|  46.0k|			if (entry->flags & SC_ASN1_OPTIONAL)
  ------------------
  |  |  148|  46.0k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  |  Branch (1778:8): [True: 42.7k, False: 3.29k]
  ------------------
 1779|  42.7k|				continue;
 1780|  3.29k|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "mandatory ASN.1 object '%s' not found\n", entry->name);
  ------------------
  |  |   70|  3.29k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1781|  3.29k|			if (left) {
  ------------------
  |  Branch (1781:8): [True: 3.20k, False: 99]
  ------------------
 1782|  3.20k|				u8 line[128], *linep = line;
 1783|  3.20k|				size_t i;
 1784|       |
 1785|  3.20k|				line[0] = 0;
 1786|  29.1k|				for (i = 0; i < 10 && i < left; i++) {
  ------------------
  |  Branch (1786:17): [True: 28.3k, False: 805]
  |  Branch (1786:27): [True: 25.9k, False: 2.39k]
  ------------------
 1787|  25.9k|					sprintf((char *) linep, "%02X ", p[i]);
 1788|  25.9k|					linep += 3;
 1789|  25.9k|				}
 1790|  3.20k|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "next tag: %s\n", line);
  ------------------
  |  |   70|  3.20k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1791|  3.20k|			}
 1792|  3.29k|			sc_free_entry(asn1);
 1793|  3.29k|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  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|  3.29k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 3.29k, False: 0]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1794|  3.29k|		}
 1795|  30.5k|		r = asn1_decode_entry(ctx, entry, obj, objlen, depth);
 1796|       |
 1797|  31.5k|decode_ok:
 1798|  31.5k|		if (r)
  ------------------
  |  Branch (1798:7): [True: 1.24k, False: 30.2k]
  ------------------
 1799|  1.24k|			return r;
 1800|  30.2k|		if (choice)
  ------------------
  |  Branch (1800:7): [True: 5.58k, False: 24.7k]
  ------------------
 1801|  5.58k|			break;
 1802|  30.2k| 	}
 1803|  23.3k| 	if (choice && asn1[idx].name == NULL) /* No match */
  ------------------
  |  Branch (1803:7): [True: 5.89k, False: 17.5k]
  |  Branch (1803:17): [True: 315, False: 5.58k]
  ------------------
 1804|    315|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_ERROR_ASN1_OBJECT_NOT_FOUND);
  ------------------
  |  |  153|    315|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    315|	int _ret = r; \
  |  |  155|    315|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 315, False: 0]
  |  |  ------------------
  |  |  156|    315|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    315|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 315, False: 0]
  |  |  ------------------
  |  |  157|    315|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    315|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    315|	return _ret; \
  |  |  163|    315|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1805|  23.0k| 	if (newp != NULL)
  ------------------
  |  Branch (1805:7): [True: 5.90k, False: 17.1k]
  ------------------
 1806|  5.90k|		*newp = p;
 1807|  23.0k| 	if (len_left != NULL)
  ------------------
  |  Branch (1807:7): [True: 5.90k, False: 17.1k]
  ------------------
 1808|  5.90k|		*len_left = left;
 1809|  23.0k|	if (choice)
  ------------------
  |  Branch (1809:6): [True: 5.58k, False: 17.5k]
  ------------------
 1810|  5.58k|		SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, idx);
  ------------------
  |  |  153|  5.58k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  5.58k|	int _ret = r; \
  |  |  155|  5.58k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1.93k, False: 3.65k]
  |  |  ------------------
  |  |  156|  1.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 1.93k]
  |  |  ------------------
  |  |  157|  1.93k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  3.65k|	} else { \
  |  |  159|  3.65k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|  3.65k|			"returning with: %d\n", _ret); \
  |  |  161|  3.65k|	} \
  |  |  162|  5.58k|	return _ret; \
  |  |  163|  5.58k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1811|  17.5k|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, 0);
  ------------------
  |  |  153|  17.5k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  17.5k|	int _ret = r; \
  |  |  155|  17.5k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 17.5k, False: 0]
  |  |  ------------------
  |  |  156|  17.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 17.5k]
  |  |  ------------------
  |  |  157|  17.5k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  17.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|  17.5k|	return _ret; \
  |  |  163|  17.5k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1812|  17.5k|}
asn1.c:sc_free_entry:
 1689|  6.45k|static void sc_free_entry(struct sc_asn1_entry *asn1) {
 1690|  6.45k|	int idx = 0;
 1691|  6.45k|	struct sc_asn1_entry *entry = asn1;
 1692|       |
 1693|  6.45k|	if (!asn1)
  ------------------
  |  Branch (1693:6): [True: 107, False: 6.34k]
  ------------------
 1694|    107|		return;
 1695|       |
 1696|  26.4k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (1696:16): [True: 20.1k, False: 6.34k]
  ------------------
 1697|  20.1k|		entry = &asn1[idx];
 1698|  20.1k|		switch (entry->type) {
 1699|    396|		case SC_ASN1_CHOICE:
  ------------------
  |  |  170|    396|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1699:3): [True: 396, False: 19.7k]
  ------------------
 1700|  3.15k|		case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  3.15k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1700:3): [True: 2.75k, False: 17.3k]
  ------------------
 1701|  3.15k|			sc_free_entry((struct sc_asn1_entry *) entry->parm);
 1702|  3.15k|			break;
 1703|  9.36k|		case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  9.36k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1703:3): [True: 9.36k, False: 10.7k]
  ------------------
 1704|  9.36k|		case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|  9.36k|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1704:3): [True: 0, False: 20.1k]
  ------------------
 1705|  9.36k|		case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|  9.36k|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1705:3): [True: 1, False: 20.1k]
  ------------------
 1706|  9.43k|		case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|  9.43k|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1706:3): [True: 66, False: 20.0k]
  ------------------
 1707|  9.48k|		case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|  9.48k|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1707:3): [True: 53, False: 20.0k]
  ------------------
 1708|  9.91k|		case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|  9.91k|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1708:3): [True: 430, False: 19.6k]
  ------------------
 1709|  9.91k|			if ((entry->flags & SC_ASN1_ALLOC) && (entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  149|  9.91k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
              			if ((entry->flags & SC_ASN1_ALLOC) && (entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|    254|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1709:8): [True: 254, False: 9.66k]
  |  Branch (1709:42): [True: 3, False: 251]
  ------------------
 1710|      3|				u8 **buf = (u8 **)entry->parm;
 1711|      3|				free(*buf);
 1712|      3|				*buf = NULL;
 1713|      3|			}
 1714|  9.91k|			break;
 1715|  7.05k|		default:
  ------------------
  |  Branch (1715:3): [True: 7.05k, False: 13.0k]
  ------------------
 1716|  7.05k|			break;
 1717|  20.1k|		}
 1718|  20.1k|	}
 1719|  6.34k|}
asn1.c:asn1_decode_entry:
 1491|  30.5k|{
 1492|  30.5k|	void *parm = entry->parm;
 1493|  30.5k|	int (*callback_func)(sc_context_t *nctx, void *arg, const u8 *nobj,
 1494|  30.5k|			     size_t nobjlen, int ndepth);
 1495|  30.5k|	size_t *len = (size_t *) entry->arg;
 1496|  30.5k|	int r = 0;
 1497|       |
 1498|  30.5k|	callback_func = parm;
 1499|       |
 1500|  30.5k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sdecoding '%s', raw data:%s%s\n",
  ------------------
  |  |   70|   122k|#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: 4.31k, False: 26.2k]
  |  |  |  Branch (70:115): [True: 4.31k, False: 26.2k]
  |  |  ------------------
  ------------------
 1501|  30.5k|		depth, depth, "", entry->name,
 1502|  30.5k|		sc_dump_hex(obj, objlen > 16  ? 16 : objlen),
 1503|  30.5k|		objlen > 16 ? "..." : "");
 1504|       |
 1505|  30.5k|	switch (entry->type) {
 1506|  9.00k|	case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  9.00k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1506:2): [True: 9.00k, False: 21.5k]
  ------------------
 1507|  9.00k|		if (parm != NULL)
  ------------------
  |  Branch (1507:7): [True: 9.00k, False: 1]
  ------------------
 1508|  9.00k|			r = asn1_decode(ctx, (struct sc_asn1_entry *) parm, obj,
 1509|  9.00k|				       objlen, NULL, NULL, 0, depth + 1);
 1510|  9.00k|		break;
 1511|    353|	case SC_ASN1_NULL:
  ------------------
  |  |  158|    353|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1511:2): [True: 353, False: 30.2k]
  ------------------
 1512|    353|		break;
 1513|     26|	case SC_ASN1_BOOLEAN:
  ------------------
  |  |  153|     26|#define SC_ASN1_BOOLEAN                 1
  ------------------
  |  Branch (1513:2): [True: 26, False: 30.5k]
  ------------------
 1514|     26|		if (parm != NULL) {
  ------------------
  |  Branch (1514:7): [True: 26, False: 0]
  ------------------
 1515|     26|			if (objlen != 1) {
  ------------------
  |  Branch (1515:8): [True: 6, False: 20]
  ------------------
 1516|      6|				sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|      6|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1517|      6|					 "invalid ASN.1 object length: %"SC_FORMAT_LEN_SIZE_T"u\n",
 1518|      6|					 objlen);
 1519|      6|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      6|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1520|      6|			} else
 1521|     20|				*((int *) parm) = obj[0] ? 1 : 0;
  ------------------
  |  Branch (1521:23): [True: 20, False: 0]
  ------------------
 1522|     26|		}
 1523|     26|		break;
 1524|  2.51k|	case SC_ASN1_INTEGER:
  ------------------
  |  |  154|  2.51k|#define SC_ASN1_INTEGER                 2
  ------------------
  |  Branch (1524:2): [True: 2.51k, False: 28.0k]
  ------------------
 1525|  2.61k|	case SC_ASN1_ENUMERATED:
  ------------------
  |  |  160|  2.61k|#define SC_ASN1_ENUMERATED              10
  ------------------
  |  Branch (1525:2): [True: 100, False: 30.4k]
  ------------------
 1526|  2.61k|		if (parm != NULL) {
  ------------------
  |  Branch (1526:7): [True: 2.61k, False: 1]
  ------------------
 1527|  2.61k|			r = sc_asn1_decode_integer(obj, objlen, (int *) entry->parm, 0);
 1528|  2.61k|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  2.61k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1528:8): [True: 2.60k, False: 6]
  ------------------
 1529|  2.60k|				sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sdecoding '%s' returned %d\n",
  ------------------
  |  |   70|  2.60k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1530|  2.60k|						depth, depth, "", entry->name, *((int *)entry->parm));
 1531|  2.60k|			}
 1532|  2.61k|		}
 1533|  2.61k|		break;
 1534|      0|	case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|      0|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1534:2): [True: 0, False: 30.5k]
  ------------------
 1535|      0|	case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|      0|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1535:2): [True: 0, False: 30.5k]
  ------------------
 1536|      0|		if (parm != NULL) {
  ------------------
  |  Branch (1536:7): [True: 0, False: 0]
  ------------------
 1537|      0|			int invert = entry->type == SC_ASN1_BIT_STRING ? 1 : 0;
  ------------------
  |  |  155|      0|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1537:17): [True: 0, False: 0]
  ------------------
 1538|      0|			if (len == NULL)
  ------------------
  |  Branch (1538:8): [True: 0, False: 0]
  ------------------
 1539|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1540|      0|			if (objlen < 1) {
  ------------------
  |  Branch (1540:8): [True: 0, False: 0]
  ------------------
 1541|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1542|      0|				break;
 1543|      0|			}
 1544|      0|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|      0|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1544:8): [True: 0, False: 0]
  ------------------
 1545|      0|				u8 **buf = (u8 **) parm;
 1546|      0|				if (objlen > 1) {
  ------------------
  |  Branch (1546:9): [True: 0, False: 0]
  ------------------
 1547|      0|					*buf = malloc(objlen-1);
 1548|      0|					if (*buf == NULL) {
  ------------------
  |  Branch (1548:10): [True: 0, False: 0]
  ------------------
 1549|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1550|      0|						break;
 1551|      0|					}
 1552|      0|				}
 1553|      0|				*len = objlen-1;
 1554|      0|				parm = *buf;
 1555|      0|			}
 1556|      0|			r = decode_bit_string(obj, objlen, (u8 *) parm, *len, invert, 0);
 1557|      0|			if (r >= 0) {
  ------------------
  |  Branch (1557:8): [True: 0, False: 0]
  ------------------
 1558|      0|				*len = r;
 1559|      0|				r = 0;
 1560|      0|			}
 1561|      0|		}
 1562|      0|		break;
 1563|  2.18k|	case SC_ASN1_BIT_FIELD:
  ------------------
  |  |  171|  2.18k|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
  |  Branch (1563:2): [True: 2.18k, False: 28.3k]
  ------------------
 1564|  2.18k|		if (parm != NULL)
  ------------------
  |  Branch (1564:7): [True: 2.18k, False: 0]
  ------------------
 1565|  2.18k|			r = decode_bit_field(obj, objlen, (u8 *) parm, *len, 0);
 1566|  2.18k|		break;
 1567|  7.35k|	case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  7.35k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1567:2): [True: 7.35k, False: 23.2k]
  ------------------
 1568|  7.35k|		if (parm != NULL) {
  ------------------
  |  Branch (1568:7): [True: 7.35k, False: 0]
  ------------------
 1569|  7.35k|			size_t c;
 1570|  7.35k|			if (len == NULL)
  ------------------
  |  Branch (1570:8): [True: 0, False: 7.35k]
  ------------------
 1571|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1572|       |
 1573|       |			/* Strip off padding zero */
 1574|  7.35k|			if ((entry->flags & SC_ASN1_UNSIGNED)
  ------------------
  |  |  150|  7.35k|#define SC_ASN1_UNSIGNED		0x00000008
  ------------------
  |  Branch (1574:8): [True: 182, False: 7.17k]
  ------------------
 1575|    182|					&& objlen > 1 && obj[0] == 0x00) {
  ------------------
  |  Branch (1575:9): [True: 148, False: 34]
  |  Branch (1575:23): [True: 117, False: 31]
  ------------------
 1576|    117|				objlen--;
 1577|    117|				obj++;
 1578|    117|			}
 1579|       |
 1580|       |			/* Allocate buffer if needed */
 1581|  7.35k|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|  7.35k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1581:8): [True: 192, False: 7.16k]
  ------------------
 1582|    192|				u8 **buf = (u8 **) parm;
 1583|    192|				if (objlen > 0) {
  ------------------
  |  Branch (1583:9): [True: 158, False: 34]
  ------------------
 1584|    158|					*buf = malloc(objlen);
 1585|    158|					if (*buf == NULL) {
  ------------------
  |  Branch (1585:10): [True: 0, False: 158]
  ------------------
 1586|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1587|      0|						break;
 1588|      0|					}
 1589|    158|				}
 1590|    192|				c = *len = objlen;
 1591|    192|				parm = *buf;
 1592|    192|			} else
 1593|  7.16k|				c = objlen > *len ? *len : objlen;
  ------------------
  |  Branch (1593:9): [True: 10, False: 7.15k]
  ------------------
 1594|       |
 1595|  7.35k|			memcpy(parm, obj, c);
 1596|  7.35k|			*len = c;
 1597|  7.35k|		}
 1598|  7.35k|		break;
 1599|  7.35k|	case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|     28|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1599:2): [True: 28, False: 30.5k]
  ------------------
 1600|     28|		if (parm != NULL) {
  ------------------
  |  Branch (1600:7): [True: 27, False: 1]
  ------------------
 1601|     27|			size_t c;
 1602|     27|			if (len == NULL)
  ------------------
  |  Branch (1602:8): [True: 0, False: 27]
  ------------------
 1603|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1604|     27|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|     27|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1604:8): [True: 0, False: 27]
  ------------------
 1605|      0|				u8 **buf = (u8 **) parm;
 1606|      0|				if (objlen > 0) {
  ------------------
  |  Branch (1606:9): [True: 0, False: 0]
  ------------------
 1607|      0|					*buf = malloc(objlen);
 1608|      0|					if (*buf == NULL) {
  ------------------
  |  Branch (1608:10): [True: 0, False: 0]
  ------------------
 1609|      0|						r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1610|      0|						break;
 1611|      0|					}
 1612|      0|				}
 1613|      0|				c = *len = objlen;
 1614|      0|				parm = *buf;
 1615|      0|			} else
 1616|     27|				c = objlen > *len ? *len : objlen;
  ------------------
  |  Branch (1616:9): [True: 1, False: 26]
  ------------------
 1617|       |
 1618|     27|			memcpy(parm, obj, c);
 1619|     27|			*len = c;
 1620|     27|		}
 1621|     28|		break;
 1622|    154|	case SC_ASN1_OBJECT:
  ------------------
  |  |  159|    154|#define SC_ASN1_OBJECT                  6
  ------------------
  |  Branch (1622:2): [True: 154, False: 30.4k]
  ------------------
 1623|    154|		if (parm != NULL)
  ------------------
  |  Branch (1623:7): [True: 154, False: 0]
  ------------------
 1624|    154|			r = sc_asn1_decode_object_id(obj, objlen, (struct sc_object_id *) parm);
 1625|    154|		break;
 1626|      3|	case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|      3|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1626:2): [True: 3, False: 30.5k]
  ------------------
 1627|  2.39k|	case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|  2.39k|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1627:2): [True: 2.38k, False: 28.1k]
  ------------------
 1628|  2.39k|		if (parm != NULL) {
  ------------------
  |  Branch (1628:7): [True: 2.37k, False: 13]
  ------------------
 1629|  2.37k|			if (len == NULL)
  ------------------
  |  Branch (1629:8): [True: 0, False: 2.37k]
  ------------------
 1630|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1631|  2.37k|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|  2.37k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1631:8): [True: 0, False: 2.37k]
  ------------------
 1632|      0|				u8 **buf = (u8 **) parm;
 1633|      0|				*buf = malloc(objlen+1);
 1634|      0|				if (*buf == NULL) {
  ------------------
  |  Branch (1634:9): [True: 0, False: 0]
  ------------------
 1635|      0|					r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1636|      0|					break;
 1637|      0|				}
 1638|      0|				*len = objlen+1;
 1639|      0|				parm = *buf;
 1640|      0|			}
 1641|  2.37k|			r = sc_asn1_decode_utf8string(obj, objlen, (u8 *) parm, len);
 1642|  2.37k|			if (entry->flags & SC_ASN1_ALLOC) {
  ------------------
  |  |  149|  2.37k|#define SC_ASN1_ALLOC			0x00000004
  ------------------
  |  Branch (1642:8): [True: 0, False: 2.37k]
  ------------------
 1643|      0|				*len -= 1;
 1644|      0|			}
 1645|  2.37k|		}
 1646|  2.39k|		break;
 1647|  5.33k|	case SC_ASN1_PATH:
  ------------------
  |  |  174|  5.33k|#define SC_ASN1_PATH			256
  ------------------
  |  Branch (1647:2): [True: 5.33k, False: 25.2k]
  ------------------
 1648|  5.33k|		if (entry->parm != NULL)
  ------------------
  |  Branch (1648:7): [True: 5.28k, False: 49]
  ------------------
 1649|  5.28k|			r = asn1_decode_path(ctx, obj, objlen, (sc_path_t *) parm, depth);
 1650|  5.33k|		break;
 1651|    498|	case SC_ASN1_PKCS15_ID:
  ------------------
  |  |  175|    498|#define SC_ASN1_PKCS15_ID		257
  ------------------
  |  Branch (1651:2): [True: 498, False: 30.0k]
  ------------------
 1652|    498|		if (entry->parm != NULL) {
  ------------------
  |  Branch (1652:7): [True: 498, False: 0]
  ------------------
 1653|    498|			struct sc_pkcs15_id *id = (struct sc_pkcs15_id *) parm;
 1654|    498|			size_t c = objlen > sizeof(id->value) ? sizeof(id->value) : objlen;
  ------------------
  |  Branch (1654:15): [True: 0, False: 498]
  ------------------
 1655|       |
 1656|    498|			memcpy(id->value, obj, c);
 1657|    498|			id->len = c;
 1658|    498|		}
 1659|    498|		break;
 1660|    609|	case SC_ASN1_PKCS15_OBJECT:
  ------------------
  |  |  176|    609|#define SC_ASN1_PKCS15_OBJECT		258
  ------------------
  |  Branch (1660:2): [True: 609, False: 29.9k]
  ------------------
 1661|    609|		if (entry->parm != NULL)
  ------------------
  |  Branch (1661:7): [True: 594, False: 15]
  ------------------
 1662|    594|			r = asn1_decode_p15_object(ctx, obj, objlen, (struct sc_asn1_pkcs15_object *) parm, depth);
 1663|    609|		break;
 1664|      0|	case SC_ASN1_ALGORITHM_ID:
  ------------------
  |  |  177|      0|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
  |  Branch (1664:2): [True: 0, False: 30.5k]
  ------------------
 1665|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1665:7): [True: 0, False: 0]
  ------------------
 1666|      0|			r = sc_asn1_decode_algorithm_id(ctx, obj, objlen, (struct sc_algorithm_id *) parm, depth);
 1667|      0|		break;
 1668|     22|	case SC_ASN1_SE_INFO:
  ------------------
  |  |  178|     22|#define SC_ASN1_SE_INFO			260
  ------------------
  |  Branch (1668:2): [True: 22, False: 30.5k]
  ------------------
 1669|     22|		if (entry->parm != NULL)
  ------------------
  |  Branch (1669:7): [True: 22, False: 0]
  ------------------
 1670|     22|			r = asn1_decode_se_info(ctx, obj, objlen, (sc_pkcs15_sec_env_info_t ***)entry->parm, len, depth);
 1671|     22|		break;
 1672|      0|	case SC_ASN1_CALLBACK:
  ------------------
  |  |  181|      0|#define SC_ASN1_CALLBACK		384
  ------------------
  |  Branch (1672:2): [True: 0, False: 30.5k]
  ------------------
 1673|      0|		if (entry->parm != NULL)
  ------------------
  |  Branch (1673:7): [True: 0, False: 0]
  ------------------
 1674|      0|			r = callback_func(ctx, entry->arg, obj, objlen, depth);
 1675|      0|		break;
 1676|      0|	default:
  ------------------
  |  Branch (1676:2): [True: 0, False: 30.5k]
  ------------------
 1677|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 type: %d\n", entry->type);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1678|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1679|  30.5k|	}
 1680|  30.5k|	if (r) {
  ------------------
  |  Branch (1680:6): [True: 911, False: 29.6k]
  ------------------
 1681|    911|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "decoding of ASN.1 object '%s' failed: %s\n", entry->name,
  ------------------
  |  |   70|    911|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1682|    911|		      sc_strerror(r));
 1683|    911|		return r;
 1684|    911|	}
 1685|  29.6k|	entry->flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|  29.6k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
 1686|  29.6k|	return 0;
 1687|  30.5k|}
asn1.c:decode_bit_field:
  692|  2.18k|{
  693|  2.18k|	u8		data[sizeof(unsigned int)];
  694|  2.18k|	unsigned int	field = 0;
  695|  2.18k|	int		i, n;
  696|       |
  697|  2.18k|	if (outlen != sizeof(data))
  ------------------
  |  Branch (697:6): [True: 0, False: 2.18k]
  ------------------
  698|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  699|       |
  700|  2.18k|	n = decode_bit_string(inbuf, inlen, data, sizeof(data), 1, strict);
  701|  2.18k|	if (n < 0)
  ------------------
  |  Branch (701:6): [True: 60, False: 2.12k]
  ------------------
  702|     60|		return n;
  703|       |
  704|  4.97k|	for (i = 0; i < n; i += 8) {
  ------------------
  |  Branch (704:14): [True: 2.84k, False: 2.12k]
  ------------------
  705|  2.84k|		field |= ((unsigned int) data[i/8] << i);
  706|  2.84k|	}
  707|  2.12k|	memcpy(outbuf, &field, outlen);
  708|  2.12k|	return 0;
  709|  2.18k|}
asn1.c:sc_asn1_decode_utf8string:
  968|  2.37k|{
  969|  2.37k|	if (inlen+1 > *outlen)
  ------------------
  |  Branch (969:6): [True: 0, False: 2.37k]
  ------------------
  970|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  971|  2.37k|	*outlen = inlen+1;
  972|  2.37k|	memcpy(out, inbuf, inlen);
  973|  2.37k|	out[inlen] = 0;
  974|  2.37k|	return 0;
  975|  2.37k|}
asn1.c:asn1_decode_path:
 1150|  5.28k|{
 1151|  5.28k|	int idx, count, r;
 1152|  5.28k|	struct sc_asn1_entry asn1_path_ext[3], asn1_path[5];
 1153|  5.28k|	unsigned char path_value[SC_MAX_PATH_SIZE], aid_value[SC_MAX_AID_SIZE];
 1154|  5.28k|	size_t path_len = sizeof(path_value), aid_len = sizeof(aid_value);
 1155|       |
 1156|  5.28k|	memset(path, 0, sizeof(struct sc_path));
 1157|       |
 1158|  5.28k|	sc_copy_asn1_entry(c_asn1_path_ext, asn1_path_ext);
 1159|  5.28k|	sc_copy_asn1_entry(c_asn1_path, asn1_path);
 1160|       |
 1161|  5.28k|	sc_format_asn1_entry(asn1_path_ext + 0, aid_value, &aid_len, 0);
 1162|  5.28k|	sc_format_asn1_entry(asn1_path_ext + 1, path_value, &path_len, 0);
 1163|       |
 1164|  5.28k|	sc_format_asn1_entry(asn1_path + 0, path_value, &path_len, 0);
 1165|  5.28k|	sc_format_asn1_entry(asn1_path + 1, &idx, NULL, 0);
 1166|  5.28k|	sc_format_asn1_entry(asn1_path + 2, &count, NULL, 0);
 1167|  5.28k|	sc_format_asn1_entry(asn1_path + 3, asn1_path_ext, NULL, 0);
 1168|       |
 1169|  5.28k|	r = asn1_decode(ctx, asn1_path, in, len, NULL, NULL, 0, depth + 1);
 1170|  5.28k|	if (r)
  ------------------
  |  Branch (1170:6): [True: 87, False: 5.19k]
  ------------------
 1171|     87|		return r;
 1172|       |
 1173|  5.19k|	if (asn1_path[3].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|  5.19k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1173:6): [True: 0, False: 5.19k]
  ------------------
 1174|       |		/* extended path present: set 'path' and 'aid' */
 1175|      0|		memcpy(path->aid.value, aid_value, aid_len);
 1176|      0|		path->aid.len = aid_len;
 1177|       |
 1178|      0|		memcpy(path->value, path_value, path_len);
 1179|      0|		path->len = path_len;
 1180|      0|	}
 1181|  5.19k|	else if (asn1_path[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|  5.19k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1181:11): [True: 5.17k, False: 25]
  ------------------
 1182|       |		/* path present: set 'path' */
 1183|  5.17k|		memcpy(path->value, path_value, path_len);
 1184|  5.17k|		path->len = path_len;
 1185|  5.17k|	}
 1186|     25|	else   {
 1187|       |		/* failed if both 'path' and 'pathExtended' are absent */
 1188|     25|		return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|     25|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 1189|     25|	}
 1190|       |
 1191|  5.17k|	if (path->len == 2)
  ------------------
  |  Branch (1191:6): [True: 459, False: 4.71k]
  ------------------
 1192|    459|		path->type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    459|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1193|  4.71k|	else   if (path->aid.len && path->len > 2)
  ------------------
  |  Branch (1193:13): [True: 0, False: 4.71k]
  |  Branch (1193:30): [True: 0, False: 0]
  ------------------
 1194|      0|		path->type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
 1195|  4.71k|	else
 1196|  4.71k|		path->type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  4.71k|#define SC_PATH_TYPE_PATH		2
  ------------------
 1197|       |
 1198|  5.17k|	if ((asn1_path[1].flags & SC_ASN1_PRESENT) && (asn1_path[2].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|  5.17k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
              	if ((asn1_path[1].flags & SC_ASN1_PRESENT) && (asn1_path[2].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1198:6): [True: 0, False: 5.17k]
  |  Branch (1198:48): [True: 0, False: 0]
  ------------------
 1199|      0|		path->index = idx;
 1200|      0|		path->count = count;
 1201|      0|	}
 1202|  5.17k|	else {
 1203|  5.17k|		path->index = 0;
 1204|  5.17k|		path->count = -1;
 1205|  5.17k|	}
 1206|       |
 1207|  5.17k|	return SC_SUCCESS;
  ------------------
  |  |   28|  5.17k|#define SC_SUCCESS				0
  ------------------
 1208|  5.19k|}
asn1.c:asn1_decode_p15_object:
 1396|    594|{
 1397|    594|	struct sc_pkcs15_object *p15_obj = obj->p15_obj;
 1398|    594|	struct sc_asn1_entry asn1_c_attr[6], asn1_p15_obj[5];
 1399|    594|	struct sc_asn1_entry asn1_ac_rules[SC_PKCS15_MAX_ACCESS_RULES + 1], asn1_ac_rule[SC_PKCS15_MAX_ACCESS_RULES][3];
 1400|    594|	size_t flags_len = sizeof(p15_obj->flags);
 1401|    594|	size_t label_len = sizeof(p15_obj->label);
 1402|    594|	size_t access_mode_len = sizeof(p15_obj->access_rules[0].access_mode);
 1403|    594|	int r, ii;
 1404|       |
 1405|  5.34k|	for (ii=0; ii<SC_PKCS15_MAX_ACCESS_RULES; ii++)
  ------------------
  |  |   42|  5.34k|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1405:13): [True: 4.75k, False: 594]
  ------------------
 1406|  4.75k|		sc_copy_asn1_entry(c_asn1_access_control_rule, asn1_ac_rule[ii]);
 1407|    594|	sc_copy_asn1_entry(c_asn1_access_control_rules, asn1_ac_rules);
 1408|       |
 1409|       |
 1410|    594|	sc_copy_asn1_entry(c_asn1_com_obj_attr, asn1_c_attr);
 1411|    594|	sc_copy_asn1_entry(c_asn1_p15_obj, asn1_p15_obj);
 1412|    594|	sc_format_asn1_entry(asn1_c_attr + 0, p15_obj->label, &label_len, 0);
 1413|    594|	sc_format_asn1_entry(asn1_c_attr + 1, &p15_obj->flags, &flags_len, 0);
 1414|    594|	sc_format_asn1_entry(asn1_c_attr + 2, &p15_obj->auth_id, NULL, 0);
 1415|    594|	sc_format_asn1_entry(asn1_c_attr + 3, &p15_obj->user_consent, NULL, 0);
 1416|       |
 1417|  5.34k|	for (ii=0; ii<SC_PKCS15_MAX_ACCESS_RULES; ii++)   {
  ------------------
  |  |   42|  5.34k|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1417:13): [True: 4.75k, False: 594]
  ------------------
 1418|  4.75k|		sc_format_asn1_entry(asn1_ac_rule[ii] + 0, &p15_obj->access_rules[ii].access_mode, &access_mode_len, 0);
 1419|  4.75k|		sc_format_asn1_entry(asn1_ac_rule[ii] + 1, &p15_obj->access_rules[ii].auth_id, NULL, 0);
 1420|  4.75k|		sc_format_asn1_entry(asn1_ac_rules + ii, asn1_ac_rule[ii], NULL, 0);
 1421|  4.75k|	}
 1422|    594|	sc_format_asn1_entry(asn1_c_attr + 4, asn1_ac_rules, NULL, 0);
 1423|       |
 1424|    594|	sc_format_asn1_entry(asn1_p15_obj + 0, asn1_c_attr, NULL, 0);
 1425|    594|	sc_format_asn1_entry(asn1_p15_obj + 1, obj->asn1_class_attr, NULL, 0);
 1426|    594|	sc_format_asn1_entry(asn1_p15_obj + 2, obj->asn1_subclass_attr, NULL, 0);
 1427|    594|	sc_format_asn1_entry(asn1_p15_obj + 3, obj->asn1_type_attr, NULL, 0);
 1428|       |
 1429|    594|	r = asn1_decode(ctx, asn1_p15_obj, in, len, NULL, NULL, 0, depth + 1);
 1430|    594|	return r;
 1431|    594|}
asn1.c:asn1_decode_se_info:
 1244|     22|{
 1245|     22|	struct sc_pkcs15_sec_env_info **ses;
 1246|     22|	const unsigned char *ptr = obj;
 1247|     22|	size_t idx, ptrlen = objlen;
 1248|     22|	int ret;
 1249|       |
 1250|     22|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     22|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     22|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     22|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     22|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1251|       |
 1252|     22|	ses = calloc(SC_MAX_SE_NUM, sizeof(sc_pkcs15_sec_env_info_t *));
  ------------------
  |  |   51|     22|#define SC_MAX_SE_NUM			8
  ------------------
 1253|     22|	if (ses == NULL) {
  ------------------
  |  Branch (1253:6): [True: 0, False: 22]
  ------------------
 1254|      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]
  |  |  ------------------
  ------------------
 1255|      0|	}
 1256|       |
 1257|     90|	for (idx=0; idx < SC_MAX_SE_NUM && ptrlen; )   {
  ------------------
  |  |   51|    180|#define SC_MAX_SE_NUM			8
  ------------------
  |  Branch (1257:14): [True: 90, False: 0]
  |  Branch (1257:37): [True: 71, False: 19]
  ------------------
 1258|     71|		struct sc_asn1_entry asn1_se[2];
 1259|     71|		struct sc_asn1_entry asn1_se_info[4];
 1260|     71|		struct sc_pkcs15_sec_env_info si;
 1261|       |
 1262|     71|		sc_copy_asn1_entry(c_asn1_se, asn1_se);
 1263|     71|		sc_copy_asn1_entry(c_asn1_se_info, asn1_se_info);
 1264|       |
 1265|     71|		si.aid.len = sizeof(si.aid.value);
 1266|     71|		sc_format_asn1_entry(asn1_se_info + 0, &si.se, NULL, 0);
 1267|     71|		sc_format_asn1_entry(asn1_se_info + 1, &si.owner, NULL, 0);
 1268|     71|		sc_format_asn1_entry(asn1_se_info + 2, &si.aid.value, &si.aid.len, 0);
 1269|     71|		sc_format_asn1_entry(asn1_se + 0, asn1_se_info, NULL, 0);
 1270|       |
 1271|     71|		ret = asn1_decode(ctx, asn1_se, ptr, ptrlen, &ptr, &ptrlen, 0, depth+1);
 1272|     71|		if (ret != SC_SUCCESS)
  ------------------
  |  |   28|     71|#define SC_SUCCESS				0
  ------------------
  |  Branch (1272:7): [True: 3, False: 68]
  ------------------
 1273|      3|			goto err;
 1274|     68|		if (!(asn1_se_info[1].flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|     68|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1274:7): [True: 57, False: 11]
  ------------------
 1275|     57|			sc_init_oid(&si.owner);
 1276|       |
 1277|     68|		ses[idx] = calloc(1, sizeof(sc_pkcs15_sec_env_info_t));
 1278|     68|		if (ses[idx] == NULL) {
  ------------------
  |  Branch (1278:7): [True: 0, False: 68]
  ------------------
 1279|      0|			ret = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1280|      0|			goto err;
 1281|      0|		}
 1282|       |
 1283|     68|		memcpy(ses[idx], &si, sizeof(struct sc_pkcs15_sec_env_info));
 1284|     68|		idx++;
 1285|     68|	}
 1286|       |
 1287|     19|	*se  = ses;
 1288|     19|	*num = idx;
 1289|     19|	ret = SC_SUCCESS;
  ------------------
  |  |   28|     19|#define SC_SUCCESS				0
  ------------------
 1290|     22|err:
 1291|     22|	if (ret != SC_SUCCESS) {
  ------------------
  |  |   28|     22|#define SC_SUCCESS				0
  ------------------
  |  Branch (1291:6): [True: 3, False: 19]
  ------------------
 1292|      3|		size_t i;
 1293|     10|		for (i = 0; i < idx; i++)
  ------------------
  |  Branch (1293:15): [True: 7, False: 3]
  ------------------
 1294|      7|			if (ses[i])
  ------------------
  |  Branch (1294:8): [True: 7, False: 0]
  ------------------
 1295|      7|				free(ses[i]);
 1296|      3|		free(ses);
 1297|      3|	}
 1298|       |
 1299|     22|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, ret);
  ------------------
  |  |  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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 3, False: 19]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1300|     22|}
asn1.c:asn1_encode:
 2045|  24.0k|{
 2046|  24.0k|	int r, idx = 0;
 2047|  24.0k|	u8 *obj = NULL, *buf = NULL, *tmp;
 2048|  24.0k|	size_t total = 0, objsize;
 2049|       |
 2050|  24.0k|	if (asn1 == NULL) {
  ------------------
  |  Branch (2050:6): [True: 0, False: 24.0k]
  ------------------
 2051|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2052|      0|	}
 2053|       |
 2054|  86.6k|	for (idx = 0; asn1[idx].name != NULL; idx++) {
  ------------------
  |  Branch (2054:16): [True: 63.0k, False: 23.5k]
  ------------------
 2055|  63.0k|		r = asn1_encode_entry(ctx, &asn1[idx], &obj, &objsize, depth);
 2056|  63.0k|		if (r) {
  ------------------
  |  Branch (2056:7): [True: 459, False: 62.6k]
  ------------------
 2057|    459|			if (obj)
  ------------------
  |  Branch (2057:8): [True: 0, False: 459]
  ------------------
 2058|      0|				free(obj);
 2059|    459|			if (buf)
  ------------------
  |  Branch (2059:8): [True: 140, False: 319]
  ------------------
 2060|    140|				free(buf);
 2061|    459|			return r;
 2062|    459|		}
 2063|       |		/* in case of an empty (optional) element continue with
 2064|       |		 * the next asn1 element */
 2065|  62.6k|		if (!objsize)
  ------------------
  |  Branch (2065:7): [True: 23.6k, False: 38.9k]
  ------------------
 2066|  23.6k|			continue;
 2067|  38.9k|		tmp = (u8 *) realloc(buf, total + objsize);
 2068|  38.9k|		if (!tmp) {
  ------------------
  |  Branch (2068:7): [True: 0, False: 38.9k]
  ------------------
 2069|      0|			if (obj)
  ------------------
  |  Branch (2069:8): [True: 0, False: 0]
  ------------------
 2070|      0|				free(obj);
 2071|      0|			if (buf)
  ------------------
  |  Branch (2071:8): [True: 0, False: 0]
  ------------------
 2072|      0|				free(buf);
 2073|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2074|      0|		}
 2075|  38.9k|		buf = tmp;
 2076|  38.9k|		memcpy(buf + total, obj, objsize);
 2077|  38.9k|		free(obj);
 2078|  38.9k|		obj = NULL;
 2079|  38.9k|		total += objsize;
 2080|  38.9k|	}
 2081|  23.5k|	*ptr = buf;
 2082|  23.5k|	*size = total;
 2083|  23.5k|	return 0;
 2084|  24.0k|}
asn1.c:asn1_encode_entry:
 1828|  64.2k|{
 1829|  64.2k|	void *parm = entry->parm;
 1830|  64.2k|	int (*callback_func)(sc_context_t *nctx, void *arg, u8 **nobj,
 1831|  64.2k|			     size_t *nobjlen, int ndepth);
 1832|  64.2k|	const size_t *len = (const size_t *) entry->arg;
 1833|  64.2k|	int r = 0;
 1834|  64.2k|	u8 * buf = NULL;
 1835|  64.2k|	size_t buflen = 0;
 1836|       |
 1837|  64.2k|	callback_func = parm;
 1838|       |
 1839|  64.2k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "%*.*sencoding '%s'%s\n",
  ------------------
  |  |   70|  64.2k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               #define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  | 1840|  64.2k|	       	depth, depth, "", entry->name,
  |  |  |  | 1841|  64.2k|		(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
  |  |  |  |  ------------------
  |  |  |  |  |  |  147|  64.2k|#define SC_ASN1_PRESENT			0x00000001
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1840|  64.2k|	       	depth, depth, "", entry->name,
 1841|  64.2k|		(entry->flags & SC_ASN1_PRESENT)? "" : " (not present)");
 1842|  64.2k|	if (!(entry->flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|  64.2k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1842:6): [True: 23.7k, False: 40.4k]
  ------------------
 1843|  23.7k|		goto no_object;
 1844|  40.4k|	sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|  80.9k|#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: 14.5k, False: 25.9k]
  |  |  ------------------
  ------------------
 1845|  40.4k|		 "%*.*stype=%d, tag=0x%02x, parm=%p, len=%"SC_FORMAT_LEN_SIZE_T"u\n",
 1846|  40.4k|		 depth, depth, "", entry->type, entry->tag, parm,
 1847|  40.4k|		 len ? *len : 0);
 1848|       |
 1849|  40.4k|	if (entry->type == SC_ASN1_CHOICE) {
  ------------------
  |  |  170|  40.4k|#define SC_ASN1_CHOICE			130
  ------------------
  |  Branch (1849:6): [True: 1.16k, False: 39.2k]
  ------------------
 1850|  1.16k|		const struct sc_asn1_entry *list, *choice = NULL;
 1851|       |
 1852|  1.16k|		list = (const struct sc_asn1_entry *) parm;
 1853|  3.89k|		while (list->name != NULL) {
  ------------------
  |  Branch (1853:10): [True: 2.72k, False: 1.16k]
  ------------------
 1854|  2.72k|			if (list->flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|  2.72k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (1854:8): [True: 1.16k, False: 1.55k]
  ------------------
 1855|  1.16k|				if (choice) {
  ------------------
  |  Branch (1855:9): [True: 0, False: 1.16k]
  ------------------
 1856|      0|					sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1857|      0|						"ASN.1 problem: more than "
 1858|      0|						"one CHOICE when encoding %s: "
 1859|      0|						"%s and %s both present\n",
 1860|      0|						entry->name,
 1861|      0|						choice->name,
 1862|      0|						list->name);
 1863|      0|					return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1864|      0|				}
 1865|  1.16k|				choice = list;
 1866|  1.16k|			}
 1867|  2.72k|			list++;
 1868|  2.72k|		}
 1869|  1.16k|		if (choice == NULL)
  ------------------
  |  Branch (1869:7): [True: 3, False: 1.16k]
  ------------------
 1870|      3|			goto no_object;
 1871|  1.16k|		return asn1_encode_entry(ctx, choice, obj, objlen, depth + 1);
 1872|  1.16k|	}
 1873|       |
 1874|  39.2k|	if (entry->type != SC_ASN1_NULL && parm == NULL) {
  ------------------
  |  |  158|  78.5k|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1874:6): [True: 38.4k, False: 839]
  |  Branch (1874:37): [True: 0, False: 38.4k]
  ------------------
 1875|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "unexpected parm == NULL\n");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1876|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1877|      0|	}
 1878|       |
 1879|  39.2k|	switch (entry->type) {
 1880|  8.28k|	case SC_ASN1_STRUCT:
  ------------------
  |  |  169|  8.28k|#define SC_ASN1_STRUCT			129
  ------------------
  |  Branch (1880:2): [True: 8.28k, False: 31.0k]
  ------------------
 1881|  8.28k|		r = asn1_encode(ctx, (const struct sc_asn1_entry *) parm, &buf,
 1882|  8.28k|				&buflen, depth + 1);
 1883|  8.28k|		break;
 1884|    839|	case SC_ASN1_NULL:
  ------------------
  |  |  158|    839|#define SC_ASN1_NULL                    5
  ------------------
  |  Branch (1884:2): [True: 839, False: 38.4k]
  ------------------
 1885|    839|		buf = NULL;
 1886|    839|		buflen = 0;
 1887|    839|		break;
 1888|      6|	case SC_ASN1_BOOLEAN:
  ------------------
  |  |  153|      6|#define SC_ASN1_BOOLEAN                 1
  ------------------
  |  Branch (1888:2): [True: 6, False: 39.2k]
  ------------------
 1889|      6|		buf = malloc(1);
 1890|      6|		if (buf == NULL) {
  ------------------
  |  Branch (1890:7): [True: 0, False: 6]
  ------------------
 1891|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1892|      0|			break;
 1893|      0|		}
 1894|      6|		buf[0] = *((int *) parm) ? 0xFF : 0;
  ------------------
  |  Branch (1894:12): [True: 0, False: 6]
  ------------------
 1895|      6|		buflen = 1;
 1896|      6|		break;
 1897|  4.67k|	case SC_ASN1_INTEGER:
  ------------------
  |  |  154|  4.67k|#define SC_ASN1_INTEGER                 2
  ------------------
  |  Branch (1897:2): [True: 4.67k, False: 34.6k]
  ------------------
 1898|  4.94k|	case SC_ASN1_ENUMERATED:
  ------------------
  |  |  160|  4.94k|#define SC_ASN1_ENUMERATED              10
  ------------------
  |  Branch (1898:2): [True: 273, False: 39.0k]
  ------------------
 1899|  4.94k|		r = asn1_encode_integer(*((int *) entry->parm), &buf, &buflen);
 1900|  4.94k|		break;
 1901|     26|	case SC_ASN1_BIT_STRING_NI:
  ------------------
  |  |  156|     26|#define SC_ASN1_BIT_STRING_NI           128
  ------------------
  |  Branch (1901:2): [True: 26, False: 39.2k]
  ------------------
 1902|     26|	case SC_ASN1_BIT_STRING:
  ------------------
  |  |  155|     26|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1902:2): [True: 0, False: 39.2k]
  ------------------
 1903|     26|		if (len != NULL) {
  ------------------
  |  Branch (1903:7): [True: 26, False: 0]
  ------------------
 1904|     26|			if (entry->type == SC_ASN1_BIT_STRING)
  ------------------
  |  |  155|     26|#define SC_ASN1_BIT_STRING              3
  ------------------
  |  Branch (1904:8): [True: 0, False: 26]
  ------------------
 1905|      0|				r = encode_bit_string((const u8 *) parm, *len, &buf, &buflen, 1);
 1906|     26|			else
 1907|     26|				r = encode_bit_string((const u8 *) parm, *len, &buf, &buflen, 0);
 1908|     26|		} else {
 1909|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1910|      0|		}
 1911|     26|		break;
 1912|  2.10k|	case SC_ASN1_BIT_FIELD:
  ------------------
  |  |  171|  2.10k|#define SC_ASN1_BIT_FIELD		131	/* bit string as integer */
  ------------------
  |  Branch (1912:2): [True: 2.10k, False: 37.1k]
  ------------------
 1913|  2.10k|		if (len != NULL) {
  ------------------
  |  Branch (1913:7): [True: 2.10k, False: 0]
  ------------------
 1914|  2.10k|			r = encode_bit_field((const u8 *) parm, *len, &buf, &buflen);
 1915|  2.10k|		} else {
 1916|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1917|      0|		}
 1918|  2.10k|		break;
 1919|    516|	case SC_ASN1_PRINTABLESTRING:
  ------------------
  |  |  164|    516|#define SC_ASN1_PRINTABLESTRING         19
  ------------------
  |  Branch (1919:2): [True: 516, False: 38.7k]
  ------------------
 1920|  8.04k|	case SC_ASN1_OCTET_STRING:
  ------------------
  |  |  157|  8.04k|#define SC_ASN1_OCTET_STRING            4
  ------------------
  |  Branch (1920:2): [True: 7.53k, False: 31.7k]
  ------------------
 1921|  9.46k|	case SC_ASN1_UTF8STRING:
  ------------------
  |  |  161|  9.46k|#define SC_ASN1_UTF8STRING              12
  ------------------
  |  Branch (1921:2): [True: 1.41k, False: 37.8k]
  ------------------
 1922|  9.46k|		if (len != NULL) {
  ------------------
  |  Branch (1922:7): [True: 9.46k, False: 0]
  ------------------
 1923|  9.46k|			buf = malloc(*len + 1);
 1924|  9.46k|			if (buf == NULL) {
  ------------------
  |  Branch (1924:8): [True: 0, False: 9.46k]
  ------------------
 1925|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1926|      0|				break;
 1927|      0|			}
 1928|  9.46k|			buflen = 0;
 1929|       |			/* If the integer is supposed to be unsigned, insert
 1930|       |			 * a padding byte if the MSB is one */
 1931|  9.46k|			if ((entry->flags & SC_ASN1_UNSIGNED)
  ------------------
  |  |  150|  9.46k|#define SC_ASN1_UNSIGNED		0x00000008
  ------------------
  |  Branch (1931:8): [True: 507, False: 8.96k]
  ------------------
 1932|    507|					&& (((u8 *) parm)[0] & 0x80)) {
  ------------------
  |  Branch (1932:9): [True: 56, False: 451]
  ------------------
 1933|     56|				buf[buflen++] = 0x00;
 1934|     56|			}
 1935|  9.46k|			memcpy(buf + buflen, parm, *len);
 1936|  9.46k|			buflen += *len;
 1937|  9.46k|		} else {
 1938|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1939|      0|		}
 1940|  9.46k|		break;
 1941|  9.46k|	case SC_ASN1_GENERALIZEDTIME:
  ------------------
  |  |  166|    435|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
  |  Branch (1941:2): [True: 435, False: 38.8k]
  ------------------
 1942|    435|		if (len != NULL) {
  ------------------
  |  Branch (1942:7): [True: 435, False: 0]
  ------------------
 1943|    435|			buf = malloc(*len);
 1944|    435|			if (buf == NULL) {
  ------------------
  |  Branch (1944:8): [True: 0, False: 435]
  ------------------
 1945|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1946|      0|				break;
 1947|      0|			}
 1948|    435|			memcpy(buf, parm, *len);
 1949|    435|			buflen = *len;
 1950|    435|		} else {
 1951|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1952|      0|		}
 1953|    435|		break;
 1954|  8.50k|	case SC_ASN1_OBJECT:
  ------------------
  |  |  159|  8.50k|#define SC_ASN1_OBJECT                  6
  ------------------
  |  Branch (1954:2): [True: 8.50k, False: 30.7k]
  ------------------
 1955|  8.50k|		r = sc_asn1_encode_object_id(&buf, &buflen, (struct sc_object_id *) parm);
 1956|  8.50k|		break;
 1957|  3.65k|	case SC_ASN1_PATH:
  ------------------
  |  |  174|  3.65k|#define SC_ASN1_PATH			256
  ------------------
  |  Branch (1957:2): [True: 3.65k, False: 35.6k]
  ------------------
 1958|  3.65k|		r = asn1_encode_path(ctx, (const sc_path_t *) parm, &buf, &buflen, depth, entry->flags);
 1959|  3.65k|		break;
 1960|    515|	case SC_ASN1_PKCS15_ID:
  ------------------
  |  |  175|    515|#define SC_ASN1_PKCS15_ID		257
  ------------------
  |  Branch (1960:2): [True: 515, False: 38.7k]
  ------------------
 1961|    515|		{
 1962|    515|			const struct sc_pkcs15_id *id = (const struct sc_pkcs15_id *) parm;
 1963|       |
 1964|    515|			buf = malloc(id->len);
 1965|    515|			if (buf == NULL) {
  ------------------
  |  Branch (1965:8): [True: 0, False: 515]
  ------------------
 1966|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1967|      0|				break;
 1968|      0|			}
 1969|    515|			memcpy(buf, id->value, id->len);
 1970|    515|			buflen = id->len;
 1971|    515|		}
 1972|      0|		break;
 1973|    472|	case SC_ASN1_PKCS15_OBJECT:
  ------------------
  |  |  176|    472|#define SC_ASN1_PKCS15_OBJECT		258
  ------------------
  |  Branch (1973:2): [True: 472, False: 38.8k]
  ------------------
 1974|    472|		r = asn1_encode_p15_object(ctx, (const struct sc_asn1_pkcs15_object *) parm, &buf, &buflen, depth);
 1975|    472|		break;
 1976|     26|	case SC_ASN1_ALGORITHM_ID:
  ------------------
  |  |  177|     26|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
  |  Branch (1976:2): [True: 26, False: 39.2k]
  ------------------
 1977|     26|		r = sc_asn1_encode_algorithm_id(ctx, &buf, &buflen, (const struct sc_algorithm_id *) parm, depth);
 1978|     26|		break;
 1979|     16|	case SC_ASN1_SE_INFO:
  ------------------
  |  |  178|     16|#define SC_ASN1_SE_INFO			260
  ------------------
  |  Branch (1979:2): [True: 16, False: 39.2k]
  ------------------
 1980|     16|		if (!len)
  ------------------
  |  Branch (1980:7): [True: 0, False: 16]
  ------------------
 1981|      0|			return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1982|     16|		r = asn1_encode_se_info(ctx, (struct sc_pkcs15_sec_env_info **)parm, *len, &buf, &buflen, depth);
 1983|     16|		break;
 1984|      0|	case SC_ASN1_CALLBACK:
  ------------------
  |  |  181|      0|#define SC_ASN1_CALLBACK		384
  ------------------
  |  Branch (1984:2): [True: 0, False: 39.2k]
  ------------------
 1985|      0|		r = callback_func(ctx, entry->arg, &buf, &buflen, depth);
 1986|      0|		break;
 1987|      0|	default:
  ------------------
  |  Branch (1987:2): [True: 0, False: 39.2k]
  ------------------
 1988|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "invalid ASN.1 type: %d\n", entry->type);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1989|      0|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 1990|  39.2k|	}
 1991|  39.2k|	if (r) {
  ------------------
  |  Branch (1991:6): [True: 263, False: 39.0k]
  ------------------
 1992|    263|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "encoding of ASN.1 object '%s' failed: %s\n", entry->name,
  ------------------
  |  |   70|    263|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1993|    263|		      sc_strerror(r));
 1994|    263|		if (buf)
  ------------------
  |  Branch (1994:7): [True: 0, False: 263]
  ------------------
 1995|      0|			free(buf);
 1996|    263|		return r;
 1997|    263|	}
 1998|       |
 1999|       |	/* Treatment of OPTIONAL elements:
 2000|       |	 *  -	if the encoding has 0 length, and the element is OPTIONAL,
 2001|       |	 *	we don't write anything (unless it's an ASN1 NULL and the
 2002|       |	 *      SC_ASN1_PRESENT flag is set).
 2003|       |	 *  -	if the encoding has 0 length, but the element is non-OPTIONAL,
 2004|       |	 *	constructed, we write a empty element (e.g. a SEQUENCE of
 2005|       |	 *      length 0). In case of an ASN1 NULL just write the tag and
 2006|       |	 *      length (i.e. 0x05,0x00).
 2007|       |	 *  -	any other empty objects are considered bogus
 2008|       |	 */
 2009|  62.8k|no_object:
 2010|  62.8k|	if (!buflen && entry->flags & SC_ASN1_OPTIONAL && !(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  148|  87.6k|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
              	if (!buflen && entry->flags & SC_ASN1_OPTIONAL && !(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|  23.7k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (2010:6): [True: 24.7k, False: 38.0k]
  |  Branch (2010:17): [True: 23.7k, False: 1.02k]
  |  Branch (2010:52): [True: 23.6k, False: 56]
  ------------------
 2011|       |		/* This happens when we try to encode e.g. the
 2012|       |		 * subClassAttributes, which may be empty */
 2013|  23.6k|		*obj = NULL;
 2014|  23.6k|		*objlen = 0;
 2015|  23.6k|		r = 0;
 2016|  39.1k|	} else if (!buflen && (entry->flags & SC_ASN1_EMPTY_ALLOWED)) {
  ------------------
  |  |  151|  1.08k|#define SC_ASN1_EMPTY_ALLOWED           0x00000010
  ------------------
  |  Branch (2016:13): [True: 1.08k, False: 38.0k]
  |  Branch (2016:24): [True: 25, False: 1.05k]
  ------------------
 2017|     25|		*obj = NULL;
 2018|     25|		*objlen = 0;
 2019|     25|		r = asn1_write_element(ctx, entry->tag, buf, buflen, obj, objlen);
 2020|     25|		if (r)
  ------------------
  |  Branch (2020:7): [True: 0, False: 25]
  ------------------
 2021|      0|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "error writing ASN.1 tag and length: %s\n", sc_strerror(r));
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2022|  39.1k|	} else if (buflen || entry->type == SC_ASN1_NULL || entry->tag & SC_ASN1_CONS) {
  ------------------
  |  |  158|  40.1k|#define SC_ASN1_NULL                    5
  ------------------
              	} else if (buflen || entry->type == SC_ASN1_NULL || entry->tag & SC_ASN1_CONS) {
  ------------------
  |  |  141|    217|#define SC_ASN1_CONS			0x20000000
  ------------------
  |  Branch (2022:13): [True: 38.0k, False: 1.05k]
  |  Branch (2022:23): [True: 839, False: 217]
  |  Branch (2022:54): [True: 21, False: 196]
  ------------------
 2023|  38.9k|		r = asn1_write_element(ctx, entry->tag, buf, buflen, obj, objlen);
 2024|  38.9k|		if (r)
  ------------------
  |  Branch (2024:7): [True: 0, False: 38.9k]
  ------------------
 2025|      0|			sc_debug(ctx, SC_LOG_DEBUG_ASN1, "error writing ASN.1 tag and length: %s\n",
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2026|  38.9k|					sc_strerror(r));
 2027|  38.9k|	} else if (!(entry->flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|    196|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (2027:13): [True: 94, False: 102]
  ------------------
 2028|     94|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "cannot encode non-optional ASN.1 object: not given by caller\n");
  ------------------
  |  |   70|     94|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2029|     94|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     94|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2030|    102|	} else {
 2031|    102|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "cannot encode empty non-optional ASN.1 object\n");
  ------------------
  |  |   70|    102|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2032|    102|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|    102|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2033|    102|	}
 2034|  62.8k|	if (buf)
  ------------------
  |  Branch (2034:6): [True: 38.1k, False: 24.6k]
  ------------------
 2035|  38.1k|		free(buf);
 2036|  62.8k|	if (r >= 0)
  ------------------
  |  Branch (2036:6): [True: 62.6k, False: 196]
  ------------------
 2037|  62.6k|		sc_debug(ctx, SC_LOG_DEBUG_ASN1,
  ------------------
  |  |   70|  62.6k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2038|  62.8k|			 "%*.*slength of encoded item=%"SC_FORMAT_LEN_SIZE_T"u\n",
 2039|  62.8k|			 depth, depth, "", *objlen);
 2040|  62.8k|	return r;
 2041|  39.2k|}
asn1.c:asn1_encode_integer:
  776|  4.94k|{
  777|  4.94k|	int i = sizeof(in) * 8, skip_zero, skip_sign;
  778|  4.94k|	u8 *p, b;
  779|       |
  780|  4.94k|	if (in < 0)
  ------------------
  |  Branch (780:6): [True: 433, False: 4.51k]
  ------------------
  781|    433|	{
  782|    433|		skip_sign = 1;
  783|    433|		skip_zero= 0;
  784|    433|	}
  785|  4.51k|	else
  786|  4.51k|	{
  787|  4.51k|		skip_sign = 0;
  788|  4.51k|		skip_zero= 1;
  789|  4.51k|	}
  790|  4.94k|	*obj = p = malloc(sizeof(in)+1);
  791|  4.94k|	if (*obj == NULL)
  ------------------
  |  Branch (791:6): [True: 0, False: 4.94k]
  ------------------
  792|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  793|  19.7k|	do {
  794|  19.7k|		i -= 8;
  795|  19.7k|		b = in >> i;
  796|  19.7k|		if (skip_sign)
  ------------------
  |  Branch (796:7): [True: 1.55k, False: 18.2k]
  ------------------
  797|  1.55k|		{
  798|  1.55k|			if (b != 0xff)
  ------------------
  |  Branch (798:8): [True: 203, False: 1.35k]
  ------------------
  799|    203|				skip_sign = 0;
  800|  1.55k|			if (b & 0x80)
  ------------------
  |  Branch (800:8): [True: 1.54k, False: 12]
  ------------------
  801|  1.54k|			{
  802|  1.54k|				*p = b;
  803|  1.54k|				if (0xff == b)
  ------------------
  |  Branch (803:9): [True: 1.35k, False: 191]
  ------------------
  804|  1.35k|					continue;
  805|  1.54k|			}
  806|     12|			else
  807|     12|			{
  808|     12|				p++;
  809|     12|				skip_sign = 0;
  810|     12|			}
  811|  1.55k|		}
  812|  18.4k|		if (b == 0 && skip_zero)
  ------------------
  |  Branch (812:7): [True: 14.1k, False: 4.24k]
  |  Branch (812:17): [True: 13.9k, False: 249]
  ------------------
  813|  13.9k|			continue;
  814|  4.49k|		if (skip_zero) {
  ------------------
  |  Branch (814:7): [True: 3.00k, False: 1.49k]
  ------------------
  815|  3.00k|			skip_zero = 0;
  816|       |			/* prepend 0x00 if MSb is 1 and integer positive */
  817|  3.00k|			if ((b & 0x80) != 0 && in > 0)
  ------------------
  |  Branch (817:8): [True: 56, False: 2.95k]
  |  Branch (817:27): [True: 56, False: 0]
  ------------------
  818|     56|				*p++ = 0;
  819|  3.00k|		}
  820|  4.49k|		*p++ = b;
  821|  19.7k|	} while (i > 0);
  ------------------
  |  Branch (821:11): [True: 14.8k, False: 4.94k]
  ------------------
  822|  4.94k|	if (skip_sign)
  ------------------
  |  Branch (822:6): [True: 230, False: 4.71k]
  ------------------
  823|    230|		p++;
  824|  4.94k|	*objsize = p - *obj;
  825|  4.94k|	if (*objsize == 0) {
  ------------------
  |  Branch (825:6): [True: 1.50k, False: 3.44k]
  ------------------
  826|  1.50k|		*objsize = 1;
  827|  1.50k|		(*obj)[0] = 0;
  828|  1.50k|	}
  829|  4.94k|	return 0;
  830|  4.94k|}
asn1.c:encode_bit_string:
  652|  2.13k|{
  653|  2.13k|	const u8 *in = inbuf;
  654|  2.13k|	u8 *out;
  655|  2.13k|	size_t bytes, skipped = 0;
  656|       |
  657|  2.13k|	bytes = BYTES4BITS(bits_left) + 1;
  ------------------
  |  |  146|  2.13k|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  658|  2.13k|	*outbuf = out = malloc(bytes);
  659|  2.13k|	if (out == NULL)
  ------------------
  |  Branch (659:6): [True: 0, False: 2.13k]
  ------------------
  660|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  661|  2.13k|	*outlen = bytes;
  662|  2.13k|	out += 1;
  663|  6.99k|	while (bits_left) {
  ------------------
  |  Branch (663:9): [True: 4.86k, False: 2.13k]
  ------------------
  664|  4.86k|		size_t i, bits_to_go = 8;
  665|       |
  666|  4.86k|		*out = 0;
  667|  4.86k|		if (bits_left < 8) {
  ------------------
  |  Branch (667:7): [True: 1.93k, False: 2.92k]
  ------------------
  668|  1.93k|			bits_to_go = bits_left;
  669|  1.93k|			skipped = 8 - bits_left;
  670|  1.93k|		}
  671|  4.86k|		if (invert) {
  ------------------
  |  Branch (671:7): [True: 2.22k, False: 2.64k]
  ------------------
  672|  12.9k|			for (i = 0; i < bits_to_go; i++)
  ------------------
  |  Branch (672:16): [True: 10.7k, False: 2.22k]
  ------------------
  673|  10.7k|				*out |= ((*in >> i) & 1) << (7 - i);
  674|  2.64k|		} else {
  675|  2.64k|			*out = *in;
  676|  2.64k|			if (bits_left < 8)
  ------------------
  |  Branch (676:8): [True: 0, False: 2.64k]
  ------------------
  677|      0|				return SC_ERROR_NOT_SUPPORTED; /* FIXME */
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  678|  2.64k|		}
  679|  4.86k|		bits_left -= bits_to_go;
  680|  4.86k|		out++, in++;
  681|  4.86k|	}
  682|  2.13k|	out = *outbuf;
  683|  2.13k|	out[0] = skipped;
  684|  2.13k|	return 0;
  685|  2.13k|}
asn1.c:encode_bit_field:
  713|  2.10k|{
  714|  2.10k|	u8		data[sizeof(unsigned int)];
  715|  2.10k|	unsigned int	field = 0;
  716|  2.10k|	size_t		i, bits;
  717|       |
  718|  2.10k|	if (inlen != sizeof(data))
  ------------------
  |  Branch (718:6): [True: 0, False: 2.10k]
  ------------------
  719|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  720|       |
  721|       |	/* count the bits */
  722|  2.10k|	memcpy(&field, inbuf, inlen);
  723|  12.8k|	for (bits = 0; field; bits++)
  ------------------
  |  Branch (723:17): [True: 10.7k, False: 2.10k]
  ------------------
  724|  10.7k|		field >>= 1;
  725|       |
  726|  2.10k|	memcpy(&field, inbuf, inlen);
  727|  4.32k|	for (i = 0; i < bits; i += 8)
  ------------------
  |  Branch (727:14): [True: 2.22k, False: 2.10k]
  ------------------
  728|  2.22k|		data[i/8] = field >> i;
  729|       |
  730|  2.10k|	return encode_bit_string(data, bits, outbuf, outlen, 1);
  731|  2.10k|}
asn1.c:asn1_encode_path:
 1212|  3.65k|{
 1213|  3.65k|	int r;
 1214|  3.65k| 	struct sc_asn1_entry asn1_path[5];
 1215|  3.65k|	sc_path_t tpath = *path;
 1216|       |
 1217|  3.65k|	sc_copy_asn1_entry(c_asn1_path, asn1_path);
 1218|  3.65k|	sc_format_asn1_entry(asn1_path + 0, (void *) &tpath.value, (void *) &tpath.len, 1);
 1219|       |
 1220|  3.65k|	asn1_path[0].flags |= parent_flags;
 1221|  3.65k|	if (path->count > 0) {
  ------------------
  |  Branch (1221:6): [True: 24, False: 3.62k]
  ------------------
 1222|     24|		sc_format_asn1_entry(asn1_path + 1, (void *) &tpath.index, NULL, 1);
 1223|       |		sc_format_asn1_entry(asn1_path + 2, (void *) &tpath.count, NULL, 1);
 1224|     24|	}
 1225|  3.65k|	r = asn1_encode(ctx, asn1_path, buf, bufsize, depth + 1);
 1226|  3.65k|	return r;
 1227|  3.65k|}
asn1.c:asn1_encode_p15_object:
 1435|    472|{
 1436|    472|	struct sc_pkcs15_object p15_obj = *obj->p15_obj;
 1437|    472|	struct sc_asn1_entry    asn1_c_attr[6], asn1_p15_obj[5];
 1438|    472|	struct sc_asn1_entry asn1_ac_rules[SC_PKCS15_MAX_ACCESS_RULES + 1], asn1_ac_rule[SC_PKCS15_MAX_ACCESS_RULES][3];
 1439|    472|	size_t label_len = strlen(p15_obj.label);
 1440|    472|	size_t flags_len;
 1441|    472|	size_t access_mode_len;
 1442|    472|	int r, ii;
 1443|       |
 1444|    472|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "encode p15 obj(type:0x%X,access_mode:0x%X)", p15_obj.type, p15_obj.access_rules[0].access_mode);
  ------------------
  |  |   70|    472|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1445|    472|	if (p15_obj.access_rules[0].access_mode)   {
  ------------------
  |  Branch (1445:6): [True: 0, False: 472]
  ------------------
 1446|      0|		for (ii=0; ii<SC_PKCS15_MAX_ACCESS_RULES; ii++)   {
  ------------------
  |  |   42|      0|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1446:14): [True: 0, False: 0]
  ------------------
 1447|      0|			sc_copy_asn1_entry(c_asn1_access_control_rule, asn1_ac_rule[ii]);
 1448|      0|			if (p15_obj.access_rules[ii].auth_id.len == 0)   {
  ------------------
  |  Branch (1448:8): [True: 0, False: 0]
  ------------------
 1449|      0|				asn1_ac_rule[ii][1].type = SC_ASN1_NULL;
  ------------------
  |  |  158|      0|#define SC_ASN1_NULL                    5
  ------------------
 1450|      0|				asn1_ac_rule[ii][1].tag = SC_ASN1_TAG_NULL;
  ------------------
  |  |  199|      0|#define SC_ASN1_TAG_NULL		5
  ------------------
 1451|      0|			}
 1452|      0|		}
 1453|      0|		sc_copy_asn1_entry(c_asn1_access_control_rules, asn1_ac_rules);
 1454|      0|	}
 1455|       |
 1456|    472|	sc_copy_asn1_entry(c_asn1_com_obj_attr, asn1_c_attr);
 1457|    472|	sc_copy_asn1_entry(c_asn1_p15_obj, asn1_p15_obj);
 1458|    472|	if (label_len != 0)
  ------------------
  |  Branch (1458:6): [True: 418, False: 54]
  ------------------
 1459|    418|		sc_format_asn1_entry(asn1_c_attr + 0, (void *) p15_obj.label, &label_len, 1);
 1460|    472|	if (p15_obj.flags) {
  ------------------
  |  Branch (1460:6): [True: 434, False: 38]
  ------------------
 1461|    434|		flags_len = sizeof(p15_obj.flags);
 1462|    434|		sc_format_asn1_entry(asn1_c_attr + 1, (void *) &p15_obj.flags, &flags_len, 1);
 1463|    434|	}
 1464|    472|	if (p15_obj.auth_id.len)
  ------------------
  |  Branch (1464:6): [True: 115, False: 357]
  ------------------
 1465|    115|		sc_format_asn1_entry(asn1_c_attr + 2, (void *) &p15_obj.auth_id, NULL, 1);
 1466|    472|	if (p15_obj.user_consent)
  ------------------
  |  Branch (1466:6): [True: 8, False: 464]
  ------------------
 1467|      8|		sc_format_asn1_entry(asn1_c_attr + 3, (void *) &p15_obj.user_consent, NULL, 1);
 1468|       |
 1469|    472|	if (p15_obj.access_rules[0].access_mode)   {
  ------------------
  |  Branch (1469:6): [True: 0, False: 472]
  ------------------
 1470|      0|		for (ii = 0; ii < SC_PKCS15_MAX_ACCESS_RULES && p15_obj.access_rules[ii].access_mode; ii++) {
  ------------------
  |  |   42|      0|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (1470:16): [True: 0, False: 0]
  |  Branch (1470:51): [True: 0, False: 0]
  ------------------
 1471|      0|			access_mode_len = sizeof(p15_obj.access_rules[ii].access_mode);
 1472|      0|			sc_format_asn1_entry(asn1_ac_rule[ii] + 0, (void *) &p15_obj.access_rules[ii].access_mode, &access_mode_len, 1);
 1473|      0|			sc_format_asn1_entry(asn1_ac_rule[ii] + 1, (void *) &p15_obj.access_rules[ii].auth_id, NULL, 1);
 1474|      0|			sc_format_asn1_entry(asn1_ac_rules + ii, asn1_ac_rule[ii], NULL, 1);
 1475|      0|		}
 1476|      0|		sc_format_asn1_entry(asn1_c_attr + 4, asn1_ac_rules, NULL, 1);
 1477|      0|	}
 1478|       |
 1479|    472|	sc_format_asn1_entry(asn1_p15_obj + 0, asn1_c_attr, NULL, 1);
 1480|    472|	sc_format_asn1_entry(asn1_p15_obj + 1, obj->asn1_class_attr, NULL, 1);
 1481|    472|	if (obj->asn1_subclass_attr != NULL && obj->asn1_subclass_attr->name)
  ------------------
  |  Branch (1481:6): [True: 121, False: 351]
  |  Branch (1481:41): [True: 51, False: 70]
  ------------------
 1482|     51|		sc_format_asn1_entry(asn1_p15_obj + 2, obj->asn1_subclass_attr, NULL, 1);
 1483|    472|	sc_format_asn1_entry(asn1_p15_obj + 3, obj->asn1_type_attr, NULL, 1);
 1484|       |
 1485|    472|	r = asn1_encode(ctx, asn1_p15_obj, buf, bufsize, depth + 1);
 1486|    472|	return r;
 1487|    472|}
asn1.c:asn1_encode_se_info:
 1306|     16|{
 1307|     16|	unsigned char *ptr = NULL, *out = NULL, *p;
 1308|     16|	size_t ptrlen = 0, outlen = 0, idx;
 1309|     16|	int ret;
 1310|       |
 1311|     73|	for (idx=0; idx < se_num; idx++)   {
  ------------------
  |  Branch (1311:14): [True: 57, False: 16]
  ------------------
 1312|     57|		struct sc_asn1_entry asn1_se[2];
 1313|     57|		struct sc_asn1_entry asn1_se_info[4];
 1314|       |
 1315|     57|		sc_copy_asn1_entry(c_asn1_se, asn1_se);
 1316|     57|		sc_copy_asn1_entry(c_asn1_se_info, asn1_se_info);
 1317|       |
 1318|     57|		sc_format_asn1_entry(asn1_se_info + 0, &se[idx]->se, NULL, 1);
 1319|     57|		if (sc_valid_oid(&se[idx]->owner))
  ------------------
  |  Branch (1319:7): [True: 6, False: 51]
  ------------------
 1320|      6|			sc_format_asn1_entry(asn1_se_info + 1, &se[idx]->owner, NULL, 1);
 1321|     57|		if (se[idx]->aid.len)
  ------------------
  |  Branch (1321:7): [True: 45, False: 12]
  ------------------
 1322|     45|			sc_format_asn1_entry(asn1_se_info + 2, &se[idx]->aid.value, &se[idx]->aid.len, 1);
 1323|     57|		sc_format_asn1_entry(asn1_se + 0, asn1_se_info, NULL, 1);
 1324|       |
 1325|     57|		ret = sc_asn1_encode(ctx, asn1_se, &ptr, &ptrlen);
 1326|     57|		if (ret != SC_SUCCESS)
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  |  Branch (1326:7): [True: 0, False: 57]
  ------------------
 1327|      0|			goto err;
 1328|       |
 1329|     57|		if (!ptrlen)
  ------------------
  |  Branch (1329:7): [True: 0, False: 57]
  ------------------
 1330|      0|			continue;
 1331|     57|		p = (unsigned char *) realloc(out, outlen + ptrlen);
 1332|     57|		if (!p)   {
  ------------------
  |  Branch (1332:7): [True: 0, False: 57]
  ------------------
 1333|      0|			ret = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1334|      0|			goto err;
 1335|      0|		}
 1336|     57|		out = p;
 1337|     57|		memcpy(out + outlen, ptr, ptrlen);
 1338|     57|		outlen += ptrlen;
 1339|     57|		free(ptr);
 1340|     57|		ptr = NULL;
 1341|     57|		ptrlen = 0;
 1342|     57|	}
 1343|       |
 1344|     16|	*buf = out;
 1345|     16|	*bufsize = outlen;
 1346|     16|	ret = SC_SUCCESS;
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
 1347|     16|err:
 1348|     16|	if (ret != SC_SUCCESS && out != NULL)
  ------------------
  |  |   28|     32|#define SC_SUCCESS				0
  ------------------
  |  Branch (1348:6): [True: 0, False: 16]
  |  Branch (1348:27): [True: 0, False: 0]
  ------------------
 1349|      0|		free(out);
 1350|     16|	return ret;
 1351|     16|}

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

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

sc_get_atrust_acos_driver:
  814|  3.69k|{
  815|  3.69k|	return sc_get_driver();
  816|  3.69k|}
card-atrust-acos.c:sc_get_driver:
  789|  3.69k|{
  790|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  791|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (791:6): [True: 1, False: 3.69k]
  ------------------
  792|      1|		iso_ops = iso_drv->ops;
  793|       |
  794|  3.69k|	atrust_acos_ops = *iso_drv->ops;
  795|  3.69k|	atrust_acos_ops.match_card = atrust_acos_match_card;
  796|  3.69k|	atrust_acos_ops.init   = atrust_acos_init;
  797|  3.69k|	atrust_acos_ops.finish = atrust_acos_finish;
  798|  3.69k|	atrust_acos_ops.select_file = atrust_acos_select_file;
  799|  3.69k|	atrust_acos_ops.check_sw    = atrust_acos_check_sw;
  800|  3.69k|	atrust_acos_ops.create_file = NULL;
  801|  3.69k|	atrust_acos_ops.delete_file = NULL;
  802|  3.69k|	atrust_acos_ops.set_security_env  = atrust_acos_set_security_env;
  803|  3.69k|	atrust_acos_ops.compute_signature = atrust_acos_compute_signature;
  804|  3.69k|	atrust_acos_ops.decipher    = atrust_acos_decipher;
  805|  3.69k|	atrust_acos_ops.card_ctl    = atrust_acos_card_ctl;
  806|  3.69k|	atrust_acos_ops.logout      = atrust_acos_logout;
  807|       |
  808|  3.69k|	return &atrust_acos_drv;
  809|  3.69k|}
card-atrust-acos.c:atrust_acos_match_card:
   76|  3.69k|{
   77|  3.69k|	int		i, match = 0;
   78|       |
   79|       |
   80|  18.4k|	for (i = 0; atrust_acos_atrs[i] != NULL; i++)
  ------------------
  |  Branch (80:14): [True: 14.7k, False: 3.69k]
  ------------------
   81|  14.7k|	{
   82|  14.7k|		u8 defatr[SC_MAX_ATR_SIZE];
   83|  14.7k|		size_t len = sizeof(defatr);
   84|  14.7k|		const char *atrp = atrust_acos_atrs[i];
   85|       |
   86|  14.7k|		if (sc_hex_to_bin(atrp, defatr, &len))
  ------------------
  |  Branch (86:7): [True: 0, False: 14.7k]
  ------------------
   87|      0|			continue;
   88|       |		/* we may only verify part of ATR since */
   89|       |		/* part of the hist chars is variable */
   90|  14.7k|		if (len > card->atr.len)
  ------------------
  |  Branch (90:7): [True: 3.43k, False: 11.3k]
  ------------------
   91|  3.43k|			continue;
   92|  11.3k|		if (memcmp(card->atr.value, defatr, len) != 0)
  ------------------
  |  Branch (92:7): [True: 11.3k, False: 0]
  ------------------
   93|  11.3k|			continue;
   94|       |
   95|      0|		match = 1;
   96|      0|		card->name = atrust_acos_names[i];
   97|       |
   98|      0|		break;
   99|  11.3k|    }
  100|  3.69k|	return match;
  101|  3.69k|}

sc_get_authentic_driver:
 2168|  3.69k|{
 2169|  3.69k|	return sc_get_driver();
 2170|  3.69k|}
card-authentic.c:sc_get_driver:
 2133|  3.69k|{
 2134|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2135|       |
 2136|  3.69k|	if (!iso_ops)
  ------------------
  |  Branch (2136:6): [True: 1, False: 3.69k]
  ------------------
 2137|      1|		iso_ops = iso_drv->ops;
 2138|       |
 2139|  3.69k|	authentic_ops = *iso_ops;
 2140|       |
 2141|  3.69k|	authentic_ops.match_card = authentic_match_card;
 2142|  3.69k|	authentic_ops.init = authentic_init;
 2143|  3.69k|	authentic_ops.finish = authentic_finish;
 2144|  3.69k|	authentic_ops.read_binary = authentic_read_binary;
 2145|  3.69k|	authentic_ops.write_binary = authentic_write_binary;
 2146|  3.69k|	authentic_ops.update_binary = authentic_update_binary;
 2147|  3.69k|	authentic_ops.erase_binary = authentic_erase_binary;
 2148|       |	/* authentic_ops.resize_file = authentic_resize_file; */
 2149|  3.69k|	authentic_ops.select_file = authentic_select_file;
 2150|       |	/* get_response: Untested */
 2151|  3.69k|	authentic_ops.get_challenge = authentic_get_challenge;
 2152|  3.69k|	authentic_ops.set_security_env = authentic_set_security_env;
 2153|       |	/* decipher: Untested */
 2154|  3.69k|	authentic_ops.decipher = authentic_decipher;
 2155|       |	/* authentic_ops.compute_signature = authentic_compute_signature; */
 2156|  3.69k|	authentic_ops.create_file = authentic_create_file;
 2157|  3.69k|	authentic_ops.delete_file = authentic_delete_file;
 2158|  3.69k|	authentic_ops.card_ctl = authentic_card_ctl;
 2159|  3.69k|	authentic_ops.process_fci = authentic_process_fci;
 2160|  3.69k|	authentic_ops.pin_cmd = authentic_pin_cmd;
 2161|  3.69k|	authentic_ops.card_reader_lock_obtained = authentic_card_reader_lock_obtained;
 2162|       |
 2163|  3.69k|	return &authentic_drv;
 2164|  3.69k|}
card-authentic.c:authentic_match_card:
  390|  2.83k|{
  391|  2.83k|	struct sc_context *ctx = card->ctx;
  392|  2.83k|	int i;
  393|       |
  394|  2.83k|	sc_log_hex(ctx, "try to match card with ATR", card->atr.value, card->atr.len);
  ------------------
  |  |  129|  2.83k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  2.83k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  395|  2.83k|	i = _sc_match_atr(card, authentic_known_atrs, &card->type);
  396|  2.83k|	if (i < 0)   {
  ------------------
  |  Branch (396:6): [True: 2.70k, False: 130]
  ------------------
  397|  2.70k|		sc_log(ctx, "card not matched");
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
  398|  2.70k|		return 0;
  399|  2.70k|	}
  400|       |
  401|    130|	sc_log(ctx, "'%s' card matched", authentic_known_atrs[i].name);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  402|    130|	return 1;
  403|  2.83k|}
card-authentic.c:authentic_init:
  442|    130|{
  443|    130|	struct sc_context *ctx = card->ctx;
  444|    130|	int ii, rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|    130|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  445|       |
  446|    130|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    130|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    130|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    130|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    130|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 130]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  447|    130|	for(ii=0;authentic_known_atrs[ii].atr;ii++)   {
  ------------------
  |  Branch (447:11): [True: 130, False: 0]
  ------------------
  448|    130|		if (card->type == authentic_known_atrs[ii].type)   {
  ------------------
  |  Branch (448:7): [True: 130, False: 0]
  ------------------
  449|    130|			card->name = authentic_known_atrs[ii].name;
  450|    130|			card->flags = authentic_known_atrs[ii].flags;
  451|    130|			break;
  452|    130|		}
  453|    130|	}
  454|       |
  455|    130|	if (!authentic_known_atrs[ii].atr)
  ------------------
  |  Branch (455:6): [True: 0, False: 130]
  ------------------
  456|    130|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  457|       |
  458|    130|	card->cla  = 0x00;
  459|    130|	card->drv_data = (struct authentic_private_data *) calloc(1, sizeof(struct authentic_private_data));
  460|    130|	if (!card->drv_data)
  ------------------
  |  Branch (460:6): [True: 0, False: 130]
  ------------------
  461|    130|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  462|       |
  463|    130|	if (card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)
  ------------------
  |  Branch (463:6): [True: 130, False: 0]
  ------------------
  464|    130|		rv = authentic_init_oberthur_authentic_3_2(card);
  465|       |
  466|    130|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|    130|#define SC_SUCCESS				0
  ------------------
  |  Branch (466:6): [True: 20, False: 110]
  ------------------
  467|     20|		rv = authentic_get_serialnr(card, NULL);
  468|       |
  469|    130|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|    130|#define SC_SUCCESS				0
  ------------------
  |  Branch (469:6): [True: 4, False: 126]
  ------------------
  470|      4|		rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      4|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  471|       |
  472|       |	/* Free private data on error */
  473|    130|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    130|#define SC_SUCCESS				0
  ------------------
  |  Branch (473:6): [True: 4, False: 126]
  ------------------
  474|      4|		free(card->drv_data);
  475|      4|		card->drv_data = NULL;
  476|      4|	}
  477|    130|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4, False: 126]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  478|    130|}
card-authentic.c:authentic_init_oberthur_authentic_3_2:
  408|    130|{
  409|    130|	struct sc_context *ctx = card->ctx;
  410|    130|	unsigned int flags;
  411|    130|	int rv = 0;
  412|       |
  413|    130|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    130|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    130|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    130|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    130|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 130]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  414|       |
  415|    130|	flags = AUTHENTIC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   43|    130|#define AUTHENTIC_CARD_DEFAULT_FLAGS ( 0		\
  |  |   44|    130|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |  102|    130|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   45|    130|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  115|    130|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   46|    130|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  120|    130|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  118|    130|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|    130|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   47|    130|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  142|    130|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   48|    130|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  143|    130|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   49|    130|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  147|    130|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  416|       |
  417|    130|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  557|    130|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  418|    130|	card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|    130|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  419|    130|	card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  564|    130|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  420|       |
  421|    130|#ifdef ENABLE_SM
  422|    130|	card->sm_ctx.ops.open = authentic_sm_open;
  423|    130|	card->sm_ctx.ops.get_sm_apdu = authentic_sm_get_wrapped_apdu;
  424|    130|	card->sm_ctx.ops.free_sm_apdu = authentic_sm_free_wrapped_apdu;
  425|    130|#endif
  426|       |
  427|    130|	rv = iso7816_select_aid(card, aid_AuthentIC_3_2, sizeof(aid_AuthentIC_3_2), NULL, NULL);
  428|    130|	LOG_TEST_RET(ctx, rv, "AuthentIC application select error");
  ------------------
  |  |  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: 18, False: 112]
  |  |  |  |  ------------------
  |  |  |  |  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|    130|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  429|       |
  430|    112|	rv = authentic_select_mf(card, NULL);
  431|    112|	LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|    112|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    112|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    112|	int _ret = (r); \
  |  |  |  |  168|    112|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  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|    112|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|       |
  433|    110|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  434|    110|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  435|       |
  436|    110|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    110|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    110|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    110|	int _ret = r; \
  |  |  |  |  155|    110|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 110, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    110|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  157|    110|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    110|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    110|	return _ret; \
  |  |  |  |  163|    110|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  437|    110|}
card-authentic.c:authentic_select_mf:
  544|    112|{
  545|    112|	struct sc_context *ctx = card->ctx;
  546|    112|	struct sc_path mfpath;
  547|    112|	int rv;
  548|       |
  549|    112|	struct sc_apdu apdu;
  550|    112|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  551|       |
  552|    112|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    112|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    112|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    112|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    112|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  553|       |
  554|    112|	sc_format_path("3F00", &mfpath);
  555|    112|	mfpath.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|    112|#define SC_PATH_TYPE_PATH		2
  ------------------
  556|       |
  557|    112|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  292|    112|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  558|       |
  559|    112|	apdu.resp = rbuf;
  560|    112|	apdu.resplen = sizeof(rbuf);
  561|       |
  562|    112|	rv = sc_transmit_apdu(card, &apdu);
  563|    112|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    112|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    112|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    112|	int _ret = (r); \
  |  |  |  |  168|    112|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 112]
  |  |  |  |  ------------------
  |  |  |  |  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|    112|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|    112|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  565|    112|	LOG_TEST_RET(ctx, rv, "authentic_select_file() check SW failed");
  ------------------
  |  |  174|    112|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    112|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    112|	int _ret = (r); \
  |  |  |  |  168|    112|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  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|    112|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|       |
  567|    110|	rv = authentic_set_current_files(card, &mfpath, apdu.resp, apdu.resplen, file_out);
  568|    110|	LOG_TEST_RET(ctx, rv, "authentic_select_file() cannot set 'current_file'");
  ------------------
  |  |  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: 0, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  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|    110|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  569|       |
  570|    110|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    110|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    110|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    110|	int _ret = r; \
  |  |  |  |  155|    110|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 110, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    110|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  157|    110|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    110|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    110|	return _ret; \
  |  |  |  |  163|    110|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  571|    110|}
card-authentic.c:authentic_set_current_files:
  505|  4.89k|{
  506|  4.89k|	struct sc_context *ctx = card->ctx;
  507|  4.89k|	struct sc_file *file = NULL;
  508|  4.89k|	int rv;
  509|       |
  510|  4.89k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  4.89k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.89k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.89k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.89k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.89k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  511|  4.89k|	if (resplen)   {
  ------------------
  |  Branch (511:6): [True: 3.11k, False: 1.78k]
  ------------------
  512|  3.11k|		switch (resp[0]) {
  513|     11|		case 0x62:
  ------------------
  |  Branch (513:3): [True: 11, False: 3.10k]
  ------------------
  514|  2.74k|		case 0x6F:
  ------------------
  |  Branch (514:3): [True: 2.72k, False: 382]
  ------------------
  515|  2.74k|			file = sc_file_new();
  516|  2.74k|			if (file == NULL)
  ------------------
  |  Branch (516:8): [True: 0, False: 2.74k]
  ------------------
  517|  2.74k|				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|  2.74k|			if (path)
  ------------------
  |  Branch (518:8): [True: 2.74k, False: 0]
  ------------------
  519|  2.74k|				file->path = *path;
  520|       |
  521|  2.74k|			rv = authentic_process_fci(card, file, resp, resplen);
  522|  2.74k|			if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|  2.74k|#define SC_SUCCESS				0
  ------------------
  |  Branch (522:8): [True: 935, False: 1.80k]
  ------------------
  523|    935|				sc_file_free(file);
  524|    935|				LOG_TEST_RET(ctx, rv, "cannot set 'current file': FCI process error");
  ------------------
  |  |  174|    935|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    935|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    935|	int _ret = (r); \
  |  |  |  |  168|    935|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 935, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    935|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    935|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    935|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    935|		return _ret; \
  |  |  |  |  172|    935|	} \
  |  |  |  |  173|    935|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  525|    935|			}
  526|       |
  527|  1.80k|			break;
  528|  1.80k|		default:
  ------------------
  |  Branch (528:3): [True: 371, False: 2.74k]
  ------------------
  529|    371|			LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    371|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    371|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    371|	int _ret = r; \
  |  |  |  |  155|    371|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 371, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    371|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    371|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 371, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    371|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    371|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    371|	return _ret; \
  |  |  |  |  163|    371|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  530|  3.11k|		}
  531|       |
  532|  1.80k|		if (file_out)
  ------------------
  |  Branch (532:7): [True: 1.67k, False: 126]
  ------------------
  533|  1.67k|			*file_out = file;
  534|    126|		else
  535|    126|			sc_file_free(file);
  536|  1.80k|	}
  537|       |
  538|  3.59k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.59k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.59k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.59k|	int _ret = r; \
  |  |  |  |  155|  3.59k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.59k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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: 3.59k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.59k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.59k|	return _ret; \
  |  |  |  |  163|  3.59k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|  3.59k|}
card-authentic.c:authentic_get_serialnr:
 1475|     62|{
 1476|     62|	struct sc_context *ctx = card->ctx;
 1477|     62|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
 1478|     62|	int rv;
 1479|       |
 1480|     62|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1481|     62|	if (!card->serialnr.len)   {
  ------------------
  |  Branch (1481:6): [True: 55, False: 7]
  ------------------
 1482|     55|		rv = authentic_get_cplc(card);
 1483|     55|		LOG_TEST_RET(ctx, rv, "get CPLC data error");
  ------------------
  |  |  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: 16, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  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|     55|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1484|       |
 1485|     39|		card->serialnr.len = 4;
 1486|     39|		memcpy(card->serialnr.value, prv_data->cplc.value + 15, 4);
 1487|       |
 1488|     39|		sc_log(ctx, "serial %02X%02X%02X%02X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1489|     39|				card->serialnr.value[0], card->serialnr.value[1],
 1490|     39|				card->serialnr.value[2], card->serialnr.value[3]);
 1491|     39|	}
 1492|       |
 1493|     46|	if (serial)
  ------------------
  |  Branch (1493:6): [True: 30, False: 16]
  ------------------
 1494|     30|		memcpy(serial, &card->serialnr, sizeof(*serial));
 1495|       |
 1496|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1497|     46|}
card-authentic.c:authentic_get_cplc:
  360|     55|{
  361|     55|	struct authentic_private_data *prv_data = (struct authentic_private_data *) card->drv_data;
  362|     55|	struct sc_apdu apdu;
  363|     55|	int rv, ii;
  364|     55|	unsigned char p1, p2;
  365|       |
  366|     55|	p1 = (SC_CPLC_TAG >> 8) & 0xFF;
  ------------------
  |  |  345|     55|#define SC_CPLC_TAG		0x9F7F
  ------------------
  367|     55|	p2 = SC_CPLC_TAG & 0xFF;
  ------------------
  |  |  345|     55|#define SC_CPLC_TAG		0x9F7F
  ------------------
  368|     55|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, p1, p2);
  ------------------
  |  |  292|     55|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  369|     55|	for (ii=0;ii<2;ii++)   {
  ------------------
  |  Branch (369:12): [True: 55, False: 0]
  ------------------
  370|     55|		apdu.le = SC_CPLC_DER_SIZE;
  ------------------
  |  |  346|     55|#define SC_CPLC_DER_SIZE	45
  ------------------
  371|     55|		apdu.resplen = sizeof(prv_data->cplc.value);
  372|     55|		apdu.resp = prv_data->cplc.value;
  373|       |
  374|     55|		rv = sc_transmit_apdu(card, &apdu);
  375|     55|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  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: 1, False: 54]
  |  |  |  |  ------------------
  |  |  |  |  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|     55|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 54]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|     54|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  377|     54|		if (rv != SC_ERROR_CLASS_NOT_SUPPORTED)
  ------------------
  |  |   53|     54|#define SC_ERROR_CLASS_NOT_SUPPORTED		-1203
  ------------------
  |  Branch (377:7): [True: 54, False: 0]
  ------------------
  378|     54|			break;
  379|       |
  380|      0|		apdu.cla = 0x80;
  381|      0|	}
  382|     54|        LOG_TEST_RET(card->ctx, rv, "'GET CPLC' error");
  ------------------
  |  |  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: 15, False: 39]
  |  |  |  |  ------------------
  |  |  |  |  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|     54|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 39]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  383|       |
  384|     39|	prv_data->cplc.len = SC_CPLC_DER_SIZE;
  ------------------
  |  |  346|     39|#define SC_CPLC_DER_SIZE	45
  ------------------
  385|     39|	return SC_SUCCESS;
  ------------------
  |  |   28|     39|#define SC_SUCCESS				0
  ------------------
  386|     54|}
card-authentic.c:authentic_finish:
 1864|    126|{
 1865|    126|	struct sc_context *ctx = card->ctx;
 1866|       |
 1867|    126|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    126|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    126|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    126|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    126|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1868|       |
 1869|    126|#ifdef ENABLE_SM
 1870|    126|	if (card->sm_ctx.ops.close)
  ------------------
  |  Branch (1870:6): [True: 0, False: 126]
  ------------------
 1871|      0|		card->sm_ctx.ops.close(card);
 1872|    126|#endif
 1873|       |
 1874|    126|	if (card->drv_data)
  ------------------
  |  Branch (1874:6): [True: 126, False: 0]
  ------------------
 1875|    126|		free(card->drv_data);
 1876|    126|	card->drv_data = NULL;
 1877|    126|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1878|    126|}
card-authentic.c:authentic_read_binary:
  643|  1.53k|{
  644|  1.53k|	struct sc_context *ctx = card->ctx;
  645|  1.53k|	struct sc_apdu apdu;
  646|  1.53k|	size_t sz, rest, ret_count = 0;
  647|  1.53k|	int rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.53k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  648|       |
  649|  1.53k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.53k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.53k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.53k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.53k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.53k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|  1.53k|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  651|  1.53k|	       "offs:%i,count:%"SC_FORMAT_LEN_SIZE_T"u,max_recv_size:%"SC_FORMAT_LEN_SIZE_T"u",
  652|  1.53k|	       idx, count, card->max_recv_size);
  653|       |
  654|  1.53k|	rest = count;
  655|  5.76k|	while(rest)   {
  ------------------
  |  Branch (655:8): [True: 4.52k, False: 1.23k]
  ------------------
  656|  4.52k|		sz = rest > 256 ? 256 : rest;
  ------------------
  |  Branch (656:8): [True: 3.29k, False: 1.23k]
  ------------------
  657|  4.52k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  292|  4.52k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  658|  4.52k|		apdu.le = sz;
  659|  4.52k|		apdu.resplen = sz;
  660|  4.52k|		apdu.resp = (buf + ret_count);
  661|       |
  662|  4.52k|		rv = sc_transmit_apdu(card, &apdu);
  663|  4.52k|		if(!rv)
  ------------------
  |  Branch (663:6): [True: 4.23k, False: 298]
  ------------------
  664|  4.23k|			ret_count += apdu.resplen;
  665|    298|		else
  666|    298|			break;
  667|       |
  668|  4.23k|		idx += sz;
  669|  4.23k|		rest -= sz;
  670|  4.23k|	}
  671|       |
  672|  1.53k|	if (rv)   {
  ------------------
  |  Branch (672:6): [True: 298, False: 1.23k]
  ------------------
  673|    298|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "authentic_read_binary() failed");
  ------------------
  |  |  174|    298|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    298|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    298|	int _ret = (r); \
  |  |  |  |  168|    298|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 298, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    298|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    298|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    298|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    298|		return _ret; \
  |  |  |  |  172|    298|	} \
  |  |  |  |  173|    298|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  674|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  675|      0|	}
  676|       |
  677|  1.23k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  678|  1.23k|	if (!rv)
  ------------------
  |  Branch (678:6): [True: 391, False: 845]
  ------------------
  679|    391|		count = ret_count;
  680|       |
  681|  1.23k|	LOG_TEST_RET(ctx, rv, "authentic_read_binary() 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: 845, False: 391]
  |  |  |  |  ------------------
  |  |  |  |  169|    845|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    845|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    845|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    845|		return _ret; \
  |  |  |  |  172|    845|	} \
  |  |  |  |  173|  1.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 391]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  682|    391|	LOG_FUNC_RETURN(ctx, (int)count);
  ------------------
  |  |  164|    391|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    391|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    391|	int _ret = r; \
  |  |  |  |  155|    391|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 35, False: 356]
  |  |  |  |  ------------------
  |  |  |  |  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|    356|	} else { \
  |  |  |  |  159|    356|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    356|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    356|	} \
  |  |  |  |  162|    391|	return _ret; \
  |  |  |  |  163|    391|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  683|    391|}
card-authentic.c:authentic_update_binary:
  732|      6|{
  733|      6|	struct sc_context *ctx = card->ctx;
  734|      6|	struct sc_apdu apdu;
  735|      6|	size_t sz, rest;
  736|      6|	int rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      6|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  737|       |
  738|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  739|      6|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  740|      6|	       "offs:%i,count:%"SC_FORMAT_LEN_SIZE_T"u,max_send_size:%"SC_FORMAT_LEN_SIZE_T"u",
  741|      6|	       idx, count, card->max_send_size);
  742|       |
  743|      6|	rest = count;
  744|     12|	while(rest)   {
  ------------------
  |  Branch (744:8): [True: 6, False: 6]
  ------------------
  745|      6|		sz = rest > 255 ? 255 : rest;
  ------------------
  |  Branch (745:8): [True: 0, False: 6]
  ------------------
  746|      6|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  293|      6|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  747|      6|		apdu.lc = sz;
  748|      6|		apdu.datalen = sz;
  749|      6|		apdu.data = buf + count - rest;
  750|       |
  751|      6|		rv = sc_transmit_apdu(card, &apdu);
  752|      6|		if(rv)
  ------------------
  |  Branch (752:6): [True: 0, False: 6]
  ------------------
  753|      0|			break;
  754|       |
  755|      6|		idx += sz;
  756|      6|		rest -= sz;
  757|      6|	}
  758|       |
  759|      6|	if (rv)
  ------------------
  |  Branch (759:6): [True: 0, False: 6]
  ------------------
  760|      0|	{
  761|      0|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "authentic_update_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  762|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  763|      0|	}
  764|       |
  765|      6|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  766|       |
  767|      6|	LOG_TEST_RET(ctx, rv, "authentic_update_binary() 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: 4, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  768|      2|	LOG_FUNC_RETURN(ctx, (int)count);
  ------------------
  |  |  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: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|      2|}
card-authentic.c:authentic_erase_binary:
  482|      5|{
  483|      5|	struct sc_context *ctx = card->ctx;
  484|      5|	int rv;
  485|      5|	unsigned char *buf_zero = NULL;
  486|       |
  487|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|      5|	if (!count)
  ------------------
  |  Branch (488:6): [True: 0, False: 5]
  ------------------
  489|      5|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "'ERASE BINARY' with ZERO count 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  490|       |
  491|      5|	buf_zero = calloc(1, count);
  492|      5|	if (!buf_zero)
  ------------------
  |  Branch (492:6): [True: 0, False: 5]
  ------------------
  493|      5|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "cannot allocate buff 'zero'");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|       |
  495|      5|	rv = sc_update_binary(card, offs, buf_zero, count, flags);
  496|      5|	free(buf_zero);
  497|       |
  498|      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: 3, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      2|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      2|	} \
  |  |  |  |  162|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  499|      5|}
card-authentic.c:authentic_select_file:
  576|  55.9k|{
  577|  55.9k|	struct sc_context *ctx = card->ctx;
  578|  55.9k|	struct sc_apdu apdu;
  579|  55.9k|	struct sc_path lpath;
  580|  55.9k|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  581|  55.9k|	size_t pathlen;
  582|  55.9k|	int rv;
  583|       |
  584|  55.9k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  55.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  55.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  55.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  55.9k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 55.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|       |
  586|  55.9k|	memcpy(&lpath, path, sizeof(struct sc_path));
  587|       |
  588|  55.9k|	if (lpath.type == SC_PATH_TYPE_PATH && (lpath.len == 2))
  ------------------
  |  |  119|   111k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (588:6): [True: 55.0k, False: 950]
  |  Branch (588:41): [True: 31, False: 54.9k]
  ------------------
  589|     31|		lpath.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     31|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  590|       |
  591|  55.9k|	pathlen = lpath.len;
  592|  55.9k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  55.9k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  593|       |
  594|  55.9k|	if (card->type != SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)
  ------------------
  |  Branch (594:6): [True: 0, False: 55.9k]
  ------------------
  595|  55.9k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  596|       |
  597|  55.9k|	if (lpath.type == SC_PATH_TYPE_FILE_ID)   {
  ------------------
  |  |  117|  55.9k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (597:6): [True: 668, False: 55.2k]
  ------------------
  598|    668|		apdu.p1 = 0x00;
  599|    668|	}
  600|  55.2k|	else if (lpath.type == SC_PATH_TYPE_PATH)  {
  ------------------
  |  |  119|  55.2k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (600:11): [True: 54.9k, False: 313]
  ------------------
  601|  54.9k|		apdu.p1 = 0x08;
  602|  54.9k|	}
  603|    313|	else if (lpath.type == SC_PATH_TYPE_FROM_CURRENT)  {
  ------------------
  |  |  122|    313|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (603:11): [True: 0, False: 313]
  ------------------
  604|      0|		apdu.p1 = 0x09;
  605|      0|	}
  606|    313|	else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|    313|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (606:11): [True: 313, False: 0]
  ------------------
  607|    313|		apdu.p1 = 4;
  608|    313|	}
  609|      0|	else if (lpath.type == SC_PATH_TYPE_PARENT)   {
  ------------------
  |  |  123|      0|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (609:11): [True: 0, False: 0]
  ------------------
  610|      0|		apdu.p1 = 0x03;
  611|      0|		pathlen = 0;
  612|      0|		apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  613|      0|	}
  614|      0|	else   {
  615|      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__
  |  |  ------------------
  ------------------
  616|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|      0|	}
  618|       |
  619|  55.9k|	apdu.lc = pathlen;
  620|  55.9k|	apdu.data = lpath.value;
  621|  55.9k|	apdu.datalen = pathlen;
  622|       |
  623|  55.9k|	if (apdu.cse == SC_APDU_CASE_4_SHORT || apdu.cse == SC_APDU_CASE_2_SHORT)   {
  ------------------
  |  |  294|   111k|#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 (623:6): [True: 55.9k, False: 0]
  |  Branch (623:42): [True: 0, False: 0]
  ------------------
  624|  55.9k|		apdu.resp = rbuf;
  625|  55.9k|		apdu.resplen = sizeof(rbuf);
  626|  55.9k|		apdu.le = 256;
  627|  55.9k|	}
  628|       |
  629|  55.9k|	rv = sc_transmit_apdu(card, &apdu);
  630|  55.9k|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  55.9k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  55.9k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  55.9k|	int _ret = (r); \
  |  |  |  |  168|  55.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.95k, False: 54.0k]
  |  |  |  |  ------------------
  |  |  |  |  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|  55.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 54.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|  54.0k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  632|  54.0k|	LOG_TEST_RET(ctx, rv, "authentic_select_file() check SW failed");
  ------------------
  |  |  174|  54.0k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  54.0k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  54.0k|	int _ret = (r); \
  |  |  |  |  168|  54.0k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 49.2k, False: 4.78k]
  |  |  |  |  ------------------
  |  |  |  |  169|  49.2k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.2k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  49.2k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  49.2k|		return _ret; \
  |  |  |  |  172|  49.2k|	} \
  |  |  |  |  173|  54.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|       |
  634|  4.78k|	rv = authentic_set_current_files(card, &lpath, apdu.resp, apdu.resplen, file_out);
  635|  4.78k|	LOG_TEST_RET(ctx, rv, "authentic_select_file() cannot set 'current_file'");
  ------------------
  |  |  174|  4.78k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.78k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.78k|	int _ret = (r); \
  |  |  |  |  168|  4.78k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.30k, False: 3.48k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.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|  1.30k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.30k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.30k|		return _ret; \
  |  |  |  |  172|  1.30k|	} \
  |  |  |  |  173|  4.78k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|       |
  637|  3.48k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.48k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.48k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.48k|	int _ret = r; \
  |  |  |  |  155|  3.48k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.48k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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: 3.48k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.48k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.48k|	return _ret; \
  |  |  |  |  163|  3.48k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|  3.48k|}
card-authentic.c:authentic_get_challenge:
 1502|     14|{
 1503|       |	/* 'GET CHALLENGE' returns always 24 bytes */
 1504|     14|	unsigned char rbuf[0x18];
 1505|     14|	size_t out_len;
 1506|     14|	int r;
 1507|       |
 1508|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1509|       |
 1510|     14|	r = iso_ops->get_challenge(card, rbuf, sizeof rbuf);
 1511|     14|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE cmd 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1512|       |
 1513|     11|	if (len < (size_t) r) {
  ------------------
  |  Branch (1513:6): [True: 1, False: 10]
  ------------------
 1514|      1|		out_len = len;
 1515|     10|	} else {
 1516|     10|		out_len = (size_t) r;
 1517|     10|	}
 1518|     11|	memcpy(rnd, rbuf, out_len);
 1519|       |
 1520|     11|	LOG_FUNC_RETURN(card->ctx, (int)out_len);
  ------------------
  |  |  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: 1, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|	} else { \
  |  |  |  |  159|     10|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     10|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     10|	} \
  |  |  |  |  162|     11|	return _ret; \
  |  |  |  |  163|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1521|     11|}
card-authentic.c:authentic_create_file:
  912|      6|{
  913|      6|	struct sc_context *ctx = card->ctx;
  914|      6|	struct sc_apdu apdu;
  915|      6|	unsigned char sbuf[0x100];
  916|      6|	size_t sbuf_len;
  917|      6|	struct sc_path path;
  918|      6|	int rv;
  919|       |
  920|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  921|       |
  922|      6|	if (file->type != SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|      6|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (922:6): [True: 1, False: 5]
  ------------------
  923|      6|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Creation of the file with of this type is not 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  924|       |
  925|      5|	rv = authentic_fcp_encode(card, file, sbuf + 2, sizeof(sbuf)-2);
  926|      5|	LOG_TEST_RET(ctx, rv, "FCP encode error");
  ------------------
  |  |  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: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  927|      5|	sbuf_len = rv;
  928|       |
  929|      5|	sbuf[0] = ISO7816_TAG_FCP;
  ------------------
  |  |   17|      5|#define ISO7816_TAG_FCP			0x62
  ------------------
  930|      5|	sbuf[1] = sbuf_len;
  931|       |
  932|      5|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0, 0);
  ------------------
  |  |  293|      5|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  933|      5|	apdu.data = sbuf;
  934|      5|	apdu.datalen = sbuf_len + 2;
  935|      5|	apdu.lc = sbuf_len + 2;
  936|       |
  937|      5|	rv = sc_transmit_apdu(card, &apdu);
  938|      5|	LOG_TEST_RET(ctx, rv, "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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  939|      4|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  940|      4|	LOG_TEST_RET(ctx, rv, "authentic_create_file() create file error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  941|       |
  942|      1|	path = file->path;
  943|      1|	memcpy(path.value, path.value + path.len - 2, 2);
  944|      1|	path.len = 2;
  945|      1|	rv = authentic_set_current_files(card, &path, sbuf, sbuf_len + 2, NULL);
  946|      1|	LOG_TEST_RET(ctx, rv, "authentic_select_file() cannot set 'current_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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  947|       |
  948|      1|	LOG_FUNC_RETURN(ctx, 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  949|      1|}
card-authentic.c:authentic_fcp_encode:
  846|      5|{
  847|      5|	struct sc_context *ctx = card->ctx;
  848|      5|	unsigned char buf[0x80];
  849|      5|	size_t ii, offs;
  850|      5|	unsigned char ops_ef[4] = { SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE };
  ------------------
  |  |  188|      5|#define SC_AC_OP_READ			22
  ------------------
              	unsigned char ops_ef[4] = { SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE };
  ------------------
  |  |  168|      5|#define SC_AC_OP_DELETE			2
  ------------------
              	unsigned char ops_ef[4] = { SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE };
  ------------------
  |  |  189|      5|#define SC_AC_OP_UPDATE			23
  ------------------
              	unsigned char ops_ef[4] = { SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE };
  ------------------
  |  |  191|      5|#define SC_AC_OP_RESIZE			25
  ------------------
  851|      5|	unsigned char ops_df[3] = { SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO };
  ------------------
  |  |  169|      5|#define SC_AC_OP_CREATE			3
  ------------------
              	unsigned char ops_df[3] = { SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO };
  ------------------
  |  |  168|      5|#define SC_AC_OP_DELETE			2
  ------------------
              	unsigned char ops_df[3] = { SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO };
  ------------------
  |  |  173|      5|#define SC_AC_OP_CRYPTO			7
  ------------------
  852|      5|	unsigned char *ops = file->type == SC_FILE_TYPE_DF ? ops_df : ops_ef;
  ------------------
  |  |  214|      5|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (852:23): [True: 0, False: 5]
  ------------------
  853|      5|	size_t ops_len = file->type == SC_FILE_TYPE_DF ? 3 : 4;
  ------------------
  |  |  214|      5|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (853:19): [True: 0, False: 5]
  ------------------
  854|       |
  855|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  856|       |
  857|      5|	offs = 0;
  858|      5|	buf[offs++] = ISO7816_TAG_FCP_SIZE;
  ------------------
  |  |   18|      5|#define ISO7816_TAG_FCP_SIZE		0x80
  ------------------
  859|      5|	buf[offs++] = 2;
  860|      5|	buf[offs++] = (file->size >> 8) & 0xFF;
  861|      5|	buf[offs++] = file->size & 0xFF;
  862|       |
  863|      5|	buf[offs++] = ISO7816_TAG_FCP_TYPE;
  ------------------
  |  |   20|      5|#define ISO7816_TAG_FCP_TYPE		0x82
  ------------------
  864|      5|	buf[offs++] = 1;
  865|      5|	buf[offs++] = file->type == SC_FILE_TYPE_DF ? ISO7816_FILE_TYPE_DF : ISO7816_FILE_TYPE_TRANSPARENT_EF;
  ------------------
  |  |  214|      5|#define SC_FILE_TYPE_DF			0x04
  ------------------
              	buf[offs++] = file->type == SC_FILE_TYPE_DF ? ISO7816_FILE_TYPE_DF : ISO7816_FILE_TYPE_TRANSPARENT_EF;
  ------------------
  |  |   13|      0|#define ISO7816_FILE_TYPE_DF			0x38
  ------------------
              	buf[offs++] = file->type == SC_FILE_TYPE_DF ? ISO7816_FILE_TYPE_DF : ISO7816_FILE_TYPE_TRANSPARENT_EF;
  ------------------
  |  |   12|     10|#define ISO7816_FILE_TYPE_TRANSPARENT_EF	0x01
  ------------------
  |  Branch (865:16): [True: 0, False: 5]
  ------------------
  866|       |
  867|      5|	buf[offs++] = ISO7816_TAG_FCP_FID;
  ------------------
  |  |   21|      5|#define ISO7816_TAG_FCP_FID		0x83
  ------------------
  868|      5|	buf[offs++] = 2;
  869|      5|	buf[offs++] = (file->id >> 8) & 0xFF;
  870|      5|	buf[offs++] = file->id & 0xFF;
  871|       |
  872|      5|	buf[offs++] = ISO7816_TAG_FCP_ACLS;
  ------------------
  |  |   24|      5|#define ISO7816_TAG_FCP_ACLS		0x86
  ------------------
  873|      5|	buf[offs++] = ops_len * 2;
  874|     25|	for (ii=0; ii < ops_len; ii++) {
  ------------------
  |  Branch (874:13): [True: 20, False: 5]
  ------------------
  875|     20|		const struct sc_acl_entry *entry;
  876|       |
  877|     20|		entry = sc_file_get_acl_entry(file, ops[ii]);
  878|     20|		sc_log(ctx, "acl entry(method:%X,ref:%X)", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  879|       |
  880|     20|		if (entry->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|     20|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (880:7): [True: 7, False: 13]
  ------------------
  881|       |			/* TODO: After development change for 0xFF */
  882|      7|			buf[offs++] = 0x00;
  883|      7|			buf[offs++] = 0x00;
  884|      7|		}
  885|     13|		else if (entry->method == SC_AC_NONE)   {
  ------------------
  |  |  150|     13|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (885:12): [True: 13, False: 0]
  ------------------
  886|     13|			buf[offs++] = 0x00;
  887|     13|			buf[offs++] = 0x00;
  888|     13|		}
  889|      0|		else if (entry->method == SC_AC_CHV)   {
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (889:12): [True: 0, False: 0]
  ------------------
  890|      0|			if (!(entry->key_ref & AUTHENTIC_V3_CREDENTIAL_ID_MASK)
  ------------------
  |  |   38|      0|#define AUTHENTIC_V3_CREDENTIAL_ID_MASK	7
  ------------------
  |  Branch (890:8): [True: 0, False: 0]
  ------------------
  891|      0|					|| (entry->key_ref & ~AUTHENTIC_V3_CREDENTIAL_ID_MASK))
  ------------------
  |  |   38|      0|#define AUTHENTIC_V3_CREDENTIAL_ID_MASK	7
  ------------------
  |  Branch (891:9): [True: 0, False: 0]
  ------------------
  892|      0|				LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported Credential Reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  893|      0|			buf[offs++] = 0x00;
  894|      0|			buf[offs++] = 0x01 << (entry->key_ref - 1);
  895|      0|		}
  896|      0|		else
  897|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported AC method");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  898|     20|	}
  899|       |
  900|      5|	if (out)   {
  ------------------
  |  Branch (900:6): [True: 5, False: 0]
  ------------------
  901|      5|		if (out_len < offs)
  ------------------
  |  Branch (901:7): [True: 0, False: 5]
  ------------------
  902|      5|			LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "Buffer too small to encode FCP");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  903|      5|		memcpy(out, buf, offs);
  904|      5|	}
  905|       |
  906|      5|	LOG_FUNC_RETURN(ctx, (int)offs);
  ------------------
  |  |  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: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      5|	} else { \
  |  |  |  |  159|      5|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      5|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      5|	} \
  |  |  |  |  162|      5|	return _ret; \
  |  |  |  |  163|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  907|      5|}
card-authentic.c:authentic_delete_file:
  954|      1|{
  955|      1|	struct sc_context *ctx = card->ctx;
  956|      1|	struct sc_apdu apdu;
  957|      1|	unsigned char p1;
  958|      1|	int rv, ii;
  959|       |
  960|      1|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  961|       |
  962|      1|	if (!path)
  ------------------
  |  Branch (962:6): [True: 0, False: 1]
  ------------------
  963|      1|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  964|       |
  965|      1|	for (ii=0, p1 = 0x02; ii<2; ii++, p1 = 0x01)   {
  ------------------
  |  Branch (965:24): [True: 1, False: 0]
  ------------------
  966|      1|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, p1, 0x00);
  ------------------
  |  |  293|      1|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  967|      1|		apdu.data = path->value + path->len - 2;
  968|      1|		apdu.datalen = 2;
  969|      1|		apdu.lc = 2;
  970|       |
  971|      1|		rv = sc_transmit_apdu(card, &apdu);
  972|      1|		LOG_TEST_RET(ctx, rv, "APDU transmit 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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  973|      1|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  974|      1|		if (rv != SC_ERROR_FILE_NOT_FOUND || p1 != 0x02)
  ------------------
  |  |   51|      2|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (974:7): [True: 1, False: 0]
  |  Branch (974:40): [True: 0, False: 0]
  ------------------
  975|      1|			break;
  976|      1|	}
  977|      1|	LOG_TEST_RET(ctx, rv, "Delete file 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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  978|       |
  979|      1|	LOG_FUNC_RETURN(ctx, 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  980|      1|}
card-authentic.c:authentic_card_ctl:
 1753|    174|{
 1754|    174|	struct sc_context *ctx = card->ctx;
 1755|    174|	struct sc_authentic_sdo *sdo = (struct sc_authentic_sdo *) ptr;
 1756|       |
 1757|    174|	switch (cmd) {
  ------------------
  |  Branch (1757:10): [True: 42, False: 132]
  ------------------
 1758|     42|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1758:2): [True: 42, False: 132]
  ------------------
 1759|     42|		return authentic_get_serialnr(card, (struct sc_serial_number *)ptr);
 1760|      0|	case SC_CARDCTL_AUTHENTIC_SDO_CREATE:
  ------------------
  |  Branch (1760:2): [True: 0, False: 174]
  ------------------
 1761|      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__
  |  |  ------------------
  ------------------
 1762|      0|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1763|      0|	case SC_CARDCTL_AUTHENTIC_SDO_DELETE:
  ------------------
  |  Branch (1763:2): [True: 0, False: 174]
  ------------------
 1764|      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__
  |  |  ------------------
  ------------------
 1765|      0|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1766|      0|	case SC_CARDCTL_AUTHENTIC_SDO_STORE:
  ------------------
  |  Branch (1766:2): [True: 0, False: 174]
  ------------------
 1767|      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__
  |  |  ------------------
  ------------------
 1768|      0|		return authentic_manage_sdo(card, (struct sc_authentic_sdo *) ptr, cmd);
 1769|      0|	case SC_CARDCTL_AUTHENTIC_SDO_GENERATE:
  ------------------
  |  Branch (1769:2): [True: 0, False: 174]
  ------------------
 1770|      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__
  |  |  ------------------
  ------------------
 1771|      0|		return authentic_manage_sdo_generate(card, (struct sc_authentic_sdo *) ptr);
 1772|    174|	}
 1773|    132|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    132|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1774|    174|}
card-authentic.c:authentic_get_tagged_data:
  177|     45|{
  178|     45|	size_t size_len, tag_len, offs, size;
  179|     45|	int rv;
  180|     45|	unsigned tag;
  181|       |
  182|     45|	if (!out || !out_len)
  ------------------
  |  Branch (182:6): [True: 0, False: 45]
  |  Branch (182:14): [True: 0, False: 45]
  ------------------
  183|     45|		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|    280|	for (offs = 0; offs < in_len; )   {
  ------------------
  |  Branch (185:17): [True: 278, False: 2]
  ------------------
  186|    278|		if ((*(in + offs) == 0x7F) || (*(in + offs) == 0x5F))   {
  ------------------
  |  Branch (186:7): [True: 0, False: 278]
  |  Branch (186:33): [True: 8, False: 270]
  ------------------
  187|      8|			if (offs + 1 >= in_len)
  ------------------
  |  Branch (187:8): [True: 0, False: 8]
  ------------------
  188|      8|				LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|      8|			tag = *(in + offs) * 0x100 + *(in + offs + 1);
  190|      8|			tag_len = 2;
  191|      8|		}
  192|    270|		else   {
  193|    270|			tag = *(in + offs);
  194|    270|			tag_len = 1;
  195|    270|		}
  196|       |
  197|    278|		if (offs + tag_len >= in_len)
  ------------------
  |  Branch (197:7): [True: 2, False: 276]
  ------------------
  198|    278|			LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse error: invalid data");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|       |
  200|    276|		rv = authentic_parse_size(in + offs + tag_len, in_len - (offs + tag_len), &size);
  201|    276|		LOG_TEST_RET(ctx, rv, "parse error: invalid size data");
  ------------------
  |  |  174|    276|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    276|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    276|	int _ret = (r); \
  |  |  |  |  168|    276|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 17, False: 259]
  |  |  |  |  ------------------
  |  |  |  |  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|    276|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 259]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|    259|		size_len = rv;
  203|       |
  204|    259|		if (tag == in_tag)   {
  ------------------
  |  Branch (204:7): [True: 24, False: 235]
  ------------------
  205|     24|			if (in_len - (offs + tag_len + size_len) < size)
  ------------------
  |  Branch (205:8): [True: 0, False: 24]
  ------------------
  206|     24|				LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "parse 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|       |
  208|     24|			*out = in + offs + tag_len + size_len;
  209|     24|			*out_len = size;
  210|       |
  211|     24|			return SC_SUCCESS;
  ------------------
  |  |   28|     24|#define SC_SUCCESS				0
  ------------------
  212|     24|		}
  213|       |
  214|    235|		offs += tag_len + size_len + size;
  215|    235|	}
  216|       |
  217|      2|	return SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|      2|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
  218|     45|}
card-authentic.c:authentic_parse_size:
  149|    276|{
  150|    276|	if (!in || !out || in_len < 1)
  ------------------
  |  Branch (150:6): [True: 0, False: 276]
  |  Branch (150:13): [True: 0, False: 276]
  |  Branch (150:21): [True: 0, False: 276]
  ------------------
  151|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  152|       |
  153|    276|	if (*in < 0x80)   {
  ------------------
  |  Branch (153:6): [True: 258, False: 18]
  ------------------
  154|    258|		*out = *in;
  155|    258|		return 1;
  156|    258|	}
  157|     18|	else if (*in == 0x81)   {
  ------------------
  |  Branch (157:11): [True: 0, False: 18]
  ------------------
  158|      0|		if (in_len < 2)
  ------------------
  |  Branch (158:7): [True: 0, False: 0]
  ------------------
  159|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  160|      0|		*out = *(in + 1);
  161|      0|		return 2;
  162|      0|	}
  163|     18|	else if (*in == 0x82)   {
  ------------------
  |  Branch (163:11): [True: 1, False: 17]
  ------------------
  164|      1|		if (in_len < 3)
  ------------------
  |  Branch (164:7): [True: 0, False: 1]
  ------------------
  165|      0|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  166|      1|		*out = *(in + 1) * 0x100 + *(in + 2);
  167|      1|		return 3;
  168|      1|	}
  169|       |
  170|     17|	return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     17|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  171|    276|}
card-authentic.c:authentic_process_fci:
  775|  2.74k|{
  776|  2.74k|	struct sc_context *ctx = card->ctx;
  777|  2.74k|	size_t taglen;
  778|  2.74k|	int rv;
  779|  2.74k|	unsigned ii;
  780|  2.74k|	const unsigned char *tag = NULL;
  781|  2.74k|	unsigned char ops_DF[8] = {
  782|  2.74k|		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  169|  2.74k|#define SC_AC_OP_CREATE			3
  ------------------
              		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  168|  2.74k|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_CREATE, SC_AC_OP_DELETE, SC_AC_OP_CRYPTO, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  173|  2.74k|#define SC_AC_OP_CRYPTO			7
  ------------------
  783|  2.74k|	};
  784|  2.74k|	unsigned char ops_EF[8] = {
  785|  2.74k|		SC_AC_OP_READ, SC_AC_OP_DELETE, SC_AC_OP_UPDATE, SC_AC_OP_RESIZE, 0xFF, 0xFF, 0xFF, 0xFF
  ------------------
  |  |  188|  2.74k|#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|  2.74k|#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|  2.74k|#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|  2.74k|#define SC_AC_OP_RESIZE			25
  ------------------
  786|  2.74k|	};
  787|       |
  788|  2.74k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.74k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.74k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.74k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.74k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  789|       |
  790|  2.74k|	tag = sc_asn1_find_tag(card->ctx,  buf, buflen, 0x6F, &taglen);
  791|  2.74k|	if (tag != NULL) {
  ------------------
  |  Branch (791:6): [True: 2.68k, False: 59]
  ------------------
  792|  2.68k|		sc_log(ctx, "  FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
  ------------------
  |  |   71|  2.68k|#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|  2.68k|		buf = tag;
  794|  2.68k|		buflen = taglen;
  795|  2.68k|	}
  796|       |
  797|  2.74k|	tag = sc_asn1_find_tag(card->ctx,  buf, buflen, 0x62, &taglen);
  798|  2.74k|	if (tag != NULL) {
  ------------------
  |  Branch (798:6): [True: 10, False: 2.73k]
  ------------------
  799|     10|		sc_log(ctx, "  FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  800|     10|		buf = tag;
  801|     10|		buflen = taglen;
  802|     10|	}
  803|       |
  804|  2.74k|	rv = iso_ops->process_fci(card, file, buf, buflen);
  805|  2.74k|	LOG_TEST_RET(ctx, rv, "ISO parse FCI failed");
  ------------------
  |  |  174|  2.74k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.74k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.74k|	int _ret = (r); \
  |  |  |  |  168|  2.74k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.74k]
  |  |  |  |  ------------------
  |  |  |  |  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.74k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  806|       |
  807|  2.74k|	if (!file->sec_attr_len)   {
  ------------------
  |  Branch (807:6): [True: 1.17k, False: 1.56k]
  ------------------
  808|  1.17k|		sc_log_hex(ctx, "ACLs not found in data", buf, buflen);
  ------------------
  |  |  129|  1.17k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  1.17k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|  1.17k|		sc_log(ctx, "Path:%s; Type:%X; PathType:%X", sc_print_path(&file->path), file->type, file->path.type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  810|  1.17k|		if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  118|  2.35k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
              		if (file->path.type == SC_PATH_TYPE_DF_NAME || file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  214|  1.17k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (810:7): [True: 7, False: 1.17k]
  |  Branch (810:50): [True: 236, False: 935]
  ------------------
  811|    243|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    243|#define SC_FILE_TYPE_DF			0x04
  ------------------
  812|    243|		}
  813|    935|		else   {
  814|    935|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "ACLs tag missing");
  ------------------
  |  |  174|    935|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    935|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    935|	int _ret = (r); \
  |  |  |  |  168|    935|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 935, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    935|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    935|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    935|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    935|		return _ret; \
  |  |  |  |  172|    935|	} \
  |  |  |  |  173|    935|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  815|    935|		}
  816|  1.17k|	}
  817|       |
  818|  1.80k|	sc_log_hex(ctx, "ACL data", file->sec_attr, file->sec_attr_len);
  ------------------
  |  |  129|  1.80k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  1.80k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  819|  9.90k|	for (ii = 0; ii < file->sec_attr_len / 2 && ii < sizeof ops_DF; ii++)  {
  ------------------
  |  Branch (819:15): [True: 8.98k, False: 917]
  |  Branch (819:46): [True: 8.09k, False: 888]
  ------------------
  820|  8.09k|		unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
  ------------------
  |  |  214|  8.09k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (820:22): [True: 809, False: 7.28k]
  ------------------
  821|  8.09k|		unsigned char acl = *(file->sec_attr + ii*2);
  822|  8.09k|		unsigned char cred_id = *(file->sec_attr + ii*2 + 1);
  823|  8.09k|		unsigned sc = acl * 0x100 + cred_id;
  824|       |
  825|  8.09k|		sc_log(ctx, "ACL(%i) op 0x%X, acl %X:%X", ii, op, acl, cred_id);
  ------------------
  |  |   71|  8.09k|#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|  8.09k|		if (op == 0xFF)
  ------------------
  |  Branch (826:7): [True: 3.59k, False: 4.49k]
  ------------------
  827|  3.59k|			;
  828|  4.49k|		else if (!acl && !cred_id)
  ------------------
  |  Branch (828:12): [True: 371, False: 4.12k]
  |  Branch (828:20): [True: 46, False: 325]
  ------------------
  829|     46|			sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|     46|#define SC_AC_NONE			0x00000000
  ------------------
  830|  4.45k|		else if (acl == 0xFF)
  ------------------
  |  Branch (830:12): [True: 332, False: 4.11k]
  ------------------
  831|    332|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    332|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  832|  4.11k|		else if (acl & AUTHENTIC_AC_SM_MASK)
  ------------------
  |  |  119|  4.11k|#define AUTHENTIC_AC_SM_MASK	0x60
  ------------------
  |  Branch (832:12): [True: 3.21k, False: 900]
  ------------------
  833|  3.21k|			sc_file_add_acl_entry(file, op, SC_AC_SCB, sc);
  ------------------
  |  |  157|  3.21k|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  834|    900|		else if (cred_id)
  ------------------
  |  Branch (834:12): [True: 689, False: 211]
  ------------------
  835|    689|			sc_file_add_acl_entry(file, op, SC_AC_CHV, cred_id);
  ------------------
  |  |  151|    689|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  836|    211|		else
  837|    211|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    211|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  838|  8.09k|	}
  839|       |
  840|  1.80k|	LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  164|  1.80k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.80k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.80k|	int _ret = r; \
  |  |  |  |  155|  1.80k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.80k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.80k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.80k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.80k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.80k|	} else { \
  |  |  |  |  159|      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.80k|	return _ret; \
  |  |  |  |  163|  1.80k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  841|  1.80k|}
card-authentic.c:authentic_pin_cmd:
 1443|     32|{
 1444|     32|	struct sc_context *ctx = card->ctx;
 1445|     32|	int rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     32|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1446|       |
 1447|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1448|     32|	sc_log(ctx, "PIN-CMD:%X,PIN(type:%X,ret:%i)", data->cmd, data->pin_type, data->pin_reference);
  ------------------
  |  |   71|     32|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1449|     32|	sc_log(ctx, "PIN1(%p,len:%zu,tries-left:%i)", data->pin1.data, data->pin1.len, data->pin1.tries_left);
  ------------------
  |  |   71|     32|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1450|     32|	sc_log(ctx, "PIN2(%p,len:%zu)", data->pin2.data, data->pin2.len);
  ------------------
  |  |   71|     32|#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|       |
 1452|     32|	switch (data->cmd)   {
 1453|      2|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  422|      2|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1453:2): [True: 2, False: 30]
  ------------------
 1454|      2|		rv = authentic_pin_verify(card, data);
 1455|      2|		break;
 1456|      0|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1456:2): [True: 0, False: 32]
  ------------------
 1457|      0|		rv = authentic_pin_change(card, data);
 1458|      0|		break;
 1459|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1459:2): [True: 0, False: 32]
  ------------------
 1460|      0|		rv = authentic_pin_reset(card, data);
 1461|      0|		break;
 1462|     30|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  425|     30|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1462:2): [True: 30, False: 2]
  ------------------
 1463|     30|		rv = authentic_pin_get_policy(card, data, NULL);
 1464|     30|		break;
 1465|      0|	default:
  ------------------
  |  Branch (1465:2): [True: 0, False: 32]
  ------------------
 1466|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1467|     32|	}
 1468|       |
 1469|     32|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|     24|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 24, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1470|     32|}
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: 2, False: 0]
  ------------------
 1114|      2|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "PIN reference out of bounds");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1115|      2|	}
 1116|       |
 1117|      0|	if (pin_cmd->pin1.data && !pin_cmd->pin1.len)   {
  ------------------
  |  Branch (1117:6): [True: 0, False: 0]
  |  Branch (1117:28): [True: 0, False: 0]
  ------------------
 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|      0|	if (pin_cmd->pin1.data)
  ------------------
  |  Branch (1123:6): [True: 0, False: 0]
  ------------------
 1124|      0|		SHA1(pin_cmd->pin1.data, pin_cmd->pin1.len, pin_sha1);
 1125|      0|	else
 1126|      0|		SHA1((unsigned char *)"", 0, pin_sha1);
 1127|       |
 1128|      0|	if (!memcmp(pin_sha1, prv_data->pins_sha1[pin_cmd->pin_reference], SHA_DIGEST_LENGTH))   {
  ------------------
  |  Branch (1128:6): [True: 0, False: 0]
  ------------------
 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|      0|	memset(prv_data->pins_sha1[pin_cmd->pin_reference], 0, sizeof(prv_data->pins_sha1[0]));
 1134|       |
 1135|      0|	rv = authentic_pin_get_policy(card, pin_cmd, NULL);
 1136|      0|	LOG_TEST_RET(ctx, rv, "Get 'PIN policy' 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 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_get_policy:
 1305|     30|{
 1306|     30|	struct sc_context *ctx = card->ctx;
 1307|     30|	struct sc_apdu apdu;
 1308|     30|	unsigned char rbuf[0x100];
 1309|     30|	int ii, rv;
 1310|       |
 1311|     30|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     30|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     30|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     30|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     30|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1312|     30|	sc_log(ctx, "get PIN(type:%X,ref:%X,tries-left:%i)", data->pin_type, data->pin_reference, data->pin1.tries_left);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1313|       |
 1314|     30|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x5F, data->pin_reference);
  ------------------
  |  |  292|     30|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1315|     30|	for (ii=0;ii<2;ii++)   {
  ------------------
  |  Branch (1315:12): [True: 30, False: 0]
  ------------------
 1316|     30|		apdu.le = sizeof(rbuf);
 1317|     30|		apdu.resp = rbuf;
 1318|     30|		apdu.resplen = sizeof(rbuf);
 1319|       |
 1320|     30|		rv = sc_transmit_apdu(card, &apdu);
 1321|     30|		LOG_TEST_RET(ctx, rv, "APDU transmit 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1322|     30|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1323|       |
 1324|     30|		if (rv != SC_ERROR_CLASS_NOT_SUPPORTED)
  ------------------
  |  |   53|     30|#define SC_ERROR_CLASS_NOT_SUPPORTED		-1203
  ------------------
  |  Branch (1324:7): [True: 30, False: 0]
  ------------------
 1325|     30|			break;
 1326|       |
 1327|      0|		apdu.cla = 0x80;
 1328|      0|	}
 1329|     30|        LOG_TEST_RET(ctx, rv, "'GET DATA' 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1330|       |
 1331|     21|	data->pin1.tries_left = -1;
 1332|       |
 1333|     21|	rv = authentic_parse_credential_data(ctx, data, acls, apdu.resp, apdu.resplen);
 1334|     21|        LOG_TEST_RET(ctx, rv, "Cannot parse credential 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: 13, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1335|       |
 1336|      8|	data->pin1.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  432|      8|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1337|      8|	data->pin1.offset = 5;
 1338|      8|	data->pin1.pad_char = 0xFF;
 1339|      8|	data->pin1.pad_length = data->pin1.max_length;
 1340|      8|	data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  437|      8|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 1341|       |
 1342|      8|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  429|      8|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1343|       |
 1344|      8|	sc_log(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__
  |  |  ------------------
  ------------------
 1345|      8|	       "PIN policy: size max/min/pad %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u, tries max/left %i/%i",
 1346|      8|	       data->pin1.max_length, data->pin1.min_length,
 1347|      8|	       data->pin1.pad_length, data->pin1.max_tries,
 1348|      8|	       data->pin1.tries_left);
 1349|       |
 1350|      8|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1351|      8|}
card-authentic.c:authentic_parse_credential_data:
  286|     21|{
  287|     21|	unsigned char *data;
  288|     21|	size_t data_len;
  289|     21|	int rv, ii;
  290|     21|	unsigned tag = AUTHENTIC_TAG_CREDENTIAL | pin_cmd->pin_reference;
  ------------------
  |  |   94|     21|#define AUTHENTIC_TAG_CREDENTIAL			0x5F00
  ------------------
  291|       |
  292|     21|	rv = authentic_get_tagged_data(ctx, blob, blob_len, tag, &blob, &blob_len);
  293|     21|	LOG_TEST_RET(ctx, rv, "cannot get credential 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: 13, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|       |
  295|      8|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_TRYLIMIT, &data, &data_len);
  ------------------
  |  |   95|      8|#define AUTHENTIC_TAG_CREDENTIAL_TRYLIMIT		0x91
  ------------------
  296|      8|	LOG_TEST_RET(ctx, rv, "cannot get try limit");
  ------------------
  |  |  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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|      8|	pin_cmd->pin1.max_tries = *data;
  298|       |
  299|      8|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_DOCP_MECH, &data, &data_len);
  ------------------
  |  |   73|      8|#define AUTHENTIC_TAG_DOCP_MECH			0x80
  ------------------
  300|      8|	LOG_TEST_RET(ctx, rv, "cannot get PIN type");
  ------------------
  |  |  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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  301|      8|	if (data_len > 0 && *data == 0)
  ------------------
  |  Branch (301:6): [True: 8, False: 0]
  |  Branch (301:22): [True: 2, False: 6]
  ------------------
  302|      2|		pin_cmd->pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      2|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  303|      6|	else if (data_len > 0 && *data >= 2 && *data <= 7)
  ------------------
  |  Branch (303:11): [True: 6, False: 0]
  |  Branch (303:27): [True: 6, False: 0]
  |  Branch (303:41): [True: 6, False: 0]
  ------------------
  304|      6|		pin_cmd->pin_type = SC_AC_AUT;
  ------------------
  |  |  154|      6|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  305|      0|	else
  306|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "unsupported Credential 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  307|       |
  308|       |	/* Parse optional ACLs when requested */
  309|      8|	if (acls) {
  ------------------
  |  Branch (309:6): [True: 0, False: 8]
  ------------------
  310|      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
  ------------------
  311|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  312|      0|		sc_log(ctx, "data_len:%"SC_FORMAT_LEN_SIZE_T"u", 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__
  |  |  ------------------
  ------------------
  313|      0|		if (data_len == 10)   {
  ------------------
  |  Branch (313:7): [True: 0, False: 0]
  ------------------
  314|      0|			for (ii=0; ii<5; ii++)   {
  ------------------
  |  Branch (314:15): [True: 0, False: 0]
  ------------------
  315|      0|				unsigned char acl = *(data + ii*2);
  316|      0|				unsigned char cred_id = *(data + ii*2 + 1);
  317|      0|				unsigned sc = acl * 0x100 + cred_id;
  318|       |
  319|      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__
  |  |  ------------------
  ------------------
  320|      0|				if (!sc)
  ------------------
  |  Branch (320:9): [True: 0, False: 0]
  ------------------
  321|      0|					continue;
  322|       |
  323|      0|				if (acl & AUTHENTIC_AC_SM_MASK)   {
  ------------------
  |  |  119|      0|#define AUTHENTIC_AC_SM_MASK	0x60
  ------------------
  |  Branch (323:9): [True: 0, False: 0]
  ------------------
  324|      0|					acls[ii].method = SC_AC_SCB;
  ------------------
  |  |  157|      0|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  325|      0|					acls[ii].key_ref = sc;
  326|      0|				}
  327|      0|				else if (acl!=0xFF && cred_id)   {
  ------------------
  |  Branch (327:14): [True: 0, False: 0]
  |  Branch (327:27): [True: 0, False: 0]
  ------------------
  328|      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__
  |  |  ------------------
  ------------------
  329|      0|					acls[ii].method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  330|      0|					acls[ii].key_ref = cred_id;
  331|      0|				}
  332|      0|				else   {
  333|      0|					acls[ii].method = SC_AC_NEVER;
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  334|      0|					acls[ii].key_ref = 0;
  335|      0|				}
  336|      0|			}
  337|      0|		}
  338|      0|	}
  339|       |
  340|      8|	rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_PINPOLICY, &data, &data_len);
  ------------------
  |  |   96|      8|#define AUTHENTIC_TAG_CREDENTIAL_PINPOLICY		0xA1
  ------------------
  341|      8|	if (!rv)   {
  ------------------
  |  Branch (341:6): [True: 0, False: 8]
  ------------------
  342|      0|		blob = data;
  343|      0|		blob_len = data_len;
  344|       |
  345|      0|		rv = authentic_get_tagged_data(ctx, blob, blob_len, AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MAXLENGTH, &data, &data_len);
  ------------------
  |  |   97|      0|#define AUTHENTIC_TAG_CREDENTIAL_PINPOLICY_MAXLENGTH	0x83
  ------------------
  346|      0|		LOG_TEST_RET(ctx, rv, "failed to get 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|      0|		pin_cmd->pin1.max_length = *data;
  348|       |
  349|      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
  ------------------
  350|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|      0|		pin_cmd->pin1.min_length = *data;
  352|      0|	}
  353|       |
  354|      8|	return SC_SUCCESS;
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  355|      8|}
card-authentic.c:authentic_card_reader_lock_obtained:
 1882|  56.0k|{
 1883|  56.0k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  56.0k|#define SC_SUCCESS				0
  ------------------
 1884|       |
 1885|  56.0k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  56.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  56.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  56.0k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 56.0k]
  |  |  ------------------
  ------------------
 1886|       |
 1887|  56.0k|	if (was_reset > 0
  ------------------
  |  Branch (1887:6): [True: 0, False: 56.0k]
  ------------------
 1888|      0|			&& card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2) {
  ------------------
  |  Branch (1888:7): [True: 0, False: 0]
  ------------------
 1889|      0|		r = iso7816_select_aid(card, aid_AuthentIC_3_2, sizeof(aid_AuthentIC_3_2), NULL, NULL);
 1890|      0|	}
 1891|       |
 1892|  56.0k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  56.0k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  56.0k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  56.0k|	int _ret = r; \
  |  |  |  |  155|  56.0k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 56.0k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  56.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: 56.0k]
  |  |  |  |  ------------------
  |  |  |  |  157|  56.0k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  56.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|  56.0k|	return _ret; \
  |  |  |  |  163|  56.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1893|  56.0k|}

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

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

sc_get_cac_driver:
 1944|  7.38k|{
 1945|  7.38k|	return sc_get_driver();
 1946|  7.38k|}
card-cac.c:sc_get_driver:
 1918|  7.38k|{
 1919|  7.38k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1920|       |
 1921|  7.38k|	cac_ops = *iso_drv->ops;
 1922|  7.38k|	cac_ops.match_card = cac_match_card;
 1923|  7.38k|	cac_ops.init = cac_init;
 1924|  7.38k|	cac_ops.finish = cac_finish;
 1925|       |
 1926|  7.38k|	cac_ops.select_file =  cac_select_file; /* need to record object type */
 1927|  7.38k|	cac_ops.get_challenge = cac_get_challenge;
 1928|  7.38k|	cac_ops.read_binary = cac_read_binary;
 1929|       |	/* CAC driver is read only */
 1930|  7.38k|	cac_ops.write_binary = NULL;
 1931|  7.38k|	cac_ops.set_security_env = cac_set_security_env;
 1932|  7.38k|	cac_ops.restore_security_env = cac_restore_security_env;
 1933|  7.38k|	cac_ops.compute_signature = cac_compute_signature;
 1934|  7.38k|	cac_ops.decipher =  cac_decipher;
 1935|  7.38k|	cac_ops.card_ctl = cac_card_ctl;
 1936|  7.38k|	cac_ops.pin_cmd = cac_pin_cmd;
 1937|  7.38k|	cac_ops.logout = cac_logout;
 1938|       |
 1939|  7.38k|	return &cac_drv;
 1940|  7.38k|}
card-cac.c:cac_match_card:
 1829|    696|{
 1830|    696|	int r;
 1831|    696|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    696|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    696|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    696|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 696]
  |  |  ------------------
  ------------------
 1832|       |
 1833|    696|	r = cac_find_and_initialize(card, 0);
 1834|    696|	return (r == SC_SUCCESS); /* never match */
  ------------------
  |  |   28|    696|#define SC_SUCCESS				0
  ------------------
 1835|    696|}
card-cac.c:cac_find_and_initialize:
 1752|    870|{
 1753|    870|	int r, index;
 1754|    870|	cac_private_data_t *priv = NULL;
 1755|       |
 1756|       |	/* already initialized? */
 1757|    870|	if (card->drv_data) {
  ------------------
  |  Branch (1757:6): [True: 0, False: 870]
  ------------------
 1758|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1759|      0|	}
 1760|       |
 1761|       |	/* is this a CAC-2 specified in NIST Interagency Report 6887 -
 1762|       |	 * "Government Smart Card Interoperability Specification v2.1 July 2003" */
 1763|    870|	r = cac_select_CCC(card);
 1764|    870|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    870|#define SC_SUCCESS				0
  ------------------
  |  Branch (1764:6): [True: 179, False: 691]
  ------------------
 1765|    179|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "CCC found, is CAC-2");
  ------------------
  |  |   70|    179|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1766|    179|		if (!initialize) /* match card only */
  ------------------
  |  Branch (1766:7): [True: 96, False: 83]
  ------------------
 1767|     96|			return r;
 1768|       |
 1769|     83|		priv = cac_new_private_data();
 1770|     83|		if (!priv)
  ------------------
  |  Branch (1770:7): [True: 0, False: 83]
  ------------------
 1771|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1772|     83|		r = cac_process_CCC(card, priv, 0);
 1773|     83|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     83|#define SC_SUCCESS				0
  ------------------
  |  Branch (1773:7): [True: 26, False: 57]
  ------------------
 1774|     26|			card->type = SC_CARD_TYPE_CAC_II;
 1775|     26|			card->drv_data = priv;
 1776|     26|			return r;
 1777|     26|		}
 1778|     83|	}
 1779|       |
 1780|       |	/* Even some ALT tokens can be missing CCC so we should try with ACA */
 1781|    748|	r = cac_select_ACA(card);
 1782|    748|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    748|#define SC_SUCCESS				0
  ------------------
  |  Branch (1782:6): [True: 161, False: 587]
  ------------------
 1783|    161|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "ACA found, is CAC-2 without CCC");
  ------------------
  |  |   70|    161|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1784|    161|		if (!initialize) /* match card only */
  ------------------
  |  Branch (1784:7): [True: 62, False: 99]
  ------------------
 1785|     62|			return r;
 1786|       |
 1787|     99|		if (!priv) {
  ------------------
  |  Branch (1787:7): [True: 75, False: 24]
  ------------------
 1788|     75|			priv = cac_new_private_data();
 1789|     75|			if (!priv)
  ------------------
  |  Branch (1789:8): [True: 0, False: 75]
  ------------------
 1790|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1791|     75|		}
 1792|     99|		r = cac_process_ACA(card, priv);
 1793|     99|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     99|#define SC_SUCCESS				0
  ------------------
  |  Branch (1793:7): [True: 64, False: 35]
  ------------------
 1794|     64|			card->type = SC_CARD_TYPE_CAC_ALT_HID;
 1795|     64|			card->drv_data = priv;
 1796|     64|			return r;
 1797|     64|		}
 1798|     99|	}
 1799|       |
 1800|       |	/* is this a CAC Alt token without any accompanying structures */
 1801|    622|	r = cac_find_first_pki_applet(card, &index);
 1802|    622|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    622|#define SC_SUCCESS				0
  ------------------
  |  Branch (1802:6): [True: 57, False: 565]
  ------------------
 1803|     57|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "PKI applet found, is bare CAC Alt");
  ------------------
  |  |   70|     57|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1804|     57|		if (!initialize) /* match card only */
  ------------------
  |  Branch (1804:7): [True: 16, False: 41]
  ------------------
 1805|     16|			return r;
 1806|       |
 1807|     41|		if (!priv) {
  ------------------
  |  Branch (1807:7): [True: 8, False: 33]
  ------------------
 1808|      8|			priv = cac_new_private_data();
 1809|      8|			if (!priv)
  ------------------
  |  Branch (1809:8): [True: 0, False: 8]
  ------------------
 1810|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1811|      8|		}
 1812|     41|		card->drv_data = priv; /* needed for the read_binary() */
 1813|     41|		r = cac_populate_cac_alt(card, index, priv);
 1814|     41|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     41|#define SC_SUCCESS				0
  ------------------
  |  Branch (1814:7): [True: 8, False: 33]
  ------------------
 1815|      8|			card->type = SC_CARD_TYPE_CAC_II;
 1816|      8|			return r;
 1817|      8|		}
 1818|     33|		card->drv_data = NULL; /* reset on failure */
 1819|     33|	}
 1820|    598|	if (priv) {
  ------------------
  |  Branch (1820:6): [True: 68, False: 530]
  ------------------
 1821|     68|		cac_free_private_data(priv);
 1822|     68|	}
 1823|    598|	return r;
 1824|    622|}
card-cac.c:cac_select_CCC:
 1244|    870|{
 1245|       |	return cac_select_file_by_type(card, &cac_CCC_Path, NULL);
 1246|    870|}
card-cac.c:cac_select_file_by_type:
 1049|  12.2k|{
 1050|  12.2k|	struct sc_context *ctx;
 1051|  12.2k|	struct sc_apdu apdu;
 1052|  12.2k|	unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
 1053|  12.2k|	unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
 1054|  12.2k|	int r, pathtype;
 1055|  12.2k|	size_t pathlen;
 1056|  12.2k|	struct sc_file *file = NULL;
 1057|  12.2k|	cac_private_data_t *priv;
 1058|       |
 1059|  12.2k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (1059:6): [True: 0, False: 12.2k]
  |  Branch (1059:22): [True: 0, False: 12.2k]
  ------------------
 1060|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1061|       |
 1062|  12.2k|	priv = CAC_DATA(card);
  ------------------
  |  |   61|  12.2k|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
 1063|  12.2k|	ctx = card->ctx;
 1064|       |
 1065|  12.2k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  12.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  12.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  12.2k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 12.2k]
  |  |  ------------------
  ------------------
 1066|       |
 1067|  12.2k|	memcpy(path, in_path->value, in_path->len);
 1068|  12.2k|	pathlen = in_path->len;
 1069|  12.2k|	pathtype = in_path->type;
 1070|       |
 1071|  12.2k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  12.2k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1072|  12.2k|	    "path=%s, path->value=%s path->type=%d (%x)",
 1073|  12.2k|	    sc_print_path(in_path),
 1074|  12.2k|	    sc_dump_hex(in_path->value, in_path->len),
 1075|  12.2k|	    in_path->type, in_path->type);
 1076|  12.2k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "file_out=%p index=%d count=%d\n",
  ------------------
  |  |   70|  12.2k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1077|  12.2k|	    file_out, in_path->index, in_path->count);
 1078|       |
 1079|       |	/* Sigh, iso7816_select_file expects paths to keys to have specific
 1080|       |	 * formats. There is no override. We have to add some bytes to the
 1081|       |	 * path to make it happy.
 1082|       |	 * We only need to do this for private keys.
 1083|       |	 */
 1084|  12.2k|	if ((pathlen > 2) && (pathlen <= 4) && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (1084:6): [True: 0, False: 12.2k]
  |  Branch (1084:23): [True: 0, False: 0]
  |  Branch (1084:41): [True: 0, False: 0]
  ------------------
 1085|      0|		path += 2;
 1086|      0|		pathlen -= 2;
 1087|      0|	}
 1088|       |
 1089|       |
 1090|       |	/* CAC has multiple different type of objects that aren't PKCS #15. When we read
 1091|       |	 * them we need convert them to something PKCS #15 would understand. Find the object
 1092|       |	 * and object type here:
 1093|       |	 */
 1094|  12.2k|	if (priv) { /* don't record anything if we haven't been initialized yet */
  ------------------
  |  Branch (1094:6): [True: 808, False: 11.3k]
  ------------------
 1095|    808|		priv->object_type = CAC_OBJECT_TYPE_GENERIC;
  ------------------
  |  |  172|    808|#define CAC_OBJECT_TYPE_GENERIC		5
  ------------------
 1096|    808|		if (cac_is_cert(priv, in_path)) {
  ------------------
  |  Branch (1096:7): [True: 33, False: 775]
  ------------------
 1097|     33|			priv->object_type = CAC_OBJECT_TYPE_CERT;
  ------------------
  |  |  170|     33|#define CAC_OBJECT_TYPE_CERT		1
  ------------------
 1098|     33|		}
 1099|       |
 1100|       |		/* forget any old cached values */
 1101|    808|		if (priv->cache_buf) {
  ------------------
  |  Branch (1101:7): [True: 0, False: 808]
  ------------------
 1102|      0|			free(priv->cache_buf);
 1103|      0|			priv->cache_buf = NULL;
 1104|      0|		}
 1105|    808|		priv->cache_buf_len = 0;
 1106|    808|		priv->cached = 0;
 1107|    808|	}
 1108|       |
 1109|  12.2k|	if (in_path->aid.len) {
  ------------------
  |  Branch (1109:6): [True: 12.2k, False: 0]
  ------------------
 1110|  12.2k|		if (!pathlen) {
  ------------------
  |  Branch (1110:7): [True: 11.9k, False: 274]
  ------------------
 1111|  11.9k|			memcpy(path, in_path->aid.value, in_path->aid.len);
 1112|  11.9k|			pathlen = in_path->aid.len;
 1113|  11.9k|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  11.9k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 1114|  11.9k|		} else {
 1115|       |			/* First, select the application */
 1116|    274|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"select application" );
  ------------------
  |  |   70|    274|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1117|    274|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|    274|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1118|    274|			apdu.data = in_path->aid.value;
 1119|    274|			apdu.datalen = in_path->aid.len;
 1120|    274|			apdu.lc = in_path->aid.len;
 1121|       |
 1122|    274|			r = sc_transmit_apdu(card, &apdu);
 1123|    274|			LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    274|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    274|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    274|	int _ret = (r); \
  |  |  |  |  168|    274|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 274]
  |  |  |  |  ------------------
  |  |  |  |  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|    274|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 274]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1124|    274|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1125|    274|			if (r)
  ------------------
  |  Branch (1125:8): [True: 4, False: 270]
  ------------------
 1126|    274|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1127|       |
 1128|    274|		}
 1129|  12.2k|	}
 1130|       |
 1131|  12.1k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  294|  12.1k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1132|       |
 1133|  12.1k|	switch (pathtype) {
 1134|       |	/* ideally we would had SC_PATH_TYPE_OBJECT_ID and add code to the iso7816 select.
 1135|       |	 * Unfortunately we'd also need to update the caching code as well. For now just
 1136|       |	 * use FILE_ID and change p1 here */
 1137|    270|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|    270|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1137:2): [True: 270, False: 11.9k]
  ------------------
 1138|    270|		apdu.p1 = 2;
 1139|    270|		if (pathlen != 2)
  ------------------
  |  Branch (1139:7): [True: 0, False: 270]
  ------------------
 1140|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1141|    270|		break;
 1142|  11.9k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  11.9k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1142:2): [True: 11.9k, False: 270]
  ------------------
 1143|  11.9k|		apdu.p1 = 4;
 1144|  11.9k|		break;
 1145|      0|	default:
  ------------------
  |  Branch (1145:2): [True: 0, False: 12.1k]
  ------------------
 1146|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1147|  12.1k|	}
 1148|  12.1k|	apdu.lc = pathlen;
 1149|  12.1k|	apdu.data = path;
 1150|  12.1k|	apdu.datalen = pathlen;
 1151|  12.1k|	apdu.resp = buf;
 1152|  12.1k|	apdu.resplen = sizeof(buf);
 1153|  12.1k|	apdu.le = sc_get_max_recv_size(card) < 256 ? sc_get_max_recv_size(card) : 256;
  ------------------
  |  Branch (1153:12): [True: 0, False: 12.1k]
  ------------------
 1154|       |
 1155|  12.1k|	if (file_out != NULL) {
  ------------------
  |  Branch (1155:6): [True: 0, False: 12.1k]
  ------------------
 1156|      0|		apdu.p2 = 0;		/* first record, return FCI */
 1157|      0|	}
 1158|  12.1k|	else {
 1159|  12.1k|		apdu.p2 = 0x0C;
 1160|  12.1k|	}
 1161|       |
 1162|  12.1k|	r = sc_transmit_apdu(card, &apdu);
 1163|  12.1k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  12.1k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  12.1k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  12.1k|	int _ret = (r); \
  |  |  |  |  168|  12.1k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 57, False: 12.1k]
  |  |  |  |  ------------------
  |  |  |  |  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|  12.1k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 12.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1164|       |
 1165|  12.1k|	if (file_out == NULL) {
  ------------------
  |  Branch (1165:6): [True: 12.1k, False: 0]
  ------------------
 1166|       |		/* For some cards 'SELECT' can be only with request to return FCI/FCP. */
 1167|  12.1k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1168|  12.1k|		if (apdu.sw1 == 0x6A && apdu.sw2 == 0x86)   {
  ------------------
  |  Branch (1168:7): [True: 163, False: 11.9k]
  |  Branch (1168:27): [True: 18, False: 145]
  ------------------
 1169|     18|			apdu.p2 = 0x00;
 1170|     18|			apdu.resplen = sizeof(buf);
 1171|     18|			if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS)
  ------------------
  |  |   28|     18|#define SC_SUCCESS				0
  ------------------
  |  Branch (1171:8): [True: 2, False: 16]
  ------------------
 1172|      2|				r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1173|     18|		}
 1174|  12.1k|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (1174:7): [True: 16, False: 12.1k]
  ------------------
 1175|  12.1k|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1176|  12.1k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|  10.7k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10.7k, False: 1.41k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1177|  12.1k|	}
 1178|       |
 1179|      0|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1180|      0|	if (r)
  ------------------
  |  Branch (1180:6): [True: 0, False: 0]
  ------------------
 1181|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1182|       |
 1183|       |	/* This needs to come after the applet selection */
 1184|      0|	if (priv && in_path->len >= 2) {
  ------------------
  |  Branch (1184:6): [True: 0, False: 0]
  |  Branch (1184:14): [True: 0, False: 0]
  ------------------
 1185|       |		/* get applet properties to know if we can treat the
 1186|       |		 * buffer as SimpleLTV and if we have PKI applet.
 1187|       |		 *
 1188|       |		 * Do this only if we select applets for reading
 1189|       |		 * (not during driver initialization)
 1190|       |		 */
 1191|      0|		cac_properties_t prop = {0};
 1192|      0|		size_t i = -1;
 1193|       |
 1194|      0|		r = cac_get_properties(card, &prop);
 1195|      0|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1195:7): [True: 0, False: 0]
  ------------------
 1196|      0|			for (i = 0; i < prop.num_objects; i++) {
  ------------------
  |  Branch (1196:16): [True: 0, False: 0]
  ------------------
 1197|      0|				sc_log(card->ctx, "Searching for our OID: 0x%02x 0x%02x = 0x%02x 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__
  |  |  ------------------
  ------------------
 1198|      0|				    prop.objects[i].oid[0], prop.objects[i].oid[1],
 1199|      0|					in_path->value[0], in_path->value[1]);
 1200|      0|				if (memcmp(prop.objects[i].oid,
  ------------------
  |  Branch (1200:9): [True: 0, False: 0]
  ------------------
 1201|      0|				    in_path->value, 2) == 0)
 1202|      0|					break;
 1203|      0|			}
 1204|      0|		}
 1205|      0|		if (i < prop.num_objects) {
  ------------------
  |  Branch (1205:7): [True: 0, False: 0]
  ------------------
 1206|      0|			if (prop.objects[i].privatekey)
  ------------------
  |  Branch (1206:8): [True: 0, False: 0]
  ------------------
 1207|      0|				priv->object_type = CAC_OBJECT_TYPE_CERT;
  ------------------
  |  |  170|      0|#define CAC_OBJECT_TYPE_CERT		1
  ------------------
 1208|      0|			else if (prop.objects[i].simpletlv == 0)
  ------------------
  |  Branch (1208:13): [True: 0, False: 0]
  ------------------
 1209|      0|				priv->object_type = CAC_OBJECT_TYPE_TLV_FILE;
  ------------------
  |  |  171|      0|#define CAC_OBJECT_TYPE_TLV_FILE	4
  ------------------
 1210|      0|		}
 1211|      0|	}
 1212|       |
 1213|       |	/* CAC cards never return FCI, fake one */
 1214|      0|	file = sc_file_new();
 1215|      0|	if (file == NULL)
  ------------------
  |  Branch (1215:6): [True: 0, False: 0]
  ------------------
 1216|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1217|      0|	file->path = *in_path;
 1218|      0|	file->size = CAC_MAX_SIZE; /* we don't know how big, just give a large size until we can read the file */
  ------------------
  |  |   26|      0|#define CAC_MAX_SIZE 4096		/* arbitrary, just needs to be 'large enough' */
  ------------------
 1219|       |
 1220|      0|	*file_out = file;
 1221|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1222|       |
 1223|      0|}
card-cac.c:cac_is_cert:
  231|    808|{
  232|    808|	cac_object_t test_obj = {0};
  233|    808|	test_obj.path = *in_path;
  234|    808|	test_obj.path.index = 0;
  235|    808|	test_obj.path.count = 0;
  236|       |
  237|    808|	return (list_contains(&priv->pki_list, &test_obj) != 0);
  238|    808|}
card-cac.c:cac_get_properties:
  937|    158|{
  938|    158|	u8 *rbuf = NULL;
  939|    158|	size_t rbuflen = 0, len;
  940|    158|	const u8 *val, *val_end;
  941|    158|	u8 tag;
  942|    158|	size_t i = 0;
  943|    158|	int r;
  944|    158|	prop->num_objects = 0;
  945|       |
  946|    158|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    158|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    158|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    158|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 158]
  |  |  ------------------
  ------------------
  947|       |
  948|    158|	r = cac_apdu_io(card, CAC_INS_GET_PROPERTIES, 0x01, 0x00, NULL, 0,
  ------------------
  |  |   63|    158|#define CAC_INS_GET_PROPERTIES        0x56
  ------------------
  949|    158|		&rbuf, &rbuflen);
  950|    158|	if (r < 0)
  ------------------
  |  Branch (950:6): [True: 3, False: 155]
  ------------------
  951|      3|		return r;
  952|       |
  953|    155|	val = rbuf;
  954|    155|	val_end = val + rbuflen;
  955|  9.20k|	for (; val < val_end; val += len) {
  ------------------
  |  Branch (955:9): [True: 9.16k, False: 38]
  ------------------
  956|       |		/* get the tag and the length */
  957|  9.16k|		if (sc_simpletlv_read_tag(&val, val_end - val, &tag, &len) != SC_SUCCESS)
  ------------------
  |  |   28|  9.16k|#define SC_SUCCESS				0
  ------------------
  |  Branch (957:7): [True: 105, False: 9.05k]
  ------------------
  958|    105|			break;
  959|       |
  960|  9.05k|		switch (tag) {
  961|    963|		case CAC_TAG_APPLET_INFORMATION:
  ------------------
  |  |   89|    963|#define CAC_TAG_APPLET_INFORMATION    0x01
  ------------------
  |  Branch (961:3): [True: 963, False: 8.09k]
  ------------------
  962|    963|			if (len != 5) {
  ------------------
  |  Branch (962:8): [True: 781, False: 182]
  ------------------
  963|    781|				sc_log(card->ctx, "TAG: Applet Information: "
  ------------------
  |  |   71|    781|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  964|    781|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
  965|    781|				break;
  966|    781|			}
  967|    182|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    182|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  968|    182|			    "TAG: Applet Information: Family: 0x%0x", val[0]);
  969|    182|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    182|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  970|    182|			    "     Applet Version: 0x%02x 0x%02x 0x%02x 0x%02x",
  971|    182|			    val[1], val[2], val[3], val[4]);
  972|    182|			break;
  973|       |
  974|    589|		case CAC_TAG_NUMBER_OF_OBJECTS:
  ------------------
  |  |   90|    589|#define CAC_TAG_NUMBER_OF_OBJECTS     0x40
  ------------------
  |  Branch (974:3): [True: 589, False: 8.47k]
  ------------------
  975|    589|			if (len != 1) {
  ------------------
  |  Branch (975:8): [True: 343, False: 246]
  ------------------
  976|    343|				sc_log(card->ctx, "TAG: Num objects: "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  977|    343|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
  978|    343|				break;
  979|    343|			}
  980|    246|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    246|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  981|    246|			    "TAG: Num objects = %hhd", *val);
  982|       |			/* make sure we do not overrun buffer */
  983|    246|			prop->num_objects = MIN(val[0], CAC_MAX_OBJECTS);
  ------------------
  |  |   70|    246|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 163, False: 83]
  |  |  ------------------
  ------------------
  984|    246|			break;
  985|       |
  986|    608|		case CAC_TAG_TV_BUFFER:
  ------------------
  |  |   91|    608|#define CAC_TAG_TV_BUFFER             0x50
  ------------------
  |  Branch (986:3): [True: 608, False: 8.45k]
  ------------------
  987|    608|			if (len != 17) {
  ------------------
  |  Branch (987:8): [True: 237, False: 371]
  ------------------
  988|    237|				sc_log(card->ctx, "TAG: TV Object: "
  ------------------
  |  |   71|    237|#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|    237|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
  990|    237|				break;
  991|    237|			}
  992|    371|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    371|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  993|    371|			    "TAG: TV Object nr. %"SC_FORMAT_LEN_SIZE_T"u", i);
  994|    371|			if (i >= CAC_MAX_OBJECTS) {
  ------------------
  |  |  145|    371|#define CAC_MAX_OBJECTS 16
  ------------------
  |  Branch (994:8): [True: 2, False: 369]
  ------------------
  995|      2|				free(rbuf);
  996|      2|				return SC_SUCCESS;
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
  997|      2|			}
  998|       |
  999|    369|			if (cac_parse_properties_object(card, tag, val, len,
  ------------------
  |  Branch (999:8): [True: 48, False: 321]
  ------------------
 1000|    369|			    &prop->objects[i]) == SC_SUCCESS)
  ------------------
  |  |   28|    369|#define SC_SUCCESS				0
  ------------------
 1001|     48|				i++;
 1002|    369|			break;
 1003|       |
 1004|  1.37k|		case CAC_TAG_PKI_OBJECT:
  ------------------
  |  |   92|  1.37k|#define CAC_TAG_PKI_OBJECT            0x51
  ------------------
  |  Branch (1004:3): [True: 1.37k, False: 7.68k]
  ------------------
 1005|  1.37k|			if (len != 17) {
  ------------------
  |  Branch (1005:8): [True: 170, False: 1.20k]
  ------------------
 1006|    170|				sc_log(card->ctx, "TAG: PKI Object: "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1007|    170|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
 1008|    170|				break;
 1009|    170|			}
 1010|  1.20k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  1.20k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1011|  1.20k|			    "TAG: PKI Object nr. %"SC_FORMAT_LEN_SIZE_T"u", i);
 1012|  1.20k|			if (i >= CAC_MAX_OBJECTS) {
  ------------------
  |  |  145|  1.20k|#define CAC_MAX_OBJECTS 16
  ------------------
  |  Branch (1012:8): [True: 10, False: 1.19k]
  ------------------
 1013|     10|				free(rbuf);
 1014|     10|				return SC_SUCCESS;
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
 1015|     10|			}
 1016|       |
 1017|  1.19k|			if (cac_parse_properties_object(card, tag, val, len,
  ------------------
  |  Branch (1017:8): [True: 347, False: 846]
  ------------------
 1018|  1.19k|			    &prop->objects[i]) == SC_SUCCESS)
  ------------------
  |  |   28|  1.19k|#define SC_SUCCESS				0
  ------------------
 1019|    347|				i++;
 1020|  1.19k|			break;
 1021|       |
 1022|  5.52k|		default:
  ------------------
  |  Branch (1022:3): [True: 5.52k, False: 3.53k]
  ------------------
 1023|       |			/* ignore tags we don't understand */
 1024|  5.52k|			sc_log(card->ctx, "TAG: Unknown (0x%02x), len=%"
  ------------------
  |  |   71|  5.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__
  |  |  ------------------
  ------------------
 1025|  5.52k|			    SC_FORMAT_LEN_SIZE_T"u", tag, len);
 1026|  5.52k|			break;
 1027|  9.05k|		}
 1028|  9.05k|	}
 1029|    143|	free(rbuf);
 1030|       |	/* sanity */
 1031|    143|	if (i != prop->num_objects)
  ------------------
  |  Branch (1031:6): [True: 19, False: 124]
  ------------------
 1032|     19|		sc_log(card->ctx, "The announced number of objects (%zu) "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1033|    143|		    "did not match reality (%"SC_FORMAT_LEN_SIZE_T"u)",
 1034|    143|		    prop->num_objects, i);
 1035|    143|	prop->num_objects = i;
 1036|       |
 1037|    143|	return SC_SUCCESS;
  ------------------
  |  |   28|    143|#define SC_SUCCESS				0
  ------------------
 1038|    155|}
card-cac.c:cac_apdu_io:
  253|  3.85k|{
  254|  3.85k|	int r;
  255|  3.85k|	sc_apdu_t apdu = {0};
  256|  3.85k|	u8 rbufinitbuf[CAC_MAX_SIZE];
  257|  3.85k|	u8 *rbuf;
  258|  3.85k|	size_t rbuflen;
  259|  3.85k|	unsigned int apdu_case = SC_APDU_CASE_1;
  ------------------
  |  |  291|  3.85k|#define SC_APDU_CASE_1			0x01
  ------------------
  260|       |
  261|       |
  262|  3.85k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  263|       |
  264|  3.85k|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  265|  3.85k|		 "%02x %02x %02x %"SC_FORMAT_LEN_SIZE_T"u : %"SC_FORMAT_LEN_SIZE_T"u %"SC_FORMAT_LEN_SIZE_T"u\n",
  266|  3.85k|		 ins, p1, p2, sendbuflen, card->max_send_size,
  267|  3.85k|		 card->max_recv_size);
  268|       |
  269|  3.85k|	rbuf = rbufinitbuf;
  270|  3.85k|	rbuflen = sizeof(rbufinitbuf);
  271|       |
  272|       |	/* if caller provided a buffer and length */
  273|  3.85k|	if (recvbuf && *recvbuf && recvbuflen && *recvbuflen) {
  ------------------
  |  Branch (273:6): [True: 3.85k, False: 0]
  |  Branch (273:17): [True: 3.59k, False: 257]
  |  Branch (273:29): [True: 3.59k, False: 0]
  |  Branch (273:43): [True: 3.59k, False: 0]
  ------------------
  274|  3.59k|		rbuf = *recvbuf;
  275|  3.59k|		rbuflen = *recvbuflen;
  276|  3.59k|	}
  277|       |
  278|  3.85k|	if (recvbuf) {
  ------------------
  |  Branch (278:6): [True: 3.85k, False: 0]
  ------------------
  279|  3.85k|		if (sendbuf)
  ------------------
  |  Branch (279:7): [True: 3.59k, False: 257]
  ------------------
  280|  3.59k|			apdu_case = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|  3.59k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  281|    257|		else
  282|    257|			apdu_case = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|    257|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  283|  3.85k|	} else if (sendbuf)
  ------------------
  |  Branch (283:13): [True: 0, False: 0]
  ------------------
  284|      0|		apdu_case = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  285|       |
  286|       |
  287|  3.85k|	sc_format_apdu(card, &apdu, apdu_case, ins, p1, p2);
  288|       |
  289|  3.85k|	apdu.lc = sendbuflen;
  290|  3.85k|	apdu.datalen = sendbuflen;
  291|  3.85k|	apdu.data = sendbuf;
  292|       |
  293|  3.85k|	if (recvbuf) {
  ------------------
  |  Branch (293:6): [True: 3.85k, False: 0]
  ------------------
  294|  3.85k|		apdu.resp = rbuf;
  295|  3.85k|		apdu.le = (rbuflen > 255) ? 255 : rbuflen;
  ------------------
  |  Branch (295:13): [True: 257, False: 3.59k]
  ------------------
  296|  3.85k|		apdu.resplen = rbuflen;
  297|  3.85k|	} else {
  298|      0|		 apdu.resp =  rbuf;
  299|      0|		 apdu.le = 0;
  300|      0|		 apdu.resplen = 0;
  301|      0|	}
  302|       |
  303|  3.85k|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  304|  3.85k|		 "calling sc_transmit_apdu flags=%lx le=%"SC_FORMAT_LEN_SIZE_T"u, resplen=%"SC_FORMAT_LEN_SIZE_T"u, resp=%p",
  305|  3.85k|		 apdu.flags, apdu.le, apdu.resplen, apdu.resp);
  306|       |
  307|       |	/* with new adpu.c and chaining, this actually reads the whole object */
  308|  3.85k|	r = sc_transmit_apdu(card, &apdu);
  309|       |
  310|  3.85k|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  311|  3.85k|		 "result r=%d apdu.resplen=%"SC_FORMAT_LEN_SIZE_T"u sw1=%02x sw2=%02x",
  312|  3.85k|		 r, apdu.resplen, apdu.sw1, apdu.sw2);
  313|  3.85k|	if (r < 0) {
  ------------------
  |  Branch (313:6): [True: 23, False: 3.82k]
  ------------------
  314|     23|		sc_log(card->ctx, "Transmit failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  315|     23|		goto err;
  316|     23|	}
  317|       |
  318|  3.82k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  319|       |
  320|  3.82k|	if (r < 0) {
  ------------------
  |  Branch (320:6): [True: 92, False: 3.73k]
  ------------------
  321|     92|		sc_log(card->ctx,  "Card returned error ");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  322|     92|		goto err;
  323|     92|	}
  324|       |
  325|  3.73k|	if (recvbuflen) {
  ------------------
  |  Branch (325:6): [True: 3.73k, False: 0]
  ------------------
  326|  3.73k|		if (recvbuf && *recvbuf == NULL) {
  ------------------
  |  Branch (326:7): [True: 3.73k, False: 0]
  |  Branch (326:18): [True: 243, False: 3.49k]
  ------------------
  327|    243|			*recvbuf =  malloc(apdu.resplen);
  328|    243|			if (*recvbuf == NULL) {
  ------------------
  |  Branch (328:8): [True: 0, False: 243]
  ------------------
  329|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  330|      0|				goto err;
  331|      0|			}
  332|    243|			memcpy(*recvbuf, rbuf, apdu.resplen);
  333|    243|		}
  334|  3.73k|		*recvbuflen =  apdu.resplen;
  335|  3.73k|		r = (int)*recvbuflen;
  336|  3.73k|	}
  337|       |
  338|  3.85k|err:
  339|  3.85k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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: 211, False: 3.63k]
  |  |  |  |  ------------------
  |  |  |  |  156|    211|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    115|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 115, False: 96]
  |  |  |  |  ------------------
  |  |  |  |  157|    211|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.63k|	} else { \
  |  |  |  |  159|  3.63k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  3.63k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  3.63k|	} \
  |  |  |  |  162|  3.85k|	return _ret; \
  |  |  |  |  163|  3.85k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  340|  3.85k|}
card-cac.c:cac_parse_properties_object:
  859|  1.56k|{
  860|  1.56k|	size_t len;
  861|  1.56k|	const u8 *val, *val_end;
  862|  1.56k|	u8 tag;
  863|  1.56k|	int parsed = 0;
  864|       |
  865|  1.56k|	if (data_len < 11)
  ------------------
  |  Branch (865:6): [True: 0, False: 1.56k]
  ------------------
  866|      0|		return -1;
  867|       |
  868|       |	/* Initialize: non-PKI applet */
  869|  1.56k|	object->privatekey = 0;
  870|       |
  871|  1.56k|	val = data;
  872|  1.56k|	val_end = data + data_len;
  873|  7.42k|	for (; val < val_end; val += len) {
  ------------------
  |  Branch (873:9): [True: 6.79k, False: 623]
  ------------------
  874|       |		/* get the tag and the length */
  875|  6.79k|		if (sc_simpletlv_read_tag(&val, val_end - val, &tag, &len) != SC_SUCCESS)
  ------------------
  |  |   28|  6.79k|#define SC_SUCCESS				0
  ------------------
  |  Branch (875:7): [True: 939, False: 5.85k]
  ------------------
  876|    939|			break;
  877|       |
  878|  5.85k|		switch (tag) {
  879|    957|		case CAC_TAG_OBJECT_ID:
  ------------------
  |  |   93|    957|#define CAC_TAG_OBJECT_ID             0x41
  ------------------
  |  Branch (879:3): [True: 957, False: 4.90k]
  ------------------
  880|    957|			if (len != 2) {
  ------------------
  |  Branch (880:8): [True: 449, False: 508]
  ------------------
  881|    449|				sc_log(card->ctx, "TAG: Object ID: "
  ------------------
  |  |   71|    449|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  882|    449|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
  883|    449|				break;
  884|    449|			}
  885|    508|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    508|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  886|    508|			    "TAG: Object ID = 0x%02x 0x%02x", val[0], val[1]);
  887|    508|			memcpy(&object->oid, val, 2);
  888|    508|			parsed++;
  889|    508|			break;
  890|       |
  891|    639|		case CAC_TAG_BUFFER_PROPERTIES:
  ------------------
  |  |   94|    639|#define CAC_TAG_BUFFER_PROPERTIES     0x42
  ------------------
  |  Branch (891:3): [True: 639, False: 5.22k]
  ------------------
  892|    639|			if (len != 5) {
  ------------------
  |  Branch (892:8): [True: 186, False: 453]
  ------------------
  893|    186|				sc_log(card->ctx, "TAG: Buffer Properties: "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  894|    186|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
  895|    186|				break;
  896|    186|			}
  897|       |			/* First byte is "Type of Tag Supported" */
  898|    453|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    453|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  899|    453|			    "TAG: Buffer Properties: Type of Tag Supported = 0x%02x",
  900|    453|			    val[0]);
  901|    453|			object->simpletlv = val[0];
  902|    453|			parsed++;
  903|    453|			break;
  904|       |
  905|    889|		case CAC_TAG_PKI_PROPERTIES:
  ------------------
  |  |   95|    889|#define CAC_TAG_PKI_PROPERTIES        0x43
  ------------------
  |  Branch (905:3): [True: 889, False: 4.97k]
  ------------------
  906|       |			/* 4th byte is "Private Key Initialized" */
  907|    889|			if (len != 4) {
  ------------------
  |  Branch (907:8): [True: 402, False: 487]
  ------------------
  908|    402|				sc_log(card->ctx, "TAG: PKI Properties: "
  ------------------
  |  |   71|    402|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  909|    402|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
  910|    402|				break;
  911|    402|			}
  912|    487|			if (type != CAC_TAG_PKI_OBJECT) {
  ------------------
  |  |   92|    487|#define CAC_TAG_PKI_OBJECT            0x51
  ------------------
  |  Branch (912:8): [True: 162, False: 325]
  ------------------
  913|    162|				sc_log(card->ctx, "TAG: PKI Properties outside of PKI Object");
  ------------------
  |  |   71|    162|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  914|    162|				break;
  915|    162|			}
  916|    325|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    325|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  917|    325|			    "TAG: PKI Properties: Private Key Initialized = 0x%02x",
  918|    325|			    val[2]);
  919|    325|			object->privatekey = val[2];
  920|    325|			parsed++;
  921|    325|			break;
  922|       |
  923|  3.37k|		default:
  ------------------
  |  Branch (923:3): [True: 3.37k, False: 2.48k]
  ------------------
  924|       |			/* ignore tags we don't understand */
  925|  3.37k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  3.37k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  926|  3.37k|			    "TAG: Unknown (0x%02x)",tag );
  927|  3.37k|			break;
  928|  5.85k|		}
  929|  5.85k|	}
  930|  1.56k|	if (parsed < 2)
  ------------------
  |  Branch (930:6): [True: 1.16k, False: 395]
  ------------------
  931|  1.16k|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|  1.16k|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  932|       |
  933|    395|	return SC_SUCCESS;
  ------------------
  |  |   28|    395|#define SC_SUCCESS				0
  ------------------
  934|  1.56k|}
card-cac.c:cac_process_CCC:
 1527|    342|{
 1528|    342|	u8 *tl = NULL, *val = NULL;
 1529|    342|	size_t tl_len = 0, val_len = 0;
 1530|    342|	int r;
 1531|       |
 1532|    342|	if (depth > CAC_MAX_CCC_DEPTH) {
  ------------------
  |  |  106|    342|#define CAC_MAX_CCC_DEPTH             16
  ------------------
  |  Branch (1532:6): [True: 1, False: 341]
  ------------------
 1533|      1|		sc_log(card->ctx, "Too much recursive CCC found. Exiting");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1534|      1|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      1|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1535|      1|	}
 1536|       |
 1537|    341|	r = cac_read_file(card, CAC_FILE_TAG, &tl, &tl_len);
  ------------------
  |  |   66|    341|#define CAC_FILE_TAG    1
  ------------------
 1538|    341|	if (r < 0)
  ------------------
  |  Branch (1538:6): [True: 32, False: 309]
  ------------------
 1539|     32|		goto done;
 1540|       |
 1541|    309|	r = cac_read_file(card, CAC_FILE_VALUE, &val, &val_len);
  ------------------
  |  |   67|    309|#define CAC_FILE_VALUE  2
  ------------------
 1542|    309|	if (r < 0)
  ------------------
  |  Branch (1542:6): [True: 6, False: 303]
  ------------------
 1543|      6|		goto done;
 1544|       |
 1545|    303|	r = cac_parse_CCC(card, priv, tl, tl_len, val, val_len, depth);
 1546|    341|done:
 1547|    341|	if (tl)
  ------------------
  |  Branch (1547:6): [True: 309, False: 32]
  ------------------
 1548|    309|		free(tl);
 1549|    341|	if (val)
  ------------------
  |  Branch (1549:6): [True: 303, False: 38]
  ------------------
 1550|    303|		free(val);
 1551|    341|	return r;
 1552|    303|}
card-cac.c:cac_read_file:
  390|    664|{
  391|    664|	u8 params[2];
  392|    664|	u8 count[2] = {0};
  393|    664|	u8 *out = NULL;
  394|    664|	u8 *out_ptr = NULL;
  395|    664|	size_t offset = 0;
  396|    664|	size_t size = 0;
  397|    664|	size_t left = 0;
  398|    664|	size_t len = 0;
  399|    664|	int r;
  400|       |
  401|    664|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    664|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    664|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    664|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 664]
  |  |  ------------------
  ------------------
  402|       |
  403|    664|	params[0] = file_type;
  404|    664|	params[1] = 2;
  405|       |
  406|       |	/* get the size */
  407|    664|	len = sizeof(count);
  408|    664|	out_ptr = count;
  409|    664|	r = cac_apdu_io(card, CAC_INS_READ_FILE, 0, 0, &params[0], sizeof(params), &out_ptr, &len);
  ------------------
  |  |   61|    664|#define CAC_INS_READ_FILE             0x52  /* read a TL or V file */
  ------------------
  410|    664|	if (len == 0) {
  ------------------
  |  Branch (410:6): [True: 6, False: 658]
  ------------------
  411|      6|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      6|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  412|      6|	}
  413|    664|	if (r < 0)
  ------------------
  |  Branch (413:6): [True: 24, False: 640]
  ------------------
  414|     24|		goto fail;
  415|       |
  416|    640|	left = size = lebytes2ushort(count);
  417|    640|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    640|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  418|    640|		 "got %"SC_FORMAT_LEN_SIZE_T"u bytes out_ptr=%p count&=%p count[0]=0x%02x count[1]=0x%02x, len=0x%04"SC_FORMAT_LEN_SIZE_T"x (%"SC_FORMAT_LEN_SIZE_T"u)",
  419|    640|		 len, out_ptr, &count, count[0], count[1], size, size);
  420|    640|	out = out_ptr = malloc(size);
  421|    640|	if (out == NULL) {
  ------------------
  |  Branch (421:6): [True: 0, False: 640]
  ------------------
  422|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  423|      0|		goto fail;
  424|      0|	}
  425|  3.37k|	for (offset += 2; left > 0; offset += len, left -= len, out_ptr += len) {
  ------------------
  |  Branch (425:20): [True: 2.74k, False: 623]
  ------------------
  426|  2.74k|		len = MIN(left, CAC_MAX_CHUNK_SIZE);
  ------------------
  |  |   70|  2.74k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 781, False: 1.96k]
  |  |  ------------------
  ------------------
  427|  2.74k|		params[1] = len;
  428|  2.74k|		r = cac_apdu_io(card, CAC_INS_READ_FILE, HIGH_BYTE_OF_SHORT(offset), LOW_BYTE_OF_SHORT(offset),
  ------------------
  |  |   61|  2.74k|#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),
  ------------------
  |  |  387|  2.74k|#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),
  ------------------
  |  |  388|  2.74k|#define LOW_BYTE_OF_SHORT(x) ((x) & 0xff)
  ------------------
  429|  2.74k|						&params[0], sizeof(params), &out_ptr, &len);
  430|       |		/* if there is no data, assume there is no file */
  431|  2.74k|		if (len == 0) {
  ------------------
  |  Branch (431:7): [True: 1, False: 2.74k]
  ------------------
  432|      1|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      1|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  433|      1|		}
  434|  2.74k|		if (r < 0) {
  ------------------
  |  Branch (434:7): [True: 17, False: 2.73k]
  ------------------
  435|     17|			goto fail;
  436|     17|		}
  437|  2.74k|	}
  438|    623|	*out_len = size;
  439|    623|	*out_buf = out;
  440|    623|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    623|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    623|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    623|	int _ret = r; \
  |  |  |  |  155|    623|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 623, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    623|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 623]
  |  |  |  |  ------------------
  |  |  |  |  157|    623|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    623|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    623|	return _ret; \
  |  |  |  |  163|    623|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|     41|fail:
  442|     41|	if (out)
  ------------------
  |  Branch (442:6): [True: 17, False: 24]
  ------------------
  443|     17|		free(out);
  444|     41|	*out_len = 0;
  445|     41|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     41|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     41|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     41|	int _ret = r; \
  |  |  |  |  155|     41|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 41, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     41|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     41|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 41, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     41|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     41|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     41|	return _ret; \
  |  |  |  |  163|     41|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|     41|}
card-cac.c:cac_parse_CCC:
 1416|    303|{
 1417|    303|	size_t len = 0;
 1418|    303|	const u8 *tl_end = tl + tl_len;
 1419|    303|	const u8 *val_end = val + val_len;
 1420|    303|	sc_path_t new_path;
 1421|    303|	int r;
 1422|       |
 1423|       |
 1424|  2.85k|	for (; (tl < tl_end) && (val< val_end); val += len) {
  ------------------
  |  Branch (1424:9): [True: 2.84k, False: 4]
  |  Branch (1424:26): [True: 2.80k, False: 45]
  ------------------
 1425|       |		/* get the tag and the length */
 1426|  2.80k|		u8 tag;
 1427|  2.80k|		r = sc_simpletlv_read_tag(&tl, tl_end - tl, &tag, &len);
 1428|  2.80k|		if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS) {
  ------------------
  |  |   28|  5.60k|#define SC_SUCCESS				0
  ------------------
              		if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS) {
  ------------------
  |  |   99|    103|#define SC_ERROR_TLV_END_OF_CONTENTS	-1418
  ------------------
  |  Branch (1428:7): [True: 103, False: 2.69k]
  |  Branch (1428:26): [True: 3, False: 100]
  ------------------
 1429|      3|			sc_log(card->ctx, "Failed to parse tag from buffer");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1430|      3|			break;
 1431|      3|		}
 1432|  2.79k|		if (val + len > val_end) {
  ------------------
  |  Branch (1432:7): [True: 111, False: 2.68k]
  ------------------
 1433|    111|			sc_log(card->ctx, "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
  ------------------
  |  |   71|    111|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1434|    111|			break;
 1435|    111|		}
 1436|  2.68k|		switch (tag) {
 1437|    165|		case CAC_TAG_CUID:
  ------------------
  |  |   72|    165|#define CAC_TAG_CUID                  0xF0
  ------------------
  |  Branch (1437:3): [True: 165, False: 2.52k]
  ------------------
 1438|    165|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG:CUID");
  ------------------
  |  |   70|    165|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1439|    165|			r = cac_parse_cuid(card, priv, (cac_cuid_t *)val, len);
 1440|    165|			if (r < 0)
  ------------------
  |  Branch (1440:8): [True: 1, False: 164]
  ------------------
 1441|      1|				return r;
 1442|    164|			break;
 1443|    164|		case CAC_TAG_CC_VERSION_NUMBER:
  ------------------
  |  |   73|    162|#define CAC_TAG_CC_VERSION_NUMBER     0xF1
  ------------------
  |  Branch (1443:3): [True: 162, False: 2.52k]
  ------------------
 1444|    162|			if (len != 1) {
  ------------------
  |  Branch (1444:8): [True: 7, False: 155]
  ------------------
 1445|      7|				sc_log(card->ctx, "TAG: CC Version: "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1446|      7|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
 1447|      7|				break;
 1448|      7|			}
 1449|       |			/* ignore the version numbers for now */
 1450|    155|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    155|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1451|    155|				"TAG: CC Version = 0x%02x", *val);
 1452|    155|			break;
 1453|    174|		case CAC_TAG_GRAMMAR_VERION_NUMBER:
  ------------------
  |  |   74|    174|#define CAC_TAG_GRAMMAR_VERION_NUMBER 0xF2
  ------------------
  |  Branch (1453:3): [True: 174, False: 2.51k]
  ------------------
 1454|    174|			if (len != 1) {
  ------------------
  |  Branch (1454:8): [True: 55, False: 119]
  ------------------
 1455|     55|				sc_log(card->ctx, "TAG: Grammar Version: "
  ------------------
  |  |   71|     55|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1456|     55|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
 1457|     55|				break;
 1458|     55|			}
 1459|       |			/* ignore the version numbers for now */
 1460|    119|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    119|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1461|    119|				"TAG: Grammar Version = 0x%02x", *val);
 1462|    119|			break;
 1463|  1.20k|		case CAC_TAG_CARDURL:
  ------------------
  |  |   75|  1.20k|#define CAC_TAG_CARDURL               0xF3
  ------------------
  |  Branch (1463:3): [True: 1.20k, False: 1.48k]
  ------------------
 1464|  1.20k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG:CARDURL");
  ------------------
  |  |   70|  1.20k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1465|  1.20k|			r = cac_parse_cardurl(card, priv, (cac_card_url_t *)val, len);
 1466|  1.20k|			if (r < 0)
  ------------------
  |  Branch (1466:8): [True: 1, False: 1.20k]
  ------------------
 1467|      1|				return r;
 1468|  1.20k|			break;
 1469|       |		/*
 1470|       |		 * The following are really for file systems cards. This code only cares about CAC VM cards
 1471|       |		 */
 1472|  1.20k|		case CAC_TAG_PKCS15:
  ------------------
  |  |   76|      6|#define CAC_TAG_PKCS15                0xF4
  ------------------
  |  Branch (1472:3): [True: 6, False: 2.68k]
  ------------------
 1473|      6|			if (len != 1) {
  ------------------
  |  Branch (1473:8): [True: 0, False: 6]
  ------------------
 1474|      0|				sc_log(card->ctx, "TAG: PKCS15: "
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1475|      0|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
 1476|      0|				break;
 1477|      0|			}
 1478|       |			/* TODO should verify that this is '0'. If it's not
 1479|       |			 * zero, we should drop out of here and let the PKCS 15
 1480|       |			 * code handle this card */
 1481|      6|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG: PKCS15 = 0x%02x", *val);
  ------------------
  |  |   70|      6|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1482|      6|			break;
 1483|      7|		case CAC_TAG_DATA_MODEL:
  ------------------
  |  |   78|      7|#define CAC_TAG_DATA_MODEL            0xF5
  ------------------
  |  Branch (1483:3): [True: 7, False: 2.68k]
  ------------------
 1484|      7|			if (len != 1) {
  ------------------
  |  Branch (1484:8): [True: 7, False: 0]
  ------------------
 1485|      7|				sc_log(card->ctx, "TAG: Registered Data Model Number: "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1486|      7|				    "Invalid length %"SC_FORMAT_LEN_SIZE_T"u", len);
 1487|      7|				break;
 1488|      7|			}
 1489|      0|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG: Registered Data Model Number (0x%02x)", *val);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1490|      0|			break;
 1491|      3|		case CAC_TAG_CARD_APDU:
  ------------------
  |  |   79|      3|#define CAC_TAG_CARD_APDU             0xF7
  ------------------
  |  Branch (1491:3): [True: 3, False: 2.68k]
  ------------------
 1492|     65|		case CAC_TAG_CAPABILITY_TUPLES:
  ------------------
  |  |   81|     65|#define CAC_TAG_CAPABILITY_TUPLES     0xFB
  ------------------
  |  Branch (1492:3): [True: 62, False: 2.62k]
  ------------------
 1493|     66|		case CAC_TAG_STATUS_TUPLES:
  ------------------
  |  |   82|     66|#define CAC_TAG_STATUS_TUPLES         0xFC
  ------------------
  |  Branch (1493:3): [True: 1, False: 2.68k]
  ------------------
 1494|     66|		case CAC_TAG_REDIRECTION:
  ------------------
  |  |   80|     66|#define CAC_TAG_REDIRECTION           0xFA
  ------------------
  |  Branch (1494:3): [True: 0, False: 2.68k]
  ------------------
 1495|     68|		case CAC_TAG_ERROR_CODES:
  ------------------
  |  |   84|     68|#define CAC_TAG_ERROR_CODES           0xFE
  ------------------
  |  Branch (1495:3): [True: 2, False: 2.68k]
  ------------------
 1496|     68|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG: FSSpecific(0x%02x)", tag);
  ------------------
  |  |   70|     68|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1497|     68|			break;
 1498|      0|		case CAC_TAG_ACCESS_CONTROL:
  ------------------
  |  |   77|      0|#define CAC_TAG_ACCESS_CONTROL        0xF6
  ------------------
  |  Branch (1498:3): [True: 0, False: 2.68k]
  ------------------
 1499|       |			/* TODO handle access control later */
 1500|      0|			sc_log_hex(card->ctx, "TAG:ACCESS Control", val, len);
  ------------------
  |  |  129|      0|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|      0|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1501|      0|			break;
 1502|    275|		case CAC_TAG_NEXT_CCC:
  ------------------
  |  |   83|    275|#define CAC_TAG_NEXT_CCC              0xFD
  ------------------
  |  Branch (1502:3): [True: 275, False: 2.41k]
  ------------------
 1503|    275|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG:NEXT CCC");
  ------------------
  |  |   70|    275|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1504|    275|			r = cac_path_from_cardurl(card, &new_path, (cac_card_url_t *)val, len);
 1505|    275|			if (r < 0)
  ------------------
  |  Branch (1505:8): [True: 1, False: 274]
  ------------------
 1506|      1|				return r;
 1507|       |
 1508|    274|			r = cac_select_file_by_type(card, &new_path, NULL);
 1509|    274|			if (r < 0)
  ------------------
  |  Branch (1509:8): [True: 15, False: 259]
  ------------------
 1510|     15|				return r;
 1511|       |
 1512|       |			/* Increase depth to avoid infinite recursion */
 1513|    259|			r = cac_process_CCC(card, priv, depth + 1);
 1514|    259|			if (r < 0)
  ------------------
  |  Branch (1514:8): [True: 122, False: 137]
  ------------------
 1515|    122|				return r;
 1516|    137|			break;
 1517|    623|		default:
  ------------------
  |  Branch (1517:3): [True: 623, False: 2.06k]
  ------------------
 1518|       |			/* ignore tags we don't understand */
 1519|    623|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"TAG:Unknown (0x%02x)",tag );
  ------------------
  |  |   70|    623|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1520|    623|			break;
 1521|  2.68k|		}
 1522|  2.68k|	}
 1523|    163|	return SC_SUCCESS;
  ------------------
  |  |   28|    163|#define SC_SUCCESS				0
  ------------------
 1524|    303|}
card-cac.c:cac_parse_cuid:
 1387|    165|{
 1388|    165|	size_t card_id_len;
 1389|       |
 1390|    165|	if (len < sizeof(cac_cuid_t)) {
  ------------------
  |  Branch (1390:6): [True: 1, False: 164]
  ------------------
 1391|      1|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1392|      1|	}
 1393|       |
 1394|    164|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "gsc_rid=%s", sc_dump_hex(val->gsc_rid, sizeof(val->gsc_rid)));
  ------------------
  |  |   70|    164|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1395|    164|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "manufacture id=%x", val->manufacturer_id);
  ------------------
  |  |   70|    164|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1396|    164|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "cac_type=%d", val->card_type);
  ------------------
  |  |   70|    164|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1397|    164|	card_id_len = len - (&val->card_id - (u8 *)val);
 1398|    164|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    164|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1399|    164|		 "card_id=%s (%"SC_FORMAT_LEN_SIZE_T"u)",
 1400|    164|		 sc_dump_hex(&val->card_id, card_id_len),
 1401|    164|		 card_id_len);
 1402|    164|	priv->cuid = *val;
 1403|    164|	free(priv->cac_id);
 1404|    164|	priv->cac_id = malloc(card_id_len);
 1405|    164|	if (priv->cac_id == NULL) {
  ------------------
  |  Branch (1405:6): [True: 0, False: 164]
  ------------------
 1406|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1407|      0|	}
 1408|    164|	memcpy(priv->cac_id, &val->card_id, card_id_len);
 1409|    164|	priv->cac_id_len = card_id_len;
 1410|    164|	return SC_SUCCESS;
  ------------------
  |  |   28|    164|#define SC_SUCCESS				0
  ------------------
 1411|    164|}
card-cac.c:cac_parse_cardurl:
 1341|  1.20k|{
 1342|  1.20k|	cac_object_t new_object;
 1343|  1.20k|	const cac_object_t *obj;
 1344|  1.20k|	unsigned short object_id;
 1345|  1.20k|	int r;
 1346|       |
 1347|  1.20k|	r = cac_path_from_cardurl(card, &new_object.path, val, len);
 1348|  1.20k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  1.20k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1348:6): [True: 1, False: 1.20k]
  ------------------
 1349|      1|		return r;
 1350|      1|	}
 1351|  1.20k|	switch (val->cardApplicationType) {
 1352|    632|	case CAC_APP_TYPE_PKI:
  ------------------
  |  |   99|    632|#define CAC_APP_TYPE_PKI              0x04
  ------------------
  |  Branch (1352:2): [True: 632, False: 575]
  ------------------
 1353|       |		/* we don't want to overflow the cac_label array. This test could
 1354|       |		 * go way if we create a label function that will create a unique label
 1355|       |		 * from a cert index.
 1356|       |		 */
 1357|    632|		if (priv->cert_next >= MAX_CAC_SLOTS)
  ------------------
  |  |   70|    632|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (1357:7): [True: 274, False: 358]
  ------------------
 1358|    274|			break; /* don't fail just because we have more certs than we can support */
 1359|    358|		new_object.name = get_cac_label(priv->cert_next);
 1360|    358|		new_object.fd = priv->cert_next+1;
 1361|    358|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"CARDURL: pki_object found, cert_next=%d (%s),", priv->cert_next, new_object.name);
  ------------------
  |  |   70|    358|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1362|    358|		cac_add_object_to_list(&priv->pki_list, &new_object);
 1363|    358|		priv->cert_next++;
 1364|    358|		break;
 1365|     64|	case CAC_APP_TYPE_GENERAL:
  ------------------
  |  |   97|     64|#define CAC_APP_TYPE_GENERAL          0x01
  ------------------
  |  Branch (1365:2): [True: 64, False: 1.14k]
  ------------------
 1366|     64|		object_id = bebytes2ushort(val->objectID);
 1367|     64|		obj = cac_find_obj_by_id(object_id);
 1368|     64|		if (obj == NULL)
  ------------------
  |  Branch (1368:7): [True: 64, False: 0]
  ------------------
 1369|     64|			break; /* don't fail just because we don't recognize the object */
 1370|      0|		new_object.name = obj->name;
 1371|      0|		new_object.fd = 0;
 1372|      0|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"CARDURL: gen_object found, objectID=%x (%s),", object_id, new_object.name);
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1373|      0|		cac_add_object_to_list(&priv->general_list, &new_object);
 1374|      0|		break;
 1375|     91|	case CAC_APP_TYPE_SKI:
  ------------------
  |  |   98|     91|#define CAC_APP_TYPE_SKI              0x02
  ------------------
  |  Branch (1375:2): [True: 91, False: 1.11k]
  ------------------
 1376|     91|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"CARDURL: ski_object found");
  ------------------
  |  |   70|     91|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1377|     91|	break;
 1378|    420|	default:
  ------------------
  |  Branch (1378:2): [True: 420, False: 787]
  ------------------
 1379|    420|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"CARDURL: unknown object_object found (type=0x%02x)", val->cardApplicationType);
  ------------------
  |  |   70|    420|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1380|       |		/* don't fail just because there is an unknown object in the CCC */
 1381|    420|		break;
 1382|  1.20k|	}
 1383|  1.20k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.20k|#define SC_SUCCESS				0
  ------------------
 1384|  1.20k|}
card-cac.c:cac_find_obj_by_id:
  216|     64|{
  217|     64|	int i;
  218|       |
  219|    448|	for (i = 0; i < cac_object_count; i++) {
  ------------------
  |  Branch (219:14): [True: 384, False: 64]
  ------------------
  220|    384|		if (cac_objects[i].fd == object_id) {
  ------------------
  |  Branch (220:7): [True: 0, False: 384]
  ------------------
  221|      0|			return &cac_objects[i];
  222|      0|		}
  223|    384|	}
  224|     64|	return NULL;
  225|     64|}
card-cac.c:cac_path_from_cardurl:
 1255|  1.48k|{
 1256|  1.48k|	if (len < 10) {
  ------------------
  |  Branch (1256:6): [True: 2, False: 1.48k]
  ------------------
 1257|      2|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      2|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 1258|      2|	}
 1259|  1.48k|	sc_mem_clear(path, sizeof(sc_path_t));
 1260|  1.48k|	memcpy(path->aid.value, &val->rid, sizeof(val->rid));
 1261|  1.48k|	memcpy(&path->aid.value[5], val->applicationID, sizeof(val->applicationID));
 1262|  1.48k|	path->aid.len = sizeof(val->rid) + sizeof(val->applicationID);
 1263|  1.48k|	memcpy(path->value, val->objectID, sizeof(val->objectID));
 1264|  1.48k|	path->len = sizeof(val->objectID);
 1265|  1.48k|	path->type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  1.48k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1266|  1.48k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  1.48k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1267|  1.48k|		 "path->aid=%x %x %x %x %x %x %x  len=%"SC_FORMAT_LEN_SIZE_T"u, path->value = %x %x len=%"SC_FORMAT_LEN_SIZE_T"u path->type=%d (%x)",
 1268|  1.48k|		 path->aid.value[0], path->aid.value[1], path->aid.value[2],
 1269|  1.48k|		 path->aid.value[3], path->aid.value[4], path->aid.value[5],
 1270|  1.48k|		 path->aid.value[6], path->aid.len, path->value[0],
 1271|  1.48k|		 path->value[1], path->len, path->type, path->type);
 1272|  1.48k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  1.48k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1273|  1.48k|		 "rid=%x %x %x %x %x  len=%"SC_FORMAT_LEN_SIZE_T"u appid= %x %x len=%"SC_FORMAT_LEN_SIZE_T"u objid= %x %x len=%"SC_FORMAT_LEN_SIZE_T"u",
 1274|  1.48k|		 val->rid[0], val->rid[1], val->rid[2], val->rid[3],
 1275|  1.48k|		 val->rid[4], sizeof(val->rid), val->applicationID[0],
 1276|  1.48k|		 val->applicationID[1], sizeof(val->applicationID),
 1277|  1.48k|		 val->objectID[0], val->objectID[1], sizeof(val->objectID));
 1278|       |
 1279|  1.48k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.48k|#define SC_SUCCESS				0
  ------------------
 1280|  1.48k|}
card-cac.c:cac_select_ACA:
 1250|    748|{
 1251|       |	return cac_select_file_by_type(card, &cac_ACA_Path, NULL);
 1252|    748|}
card-cac.c:cac_process_ACA:
 1721|     99|{
 1722|     99|	int r;
 1723|     99|	u8 *val = NULL;
 1724|     99|	size_t val_len;
 1725|       |
 1726|     99|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     99|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     99|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     99|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 99]
  |  |  ------------------
  ------------------
 1727|       |
 1728|       |	/* Assuming ACA is already selected */
 1729|     99|	r = cac_get_acr(card, CAC_ACR_SERVICE, &val, &val_len);
  ------------------
  |  |  104|     99|#define CAC_ACR_SERVICE               0x21
  ------------------
 1730|     99|	if (r < 0)
  ------------------
  |  Branch (1730:6): [True: 24, False: 75]
  ------------------
 1731|     24|		goto done;
 1732|       |
 1733|     75|	r = cac_parse_ACA_service(card, priv, val, val_len);
 1734|     75|        if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     75|#define SC_SUCCESS				0
  ------------------
  |  Branch (1734:13): [True: 64, False: 11]
  ------------------
 1735|     64|		priv->aca_path = malloc(sizeof(sc_path_t));
 1736|     64|		if (!priv->aca_path) {
  ------------------
  |  Branch (1736:7): [True: 0, False: 64]
  ------------------
 1737|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1738|      0|			goto done;
 1739|      0|		}
 1740|     64|		memcpy(priv->aca_path, &cac_ACA_Path, sizeof(sc_path_t));
 1741|     64|	}
 1742|     99|done:
 1743|     99|	if (val)
  ------------------
  |  Branch (1743:6): [True: 75, False: 24]
  ------------------
 1744|     75|		free(val);
 1745|     99|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     99|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     99|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     99|	int _ret = r; \
  |  |  |  |  155|     99|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 99, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     99|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 64]
  |  |  |  |  ------------------
  |  |  |  |  157|     99|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     99|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     99|	return _ret; \
  |  |  |  |  163|     99|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1746|     99|}
card-cac.c:cac_get_acr:
  348|     99|{
  349|     99|	u8 *out = NULL;
  350|       |	/* XXX assuming it will not be longer than 255 B */
  351|     99|	size_t len = 256;
  352|     99|	int r;
  353|       |
  354|     99|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     99|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     99|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     99|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 99]
  |  |  ------------------
  ------------------
  355|       |
  356|       |	/* for simplicity we support only ACR without arguments now */
  357|     99|	if (acr_type != 0x00 && acr_type != 0x10
  ------------------
  |  Branch (357:6): [True: 99, False: 0]
  |  Branch (357:26): [True: 99, False: 0]
  ------------------
  358|     99|	    && acr_type != 0x20 && acr_type != 0x21) {
  ------------------
  |  Branch (358:9): [True: 99, False: 0]
  |  Branch (358:29): [True: 0, False: 99]
  ------------------
  359|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  360|      0|	}
  361|       |
  362|     99|	r = cac_apdu_io(card, CAC_INS_GET_ACR, acr_type, 0, NULL, 0, &out, &len);
  ------------------
  |  |   62|     99|#define CAC_INS_GET_ACR               0x4c
  ------------------
  363|     99|	if (len == 0) {
  ------------------
  |  Branch (363:6): [True: 13, False: 86]
  ------------------
  364|     13|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     13|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  365|     13|	}
  366|     99|	if (r < 0)
  ------------------
  |  Branch (366:6): [True: 24, False: 75]
  ------------------
  367|     24|		goto fail;
  368|       |
  369|     75|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|     75|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  370|     75|	    "got %"SC_FORMAT_LEN_SIZE_T"u bytes out=%p", len, out);
  371|       |
  372|     75|	*out_len = len;
  373|     75|	*out_buf = out;
  374|     75|	return SC_SUCCESS;
  ------------------
  |  |   28|     75|#define SC_SUCCESS				0
  ------------------
  375|       |
  376|     24|fail:
  377|     24|	if (out)
  ------------------
  |  Branch (377:6): [True: 13, False: 11]
  ------------------
  378|     13|		free(out);
  379|       |	*out_buf = NULL;
  380|     24|	*out_len = 0;
  381|     24|	return r;
  382|     99|}
card-cac.c:cac_parse_ACA_service:
 1559|     75|{
 1560|     75|	size_t len = 0;
 1561|     75|	const u8 *val_end = val + val_len;
 1562|     75|	int r;
 1563|       |
 1564|     75|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1565|       |
 1566|  5.47k|	for (; val < val_end; val += len) {
  ------------------
  |  Branch (1566:9): [True: 5.46k, False: 7]
  ------------------
 1567|       |		/* get the tag and the length */
 1568|  5.46k|		u8 tag;
 1569|  5.46k|		if (sc_simpletlv_read_tag(&val, val_end - val, &tag, &len) != SC_SUCCESS)
  ------------------
  |  |   28|  5.46k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1569:7): [True: 57, False: 5.40k]
  ------------------
 1570|     57|			break;
 1571|       |
 1572|  5.40k|		switch (tag) {
 1573|    499|		case CAC_TAG_APPLET_FAMILY:
  ------------------
  |  |   85|    499|#define CAC_TAG_APPLET_FAMILY         0x01
  ------------------
  |  Branch (1573:3): [True: 499, False: 4.90k]
  ------------------
 1574|    499|			if (len != 5) {
  ------------------
  |  Branch (1574:8): [True: 349, False: 150]
  ------------------
 1575|    349|				sc_log(card->ctx, "TAG: Applet Information: "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1576|    349|				    "bad length %"SC_FORMAT_LEN_SIZE_T"u", len);
 1577|    349|				break;
 1578|    349|			}
 1579|    150|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    150|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1580|    150|			    "TAG: Applet Information: Family: 0x%02x", val[0]);
 1581|    150|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    150|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1582|    150|			    "     Applet Version: 0x%02x 0x%02x 0x%02x 0x%02x",
 1583|    150|			    val[1], val[2], val[3], val[4]);
 1584|    150|			break;
 1585|    385|		case CAC_TAG_NUMBER_APPLETS:
  ------------------
  |  |   86|    385|#define CAC_TAG_NUMBER_APPLETS        0x94
  ------------------
  |  Branch (1585:3): [True: 385, False: 5.02k]
  ------------------
 1586|    385|			if (len != 1) {
  ------------------
  |  Branch (1586:8): [True: 156, False: 229]
  ------------------
 1587|    156|				sc_log(card->ctx, "TAG: Num applets: "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1588|    156|				    "bad length %"SC_FORMAT_LEN_SIZE_T"u", len);
 1589|    156|				break;
 1590|    156|			}
 1591|    229|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    229|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1592|    229|			    "TAG: Num applets = %hhd", *val);
 1593|    229|			break;
 1594|  1.31k|		case CAC_TAG_APPLET_ENTRY:
  ------------------
  |  |   87|  1.31k|#define CAC_TAG_APPLET_ENTRY          0x93
  ------------------
  |  Branch (1594:3): [True: 1.31k, False: 4.08k]
  ------------------
 1595|       |			/* Make sure we match the outer length */
 1596|  1.31k|			if (len < 3 || val[2] != len - 3) {
  ------------------
  |  Branch (1596:8): [True: 281, False: 1.03k]
  |  Branch (1596:19): [True: 200, False: 838]
  ------------------
 1597|    481|				sc_log(card->ctx, "TAG: Applet Entry: "
  ------------------
  |  |   71|    481|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1598|    481|				    "bad length (%"SC_FORMAT_LEN_SIZE_T
 1599|    481|				    "u) or length of internal buffer", len);
 1600|    481|				break;
 1601|    481|			}
 1602|    838|			sc_debug_hex(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  127|    838|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1603|    838|			    "TAG: Applet Entry: AID", val + 3, val[2]);
 1604|       |			/* This is SimpleTLV prefixed with applet ID (1B) */
 1605|    838|			r = cac_parse_aid(card, priv, val + 3, val[2]);
 1606|    838|			if (r < 0)
  ------------------
  |  Branch (1606:8): [True: 11, False: 827]
  ------------------
 1607|     11|				return r;
 1608|    827|			break;
 1609|  3.20k|		default:
  ------------------
  |  Branch (1609:3): [True: 3.20k, False: 2.20k]
  ------------------
 1610|       |			/* ignore tags we don't understand */
 1611|  3.20k|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  3.20k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1612|  3.20k|			    "TAG: Unknown (0x%02x)", tag);
 1613|  3.20k|			break;
 1614|  5.40k|		}
 1615|  5.40k|	}
 1616|     64|	return SC_SUCCESS;
  ------------------
  |  |   28|     64|#define SC_SUCCESS				0
  ------------------
 1617|     75|}
card-cac.c:cac_parse_aid:
 1283|    838|{
 1284|    838|	cac_object_t new_object;
 1285|    838|	cac_properties_t prop = {0};
 1286|    838|	size_t i;
 1287|    838|	int r;
 1288|       |
 1289|    838|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    838|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    838|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    838|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 838]
  |  |  ------------------
  ------------------
 1290|       |
 1291|       |	/* Search for PKI applets (7 B). Ignore generic objects for now */
 1292|    838|	if (aid_len != 7 || (memcmp(aid, CAC_1_RID "\x01", 6) != 0
  ------------------
  |  |   66|    545|#define CAC_1_RID "\xA0\x00\x00\x00\x79"
  ------------------
  |  Branch (1292:6): [True: 293, False: 545]
  |  Branch (1292:23): [True: 409, False: 136]
  ------------------
 1293|    409|	    && memcmp(aid, CAC_1_RID "\x00", 6) != 0))
  ------------------
  |  |   66|    409|#define CAC_1_RID "\xA0\x00\x00\x00\x79"
  ------------------
  |  Branch (1293:9): [True: 379, False: 30]
  ------------------
 1294|    672|		return SC_SUCCESS;
  ------------------
  |  |   28|    672|#define SC_SUCCESS				0
  ------------------
 1295|       |
 1296|    166|	sc_mem_clear(&new_object.path, sizeof(sc_path_t));
 1297|    166|	memcpy(new_object.path.aid.value, aid, aid_len);
 1298|    166|	new_object.path.aid.len = aid_len;
 1299|       |
 1300|       |	/* Call without OID set will just select the AID without subsequent
 1301|       |	 * OID selection, which we need to figure out just now
 1302|       |	 */
 1303|    166|	r = cac_select_file_by_type(card, &new_object.path, NULL);
 1304|    166|	LOG_TEST_RET(card->ctx, r, "Cannot select AID");
  ------------------
  |  |  174|    166|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    166|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    166|	int _ret = (r); \
  |  |  |  |  168|    166|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 158]
  |  |  |  |  ------------------
  |  |  |  |  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|    166|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 158]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1305|    158|	r = cac_get_properties(card, &prop);
 1306|    158|	LOG_TEST_RET(card->ctx, r, "Cannot get CAC properties");
  ------------------
  |  |  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: 3, False: 155]
  |  |  |  |  ------------------
  |  |  |  |  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|    158|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 155]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1307|       |
 1308|    289|	for (i = 0; i < prop.num_objects; i++) {
  ------------------
  |  Branch (1308:14): [True: 146, False: 143]
  ------------------
 1309|       |		/* don't fail just because we have more certs than we can support */
 1310|    146|		if (priv->cert_next >= MAX_CAC_SLOTS)
  ------------------
  |  |   70|    146|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (1310:7): [True: 12, False: 134]
  ------------------
 1311|     12|			return SC_SUCCESS;
  ------------------
  |  |   28|     12|#define SC_SUCCESS				0
  ------------------
 1312|       |
 1313|    134|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    134|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1314|    134|		    "ACA: pki_object found, cert_next=%d (%s), privkey=%d",
 1315|    134|		    priv->cert_next, get_cac_label(priv->cert_next),
 1316|    134|		    prop.objects[i].privatekey);
 1317|       |
 1318|       |		/* If the private key is not initialized, we can safely
 1319|       |		 * ignore this object here, but increase the pointer to follow
 1320|       |		 * the certificate labels
 1321|       |		 */
 1322|    134|		if (!prop.objects[i].privatekey) {
  ------------------
  |  Branch (1322:7): [True: 113, False: 21]
  ------------------
 1323|    113|			priv->cert_next++;
 1324|    113|			continue;
 1325|    113|		}
 1326|       |
 1327|       |		/* OID here has always 2B */
 1328|     21|		memcpy(new_object.path.value, &prop.objects[i].oid, 2);
 1329|     21|		new_object.path.len = 2;
 1330|     21|		new_object.path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     21|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1331|     21|		new_object.name = get_cac_label(priv->cert_next);
 1332|     21|		new_object.fd = priv->cert_next+1;
 1333|     21|		cac_add_object_to_list(&priv->pki_list, &new_object);
 1334|     21|		priv->cert_next++;
 1335|     21|	}
 1336|       |
 1337|    143|	return SC_SUCCESS;
  ------------------
  |  |   28|    143|#define SC_SUCCESS				0
  ------------------
 1338|    155|}
card-cac.c:cac_find_first_pki_applet:
 1631|    622|{
 1632|    622|	int r, i;
 1633|  9.90k|	for (i = 0; i < MAX_CAC_SLOTS; i++) {
  ------------------
  |  |   70|  9.90k|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (1633:14): [True: 9.33k, False: 565]
  ------------------
 1634|  9.33k|		r = cac_select_pki_applet(card, i);
 1635|  9.33k|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  9.33k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1635:7): [True: 181, False: 9.15k]
  ------------------
 1636|       |			/* Try to read first two bytes of the buffer to
 1637|       |			 * make sure it is not just malfunctioning card
 1638|       |			 */
 1639|    181|			u8 params[2] = {CAC_FILE_TAG, 2};
  ------------------
  |  |   66|    181|#define CAC_FILE_TAG    1
  ------------------
 1640|    181|			u8 data[2], *out_ptr = data;
 1641|    181|			size_t len = 2;
 1642|    181|			r = cac_apdu_io(card, CAC_INS_READ_FILE, 0, 0,
  ------------------
  |  |   61|    181|#define CAC_INS_READ_FILE             0x52  /* read a TL or V file */
  ------------------
 1643|    181|			    &params[0], sizeof(params), &out_ptr, &len);
 1644|    181|			if (r != 2)
  ------------------
  |  Branch (1644:8): [True: 124, False: 57]
  ------------------
 1645|    124|				continue;
 1646|       |
 1647|     57|			*index_out = i;
 1648|     57|			return SC_SUCCESS;
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
 1649|    181|		}
 1650|  9.33k|	}
 1651|    565|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    565|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1652|    622|}
card-cac.c:cac_select_pki_applet:
 1621|  9.89k|{
 1622|  9.89k|	sc_path_t applet_path = cac_cac_pki_obj.path;
 1623|  9.89k|	applet_path.aid.value[applet_path.aid.len-1] = index;
 1624|       |	return cac_select_file_by_type(card, &applet_path, NULL);
 1625|  9.89k|}
card-cac.c:cac_populate_cac_alt:
 1658|     41|{
 1659|     41|	int r, i;
 1660|     41|	cac_object_t pki_obj = cac_cac_pki_obj;
 1661|     41|	u8 buf[100];
 1662|     41|	u8 *val;
 1663|       |
 1664|       |	/* populate PKI objects */
 1665|    562|	for (i = index; i < MAX_CAC_SLOTS; i++) {
  ------------------
  |  |   70|    562|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (1665:18): [True: 521, False: 41]
  ------------------
 1666|    521|		r = cac_select_pki_applet(card, i);
 1667|    521|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    521|#define SC_SUCCESS				0
  ------------------
  |  Branch (1667:7): [True: 336, False: 185]
  ------------------
 1668|    336|			pki_obj.name = get_cac_label(i);
 1669|    336|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    336|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1670|    336|			    "CAC: pki_object found, cert_next=%d (%s),", i, pki_obj.name);
 1671|    336|			pki_obj.path.aid.value[pki_obj.path.aid.len-1] = i;
 1672|    336|			pki_obj.fd = i+1; /* don't use id of zero */
 1673|    336|			cac_add_object_to_list(&priv->pki_list, &pki_obj);
 1674|    336|		}
 1675|    521|	}
 1676|       |
 1677|       |	/* populate non-PKI objects */
 1678|    287|	for (i=0; i < cac_object_count; i++) {
  ------------------
  |  Branch (1678:12): [True: 246, False: 41]
  ------------------
 1679|    246|		r = cac_select_file_by_type(card, &cac_objects[i].path, NULL);
 1680|    246|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    246|#define SC_SUCCESS				0
  ------------------
  |  Branch (1680:7): [True: 151, False: 95]
  ------------------
 1681|    151|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|    151|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1682|    151|			    "CAC: obj_object found, cert_next=%d (%s),",
 1683|    151|			    i, cac_objects[i].name);
 1684|    151|			cac_add_object_to_list(&priv->general_list, &cac_objects[i]);
 1685|    151|		}
 1686|    246|	}
 1687|       |
 1688|       |	/*
 1689|       |	 * create a cuid to simulate the cac 2 cuid.
 1690|       |	 */
 1691|     41|	priv->cuid = cac_cac_cuid;
 1692|       |	/* create a serial number by hashing the first 100 bytes of the
 1693|       |	 * first certificate on the card */
 1694|     41|	r = cac_select_pki_applet(card, index);
 1695|     41|	if (r < 0) {
  ------------------
  |  Branch (1695:6): [True: 33, False: 8]
  ------------------
 1696|     33|		return r; /* shouldn't happen unless the card has been removed or is malfunctioning */
 1697|     33|	}
 1698|      8|	val = buf;
 1699|      8|	r = cac_read_binary(card, 0, val, sizeof(buf), 0);
 1700|      8|	if (r > 0) {
  ------------------
  |  Branch (1700:6): [True: 1, False: 7]
  ------------------
 1701|      1|#ifdef ENABLE_OPENSSL
 1702|      1|		size_t val_len = r;
 1703|      1|		free(priv->cac_id);
 1704|      1|		priv->cac_id = malloc(20);
 1705|      1|		if (priv->cac_id == NULL) {
  ------------------
  |  Branch (1705:7): [True: 0, False: 1]
  ------------------
 1706|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1707|      0|		}
 1708|      1|		SHA1(val, val_len, priv->cac_id);
 1709|      1|		priv->cac_id_len = 20;
 1710|      1|		sc_debug_hex(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  127|      1|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1711|      1|		    "cuid", priv->cac_id, priv->cac_id_len);
 1712|       |#else
 1713|       |		sc_log(card->ctx, "OpenSSL Required");
 1714|       |		return SC_ERROR_NOT_SUPPORTED;
 1715|       |#endif /* ENABLE_OPENSSL */
 1716|      1|	}
 1717|      8|	return SC_SUCCESS;
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
 1718|      8|}
card-cac.c:cac_init:
 1839|    174|{
 1840|    174|	int r;
 1841|    174|	unsigned long flags;
 1842|       |
 1843|    174|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    174|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    174|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    174|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 174]
  |  |  ------------------
  ------------------
 1844|       |
 1845|    174|	r = cac_find_and_initialize(card, 1);
 1846|    174|	if (r < 0) {
  ------------------
  |  Branch (1846:6): [True: 76, False: 98]
  ------------------
 1847|     76|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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|     76|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 76, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1848|     76|	}
 1849|     98|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  111|     98|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 1850|       |
 1851|     98|	_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
 1852|     98|	_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
 1853|     98|	_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
 1854|       |
 1855|     98|	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  557|     98|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|     98|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 1856|       |
 1857|     98|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     98|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     98|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     98|	int _ret = r; \
  |  |  |  |  155|     98|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 98, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     98|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     98|	return _ret; \
  |  |  |  |  163|     98|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1858|     98|}
card-cac.c:cac_finish:
 1231|     98|{
 1232|     98|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|     98|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
 1233|       |
 1234|     98|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     98|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     98|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     98|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 98]
  |  |  ------------------
  ------------------
 1235|     98|	if (priv) {
  ------------------
  |  Branch (1235:6): [True: 98, False: 0]
  ------------------
 1236|     98|		cac_free_private_data(priv);
 1237|     98|	}
 1238|     98|	return SC_SUCCESS;
  ------------------
  |  |   28|     98|#define SC_SUCCESS				0
  ------------------
 1239|     98|}
card-cac.c:cac_read_binary:
  456|      8|{
  457|      8|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|      8|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  458|      8|	int r = 0;
  459|      8|	u8 *tl = NULL, *val = NULL;
  460|      8|	const u8 *tl_ptr, *val_ptr, *tl_start;
  461|      8|	u8 *tlv_ptr;
  462|      8|	const u8 *cert_ptr;
  463|      8|	size_t tl_len = 0, val_len = 0, tlv_len;
  464|      8|	size_t len, tl_head_len, cert_len;
  465|      8|	u8 cert_type, tag;
  466|       |
  467|      8|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  468|       |
  469|       |	/* if we didn't return it all last time, return the remainder */
  470|      8|	if (priv->cached) {
  ------------------
  |  Branch (470:6): [True: 0, False: 8]
  ------------------
  471|      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__
  |  |  ------------------
  ------------------
  472|      0|			 "returning cached value idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u",
  473|      0|			 idx, count);
  474|      0|		if (idx > priv->cache_buf_len) {
  ------------------
  |  Branch (474:7): [True: 0, False: 0]
  ------------------
  475|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|      0|		}
  477|      0|		len = MIN(count, priv->cache_buf_len-idx);
  ------------------
  |  |   70|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  478|      0|		memcpy(buf, &priv->cache_buf[idx], len);
  479|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|      0|	}
  481|       |
  482|      8|	sc_log(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__
  |  |  ------------------
  ------------------
  483|      8|		 "clearing cache idx=%d count=%"SC_FORMAT_LEN_SIZE_T"u",
  484|      8|		 idx, count);
  485|      8|	if (priv->cache_buf) {
  ------------------
  |  Branch (485:6): [True: 0, False: 8]
  ------------------
  486|      0|		free(priv->cache_buf);
  487|      0|		priv->cache_buf = NULL;
  488|      0|		priv->cache_buf_len = 0;
  489|      0|	}
  490|       |
  491|       |
  492|      8|	if (priv->object_type <= 0)
  ------------------
  |  Branch (492:6): [True: 0, False: 8]
  ------------------
  493|      8|		 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  494|       |
  495|      8|	r = cac_read_file(card, CAC_FILE_TAG, &tl, &tl_len);
  ------------------
  |  |   66|      8|#define CAC_FILE_TAG    1
  ------------------
  496|      8|	if (r < 0)  {
  ------------------
  |  Branch (496:6): [True: 2, False: 6]
  ------------------
  497|      2|		goto done;
  498|      2|	}
  499|       |
  500|      6|	r = cac_read_file(card, CAC_FILE_VALUE, &val, &val_len);
  ------------------
  |  |   67|      6|#define CAC_FILE_VALUE  2
  ------------------
  501|      6|	if (r < 0)
  ------------------
  |  Branch (501:6): [True: 1, False: 5]
  ------------------
  502|      1|		goto done;
  503|       |
  504|      5|	switch (priv->object_type) {
  505|      0|	case CAC_OBJECT_TYPE_TLV_FILE:
  ------------------
  |  |  171|      0|#define CAC_OBJECT_TYPE_TLV_FILE	4
  ------------------
  |  Branch (505:2): [True: 0, False: 5]
  ------------------
  506|      0|		tlv_len = tl_len + val_len;
  507|      0|		priv->cache_buf = malloc(tlv_len);
  508|      0|		if (priv->cache_buf == NULL) {
  ------------------
  |  Branch (508:7): [True: 0, False: 0]
  ------------------
  509|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  510|      0|			goto done;
  511|      0|		}
  512|      0|		priv->cache_buf_len = tlv_len;
  513|       |
  514|      0|		for (tl_ptr = tl, val_ptr = val, tlv_ptr = priv->cache_buf;
  515|      0|				tl_len >= 2 && tlv_len > 0;
  ------------------
  |  Branch (515:5): [True: 0, False: 0]
  |  Branch (515:20): [True: 0, False: 0]
  ------------------
  516|      0|				val_len -= len, tlv_len -= len, val_ptr += len, tlv_ptr += len) {
  517|       |			/* get the tag and the length */
  518|      0|			tl_start = tl_ptr;
  519|      0|			r = sc_simpletlv_read_tag(&tl_ptr, tl_len, &tag, &len);
  520|      0|			if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
              			if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS)
  ------------------
  |  |   99|      0|#define SC_ERROR_TLV_END_OF_CONTENTS	-1418
  ------------------
  |  Branch (520:8): [True: 0, False: 0]
  |  Branch (520:27): [True: 0, False: 0]
  ------------------
  521|      0|				break;
  522|      0|			tl_head_len = (tl_ptr - tl_start);
  523|      0|			sc_simpletlv_put_tag(tag, len, tlv_ptr, tlv_len, &tlv_ptr);
  524|      0|			tlv_len -= tl_head_len;
  525|      0|			tl_len -= tl_head_len;
  526|       |
  527|       |			/* don't crash on bad data */
  528|      0|			if (val_len < len) {
  ------------------
  |  Branch (528:8): [True: 0, False: 0]
  ------------------
  529|      0|				sc_log(card->ctx, "Received too long value %"SC_FORMAT_LEN_SIZE_T"u, "
  ------------------
  |  |   71|      0|#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|				    "while only %"SC_FORMAT_LEN_SIZE_T"u left. Truncating", len, val_len);
  531|      0|				len = val_len;
  532|      0|			}
  533|       |			/* if we run out of return space, truncate */
  534|      0|			if (tlv_len < len) {
  ------------------
  |  Branch (534:8): [True: 0, False: 0]
  ------------------
  535|      0|				len = tlv_len;
  536|      0|			}
  537|      0|			memcpy(tlv_ptr, val_ptr, len);
  538|      0|		}
  539|       |		/* fixup the cache_buf_le to reflect for the bad data ignored above */
  540|      0|		priv->cache_buf_len = (tlv_ptr - priv->cache_buf);
  541|      0|		break;
  542|       |
  543|      5|	case CAC_OBJECT_TYPE_CERT:
  ------------------
  |  |  170|      5|#define CAC_OBJECT_TYPE_CERT		1
  ------------------
  |  Branch (543:2): [True: 5, False: 0]
  ------------------
  544|       |		/* read file */
  545|      5|		sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  546|      5|			 " obj= cert_file, val_len=%"SC_FORMAT_LEN_SIZE_T"u (0x%04"SC_FORMAT_LEN_SIZE_T"x)",
  547|      5|			 val_len, val_len);
  548|      5|		cert_len = 0;
  549|      5|		cert_ptr = NULL;
  550|      5|		cert_type = 0;
  551|    549|		for (tl_ptr = tl, val_ptr = val; tl_len >= 2;
  ------------------
  |  Branch (551:36): [True: 546, False: 3]
  ------------------
  552|    546|		    val_len -= len, val_ptr += len, tl_len -= tl_head_len) {
  553|    546|			tl_start = tl_ptr;
  554|    546|			r = sc_simpletlv_read_tag(&tl_ptr, tl_len, &tag, &len);
  555|    546|			if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS)
  ------------------
  |  |   28|  1.09k|#define SC_SUCCESS				0
  ------------------
              			if (r != SC_SUCCESS && r != SC_ERROR_TLV_END_OF_CONTENTS)
  ------------------
  |  |   99|     25|#define SC_ERROR_TLV_END_OF_CONTENTS	-1418
  ------------------
  |  Branch (555:8): [True: 25, False: 521]
  |  Branch (555:27): [True: 0, False: 25]
  ------------------
  556|      0|				break;
  557|    546|			tl_head_len = tl_ptr - tl_start;
  558|       |
  559|       |			/* incomplete value */
  560|    546|			if (val_len < len) {
  ------------------
  |  Branch (560:8): [True: 2, False: 544]
  ------------------
  561|      2|				sc_log(card->ctx, "Read incomplete value %"SC_FORMAT_LEN_SIZE_T"u, "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  562|      2|				    "while only %"SC_FORMAT_LEN_SIZE_T"u left", len, val_len);
  563|      2|				break;
  564|      2|			}
  565|       |
  566|    544|			if (tag == CAC_TAG_CERTIFICATE) {
  ------------------
  |  |   69|    544|#define CAC_TAG_CERTIFICATE           0x70
  ------------------
  |  Branch (566:8): [True: 1, False: 543]
  ------------------
  567|      1|				cert_len = len;
  568|      1|				cert_ptr = val_ptr;
  569|      1|			}
  570|    544|			if (tag == CAC_TAG_CERTINFO) {
  ------------------
  |  |   70|    544|#define CAC_TAG_CERTINFO              0x71
  ------------------
  |  Branch (570:8): [True: 0, False: 544]
  ------------------
  571|      0|				if ((len >= 1) && (val_len >=1)) {
  ------------------
  |  Branch (571:9): [True: 0, False: 0]
  |  Branch (571:23): [True: 0, False: 0]
  ------------------
  572|      0|					cert_type = *val_ptr;
  573|      0|				}
  574|      0|			}
  575|    544|			if (tag == CAC_TAG_MSCUID) {
  ------------------
  |  |   71|    544|#define CAC_TAG_MSCUID                0x72
  ------------------
  |  Branch (575:8): [True: 0, False: 544]
  ------------------
  576|      0|				sc_log_hex(card->ctx, "MSCUID", val_ptr, len);
  ------------------
  |  |  129|      0|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|      0|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|      0|			}
  578|    544|		}
  579|       |		/* if the info byte is 1, then the cert is compressed, decompress it */
  580|      5|		if ((cert_type & 0x3) == 1 && flags) {
  ------------------
  |  Branch (580:7): [True: 0, False: 5]
  |  Branch (580:33): [True: 0, False: 0]
  ------------------
  581|      0|			*flags |= SC_FILE_FLAG_COMPRESSED_AUTO;
  ------------------
  |  |  230|      0|#define SC_FILE_FLAG_COMPRESSED_AUTO		0x01
  ------------------
  582|      0|		}
  583|      5|		if (cert_len > 0) {
  ------------------
  |  Branch (583:7): [True: 1, False: 4]
  ------------------
  584|      1|			priv->cache_buf = malloc(cert_len);
  585|      1|			if (priv->cache_buf == NULL) {
  ------------------
  |  Branch (585:8): [True: 0, False: 1]
  ------------------
  586|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  587|      0|				goto done;
  588|      0|			}
  589|      1|			priv->cache_buf_len = cert_len;
  590|      1|			memcpy(priv->cache_buf, cert_ptr, cert_len);
  591|      4|		} else {
  592|      4|			sc_log(card->ctx, "Can't read zero-length certificate");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  593|      4|			goto done;
  594|      4|		}
  595|      1|		break;
  596|      1|	case CAC_OBJECT_TYPE_GENERIC:
  ------------------
  |  |  172|      0|#define CAC_OBJECT_TYPE_GENERIC		5
  ------------------
  |  Branch (596:2): [True: 0, False: 5]
  ------------------
  597|       |		/* TODO
  598|       |		 * We have some two buffers in unknown encoding that we
  599|       |		 * need to present in PKCS#15 layer.
  600|       |		 */
  601|      0|	default:
  ------------------
  |  Branch (601:2): [True: 0, False: 5]
  ------------------
  602|       |		/* Unknown object type */
  603|      0|		sc_log(card->ctx, "Unknown object type: %x", priv->object_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__
  |  |  ------------------
  ------------------
  604|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  605|      0|		goto done;
  606|      5|	}
  607|       |
  608|       |	/* OK we've read the data, now copy the required portion out to the callers buffer */
  609|      1|	priv->cached = 1;
  610|      1|	len = MIN(count, priv->cache_buf_len-idx);
  ------------------
  |  |   70|      1|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  611|      1|	memcpy(buf, &priv->cache_buf[idx], len);
  612|      1|	r = (int)len;
  613|      8|done:
  614|      8|	if (tl)
  ------------------
  |  Branch (614:6): [True: 6, False: 2]
  ------------------
  615|      6|		free(tl);
  616|      8|	if (val)
  ------------------
  |  Branch (616:6): [True: 5, False: 3]
  ------------------
  617|      5|		free(val);
  618|      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: 7, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  157|      7|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      7|	} 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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  619|      8|}
card-cac.c:cac_card_ctl:
  684|     99|{
  685|     99|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|     99|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  686|       |
  687|     99|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     99|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     99|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     99|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     99|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 99]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  688|     99|	sc_log(card->ctx, "cmd=%ld ptr=%p", cmd, ptr);
  ------------------
  |  |   71|     99|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  689|       |
  690|     99|	if (priv == NULL) {
  ------------------
  |  Branch (690:6): [True: 0, False: 99]
  ------------------
  691|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  692|      0|	}
  693|     99|	switch(cmd) {
  ------------------
  |  Branch (693:9): [True: 0, False: 99]
  ------------------
  694|      0|		case SC_CARDCTL_CAC_GET_ACA_PATH:
  ------------------
  |  Branch (694:3): [True: 0, False: 99]
  ------------------
  695|      0|			return cac_get_ACA_path(card, (sc_path_t *) ptr);
  696|      0|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (696:3): [True: 0, False: 99]
  ------------------
  697|      0|			return cac_get_serial_nr_from_CUID(card, (sc_serial_number_t *) ptr);
  698|      0|		case SC_CARDCTL_CAC_INIT_GET_GENERIC_OBJECTS:
  ------------------
  |  Branch (698:3): [True: 0, False: 99]
  ------------------
  699|      0|			return cac_get_init_and_get_count(&priv->general_list, &priv->general_current, (int *)ptr);
  700|      0|		case SC_CARDCTL_CAC_INIT_GET_CERT_OBJECTS:
  ------------------
  |  Branch (700:3): [True: 0, False: 99]
  ------------------
  701|      0|			return cac_get_init_and_get_count(&priv->pki_list, &priv->pki_current, (int *)ptr);
  702|      0|		case SC_CARDCTL_CAC_GET_NEXT_GENERIC_OBJECT:
  ------------------
  |  Branch (702:3): [True: 0, False: 99]
  ------------------
  703|      0|			return cac_fill_object_info(&priv->general_list, &priv->general_current, (sc_pkcs15_data_info_t *)ptr);
  704|      0|		case SC_CARDCTL_CAC_GET_NEXT_CERT_OBJECT:
  ------------------
  |  Branch (704:3): [True: 0, False: 99]
  ------------------
  705|      0|			return cac_fill_object_info(&priv->pki_list, &priv->pki_current, (sc_pkcs15_data_info_t *)ptr);
  706|      0|		case SC_CARDCTL_CAC_FINAL_GET_GENERIC_OBJECTS:
  ------------------
  |  Branch (706:3): [True: 0, False: 99]
  ------------------
  707|      0|			return cac_final_iterator(&priv->general_list);
  708|      0|		case SC_CARDCTL_CAC_FINAL_GET_CERT_OBJECTS:
  ------------------
  |  Branch (708:3): [True: 0, False: 99]
  ------------------
  709|      0|			return cac_final_iterator(&priv->pki_list);
  710|     99|	}
  711|       |
  712|     99|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|     99|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     99|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     99|	int _ret = r; \
  |  |  |  |  155|     99|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 99, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     99|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     99|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     99|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     99|	return _ret; \
  |  |  |  |  163|     99|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  713|     99|}

sc_get_cac1_driver:
  557|  3.69k|{
  558|  3.69k|	return sc_get_driver();
  559|  3.69k|}
card-cac1.c:sc_get_driver:
  539|  3.69k|{
  540|       |	/* Inherit most of the things from the CAC driver */
  541|  3.69k|	struct sc_card_driver *cac_drv = sc_get_cac_driver();
  542|       |
  543|  3.69k|	cac_ops = *cac_drv->ops;
  544|  3.69k|	cac_ops.match_card = cac_match_card;
  545|  3.69k|	cac_ops.init = cac_init;
  546|  3.69k|	cac_ops.finish = cac_finish;
  547|       |
  548|  3.69k|	cac_ops.select_file =  cac_select_file; /* need to record object type */
  549|  3.69k|	cac_ops.read_binary = cac_read_binary;
  550|  3.69k|	cac_ops.logout = cac_logout;
  551|       |
  552|  3.69k|	return &cac1_drv;
  553|  3.69k|}
card-cac1.c:cac_match_card:
  492|    143|{
  493|    143|	int r;
  494|    143|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  495|       |
  496|    143|	r = cac_find_and_initialize(card, 0);
  497|    143|	return (r == SC_SUCCESS); /* never match */
  ------------------
  |  |   28|    143|#define SC_SUCCESS				0
  ------------------
  498|    143|}
card-cac1.c:cac_find_and_initialize:
  454|    148|{
  455|    148|	int r, index;
  456|    148|	cac_private_data_t *priv = NULL;
  457|       |
  458|       |	/* already initialized? */
  459|    148|	if (card->drv_data) {
  ------------------
  |  Branch (459:6): [True: 0, False: 148]
  ------------------
  460|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  461|      0|	}
  462|       |
  463|       |	/* is this a CAC Alt token without any accompanying structures */
  464|    148|	r = cac_find_first_pki_applet(card, &index);
  465|    148|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    148|#define SC_SUCCESS				0
  ------------------
  |  Branch (465:6): [True: 10, False: 138]
  ------------------
  466|     10|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "PKI applet found, is bare CAC-1");
  ------------------
  |  |   70|     10|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  467|     10|		if (!initialize) /* match card only */
  ------------------
  |  Branch (467:7): [True: 5, False: 5]
  ------------------
  468|      5|			return r;
  469|       |
  470|      5|		if (!priv) {
  ------------------
  |  Branch (470:7): [True: 5, False: 0]
  ------------------
  471|      5|			priv = cac_new_private_data();
  472|      5|			if (!priv)
  ------------------
  |  Branch (472:8): [True: 0, False: 5]
  ------------------
  473|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  474|      5|		}
  475|      5|		card->drv_data = priv; /* needed for the read_binary() */
  476|      5|		r = cac_populate_cac1(card, index, priv);
  477|      5|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (477:7): [True: 1, False: 4]
  ------------------
  478|      1|			card->type = SC_CARD_TYPE_CAC_I;
  479|      1|			return r;
  480|      1|		}
  481|      4|		card->drv_data = NULL; /* reset on failure */
  482|      4|	}
  483|    142|	if (priv) {
  ------------------
  |  Branch (483:6): [True: 4, False: 138]
  ------------------
  484|      4|		cac_free_private_data(priv);
  485|      4|	}
  486|    142|	return r;
  487|    148|}
card-cac1.c:cac_find_first_pki_applet:
  368|    148|{
  369|    148|	int r, i;
  370|       |
  371|  2.39k|	for (i = 0; i < MAX_CAC_SLOTS; i++) {
  ------------------
  |  |   70|  2.39k|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (371:14): [True: 2.25k, False: 138]
  ------------------
  372|  2.25k|		r = cac_select_pki_applet(card, i);
  373|  2.25k|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  2.25k|#define SC_SUCCESS				0
  ------------------
  |  Branch (373:7): [True: 37, False: 2.21k]
  ------------------
  374|     37|			u8 data[2];
  375|     37|			sc_apdu_t apdu;
  376|       |
  377|       |			/* Try to read first two bytes of the buffer to
  378|       |			 * make sure it is not just malfunctioning card
  379|       |			 */
  380|     37|			sc_format_apdu(card, &apdu, SC_APDU_CASE_2,
  ------------------
  |  |  301|     37|#define SC_APDU_CASE_2			0x22
  ------------------
  381|     37|				CAC_INS_GET_CERTIFICATE, 0x00, 0x00);
  ------------------
  |  |   59|     37|#define CAC_INS_GET_CERTIFICATE       0x36  /* CAC1 command to read a certificate */
  ------------------
  382|     37|			apdu.le = 0x02;
  383|     37|			apdu.resplen = 2;
  384|     37|			apdu.resp = data;
  385|     37|			r = sc_transmit_apdu(card, &apdu);
  386|       |			/* SW1 = 0x63 means more data in CAC1 */
  387|     37|			if (r == SC_SUCCESS && apdu.sw1 != 0x63)
  ------------------
  |  |   28|     74|#define SC_SUCCESS				0
  ------------------
  |  Branch (387:8): [True: 27, False: 10]
  |  Branch (387:27): [True: 27, False: 0]
  ------------------
  388|     27|				continue;
  389|       |
  390|     10|			*index_out = i;
  391|     10|			return SC_SUCCESS;
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
  392|     37|		}
  393|  2.25k|	}
  394|    138|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    138|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  395|    148|}
card-cac1.c:cac_select_pki_applet:
  358|  2.33k|{
  359|  2.33k|	sc_path_t applet_path = cac_cac_pki_obj.path;
  360|  2.33k|	applet_path.aid.value[applet_path.aid.len-1] = index;
  361|       |	return cac_select_file_by_type(card, &applet_path, NULL);
  362|  2.33k|}
card-cac1.c:cac_select_file_by_type:
  204|  2.33k|{
  205|  2.33k|	struct sc_context *ctx;
  206|  2.33k|	struct sc_apdu apdu;
  207|  2.33k|	unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
  208|  2.33k|	unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  209|  2.33k|	int r, pathtype;
  210|  2.33k|	size_t pathlen;
  211|  2.33k|	struct sc_file *file = NULL;
  212|  2.33k|	cac_private_data_t *priv;
  213|       |
  214|  2.33k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (214:6): [True: 0, False: 2.33k]
  |  Branch (214:22): [True: 0, False: 2.33k]
  ------------------
  215|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  216|       |
  217|  2.33k|	ctx = card->ctx;
  218|  2.33k|	priv = CAC_DATA(card);
  ------------------
  |  |   61|  2.33k|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  219|       |
  220|  2.33k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  2.33k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.33k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.33k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.33k]
  |  |  ------------------
  ------------------
  221|       |
  222|  2.33k|	memcpy(path, in_path->value, in_path->len);
  223|  2.33k|	pathlen = in_path->len;
  224|  2.33k|	pathtype = in_path->type;
  225|       |
  226|  2.33k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  227|  2.33k|		"path=%s, path->value=%s path->type=%d (%x)",
  228|  2.33k|		sc_print_path(in_path),
  229|  2.33k|		sc_dump_hex(in_path->value, in_path->len),
  230|  2.33k|		in_path->type, in_path->type);
  231|  2.33k|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "file_out=%p index=%d count=%d\n",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  232|  2.33k|		file_out, in_path->index, in_path->count);
  233|       |
  234|       |	/* Sigh, iso7816_select_file expects paths to keys to have specific
  235|       |	 * formats. There is no override. We have to add some bytes to the
  236|       |	 * path to make it happy.
  237|       |	 * We only need to do this for private keys.
  238|       |	 */
  239|  2.33k|	if ((pathlen > 2) && (pathlen <= 4) && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (239:6): [True: 0, False: 2.33k]
  |  Branch (239:23): [True: 0, False: 0]
  |  Branch (239:41): [True: 0, False: 0]
  ------------------
  240|      0|		path += 2;
  241|      0|		pathlen -= 2;
  242|      0|	}
  243|       |
  244|       |
  245|       |	/* CAC has multiple different type of objects that aren't PKCS #15. When we read
  246|       |	 * them we need convert them to something PKCS #15 would understand. Find the object
  247|       |	 * and object type here:
  248|       |	 */
  249|  2.33k|	if (priv) { /* don't record anything if we haven't been initialized yet */
  ------------------
  |  Branch (249:6): [True: 76, False: 2.25k]
  ------------------
  250|       |		/* forget any old cached values */
  251|     76|		if (priv->cache_buf) {
  ------------------
  |  Branch (251:7): [True: 0, False: 76]
  ------------------
  252|      0|			free(priv->cache_buf);
  253|      0|			priv->cache_buf = NULL;
  254|      0|		}
  255|     76|		priv->cache_buf_len = 0;
  256|     76|		priv->cached = 0;
  257|     76|	}
  258|       |
  259|  2.33k|	if (in_path->aid.len) {
  ------------------
  |  Branch (259:6): [True: 2.33k, False: 0]
  ------------------
  260|  2.33k|		if (!pathlen) {
  ------------------
  |  Branch (260:7): [True: 2.33k, False: 0]
  ------------------
  261|  2.33k|			memcpy(path, in_path->aid.value, in_path->aid.len);
  262|  2.33k|			pathlen = in_path->aid.len;
  263|  2.33k|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|  2.33k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  264|  2.33k|		} else {
  265|       |			/* First, select the application */
  266|      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__
  |  |  ------------------
  ------------------
  267|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  268|      0|			apdu.data = in_path->aid.value;
  269|      0|			apdu.datalen = in_path->aid.len;
  270|      0|			apdu.lc = in_path->aid.len;
  271|       |
  272|      0|			r = sc_transmit_apdu(card, &apdu);
  273|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  274|      0|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  275|      0|			if (r)
  ------------------
  |  Branch (275:8): [True: 0, False: 0]
  ------------------
  276|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  277|       |
  278|      0|		}
  279|  2.33k|	}
  280|       |
  281|  2.33k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  294|  2.33k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  282|       |
  283|  2.33k|	switch (pathtype) {
  284|       |	/* ideally we would had SC_PATH_TYPE_OBJECT_ID and add code to the iso7816 select.
  285|       |	 * Unfortunately we'd also need to update the caching code as well. For now just
  286|       |	 * use FILE_ID and change p1 here */
  287|      0|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (287:2): [True: 0, False: 2.33k]
  ------------------
  288|      0|		apdu.p1 = 2;
  289|      0|		if (pathlen != 2)
  ------------------
  |  Branch (289:7): [True: 0, False: 0]
  ------------------
  290|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  291|      0|		break;
  292|  2.33k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  2.33k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (292:2): [True: 2.33k, False: 0]
  ------------------
  293|  2.33k|		apdu.p1 = 4;
  294|  2.33k|		break;
  295|      0|	default:
  ------------------
  |  Branch (295:2): [True: 0, False: 2.33k]
  ------------------
  296|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|  2.33k|	}
  298|  2.33k|	apdu.lc = pathlen;
  299|  2.33k|	apdu.data = path;
  300|  2.33k|	apdu.datalen = pathlen;
  301|  2.33k|	apdu.resp = buf;
  302|  2.33k|	apdu.resplen = sizeof(buf);
  303|  2.33k|	apdu.le = sc_get_max_recv_size(card) < 256 ? sc_get_max_recv_size(card) : 256;
  ------------------
  |  Branch (303:12): [True: 0, False: 2.33k]
  ------------------
  304|  2.33k|	apdu.p2 = 0x00;
  305|       |
  306|  2.33k|	r = sc_transmit_apdu(card, &apdu);
  307|  2.33k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.33k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.33k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.33k|	int _ret = (r); \
  |  |  |  |  168|  2.33k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 2.32k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.33k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.32k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  308|       |
  309|  2.32k|	if (file_out == NULL) {
  ------------------
  |  Branch (309:6): [True: 2.32k, False: 0]
  ------------------
  310|       |		/* For some cards 'SELECT' can be only with request to return FCI/FCP. */
  311|  2.32k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  312|  2.32k|		if (apdu.sw1 == 0x6A && apdu.sw2 == 0x86)   {
  ------------------
  |  Branch (312:7): [True: 16, False: 2.30k]
  |  Branch (312:27): [True: 16, False: 0]
  ------------------
  313|     16|			apdu.p2 = 0x00;
  314|     16|			apdu.resplen = sizeof(buf);
  315|     16|			if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS)
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
  |  Branch (315:8): [True: 16, False: 0]
  ------------------
  316|     16|				r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  317|     16|		}
  318|  2.32k|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (318:7): [True: 0, False: 2.32k]
  ------------------
  319|  2.32k|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  320|  2.32k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|  2.25k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.25k, False: 66]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  321|  2.32k|	}
  322|       |
  323|      0|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  324|      0|	if (r)
  ------------------
  |  Branch (324:6): [True: 0, False: 0]
  ------------------
  325|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  326|       |
  327|       |	/* CAC cards never return FCI, fake one */
  328|      0|	file = sc_file_new();
  329|      0|	if (file == NULL)
  ------------------
  |  Branch (329:6): [True: 0, False: 0]
  ------------------
  330|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  331|      0|	file->path = *in_path;
  332|      0|	file->size = CAC_MAX_SIZE; /* we don't know how big, just give a large size until we can read the file */
  ------------------
  |  |   26|      0|#define CAC_MAX_SIZE 4096		/* arbitrary, just needs to be 'large enough' */
  ------------------
  333|       |
  334|      0|	*file_out = file;
  335|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  336|       |
  337|      0|}
card-cac1.c:cac_populate_cac1:
  398|      5|{
  399|      5|	int r, i;
  400|      5|	cac_object_t pki_obj = cac_cac_pki_obj;
  401|      5|	u8 buf[100];
  402|      5|	u8 *val;
  403|      5|	size_t val_len;
  404|       |
  405|       |	/* populate PKI objects */
  406|     76|	for (i = index; i < MAX_CAC_SLOTS; i++) {
  ------------------
  |  |   70|     76|#define MAX_CAC_SLOTS 16		/* Maximum number of slots is 16 now */
  ------------------
  |  Branch (406:18): [True: 71, False: 5]
  ------------------
  407|     71|		r = cac_select_pki_applet(card, i);
  408|     71|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     71|#define SC_SUCCESS				0
  ------------------
  |  Branch (408:7): [True: 28, False: 43]
  ------------------
  409|     28|			pki_obj.name = get_cac_label(i);
  410|     28|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|     28|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  411|     28|				"CAC: pki_object found, cert_next=%d (%s)",
  412|     28|				i, pki_obj.name);
  413|     28|			pki_obj.path.aid.value[pki_obj.path.aid.len-1] = i;
  414|     28|			pki_obj.fd = i+1; /* don't use id of zero */
  415|     28|			cac_add_object_to_list(&priv->pki_list, &pki_obj);
  416|     28|		}
  417|     71|	}
  418|       |
  419|       |	/*
  420|       |	 * create a cuid to simulate the cac 2 cuid.
  421|       |	 */
  422|      5|	priv->cuid = cac_cac_cuid;
  423|       |	/* create a serial number by hashing the first 100 bytes of the
  424|       |	 * first certificate on the card */
  425|      5|	r = cac_select_pki_applet(card, index);
  426|      5|	if (r < 0) {
  ------------------
  |  Branch (426:6): [True: 4, False: 1]
  ------------------
  427|      4|		return r; /* shouldn't happen unless the card has been removed or is malfunctioning */
  428|      4|	}
  429|      1|	val = buf;
  430|      1|	val_len = sizeof(buf);
  431|      1|	r = cac_cac1_get_certificate(card, &val, &val_len);
  432|      1|	if (r >= 0) {
  ------------------
  |  Branch (432:6): [True: 0, False: 1]
  ------------------
  433|      0|		priv->cac_id = malloc(20);
  434|      0|		if (priv->cac_id == NULL) {
  ------------------
  |  Branch (434:7): [True: 0, False: 0]
  ------------------
  435|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  436|      0|		}
  437|      0|#ifdef ENABLE_OPENSSL
  438|      0|		SHA1(val, val_len, priv->cac_id);
  439|      0|		priv->cac_id_len = 20;
  440|      0|		sc_debug_hex(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |  127|      0|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  441|      0|			"cuid", priv->cac_id, priv->cac_id_len);
  442|       |#else
  443|       |		sc_log(card->ctx, "OpenSSL Required");
  444|       |		return SC_ERROR_NOT_SUPPORTED;
  445|       |#endif /* ENABLE_OPENSSL */
  446|      0|	}
  447|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  448|      1|}
card-cac1.c:cac_cac1_get_certificate:
   65|      1|{
   66|      1|	u8 buf[CAC_MAX_SIZE];
   67|      1|	u8 *out_ptr;
   68|      1|	size_t size = 0;
   69|      1|	size_t left = 0;
   70|      1|	size_t len;
   71|      1|	sc_apdu_t apdu;
   72|      1|	int r = SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
   73|      1|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   74|       |	/* get the size */
   75|      1|	size = left = *out_buf ? *out_len : sizeof(buf);
  ------------------
  |  Branch (75:16): [True: 1, False: 0]
  ------------------
   76|      1|	out_ptr = *out_buf ? *out_buf : buf;
  ------------------
  |  Branch (76:12): [True: 1, False: 0]
  ------------------
   77|      1|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, CAC_INS_GET_CERTIFICATE, 0, 0 );
  ------------------
  |  |  292|      1|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
              	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, CAC_INS_GET_CERTIFICATE, 0, 0 );
  ------------------
  |  |   59|      1|#define CAC_INS_GET_CERTIFICATE       0x36  /* CAC1 command to read a certificate */
  ------------------
   78|      1|	len = MIN(left, 100);
  ------------------
  |  |   70|      1|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 1]
  |  |  ------------------
  ------------------
   79|      1|	while (left > 0) {
  ------------------
  |  Branch (79:9): [True: 1, False: 0]
  ------------------
   80|      1|		apdu.resp = out_ptr;
   81|      1|		apdu.le = len;
   82|      1|		apdu.resplen = left;
   83|      1|		r = sc_transmit_apdu(card, &apdu);
   84|      1|		if (r < 0) {
  ------------------
  |  Branch (84:7): [True: 1, False: 0]
  ------------------
   85|      1|			break;
   86|      1|		}
   87|      0|		if (apdu.resplen == 0) {
  ------------------
  |  Branch (87:7): [True: 0, False: 0]
  ------------------
   88|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   89|      0|			break;
   90|      0|		}
   91|       |		/* in the old CAC-1, 0x63 means 'more data' in addition to 'pin failed' */
   92|      0|		if (apdu.sw1 != 0x63 || apdu.sw2 < 1)  {
  ------------------
  |  Branch (92:7): [True: 0, False: 0]
  |  Branch (92:27): [True: 0, False: 0]
  ------------------
   93|       |			/* we've either finished reading, or hit an error, break */
   94|      0|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
   95|      0|			left -= apdu.resplen;
   96|      0|			break;
   97|      0|		}
   98|       |		/* Adjust the lengths */
   99|      0|		left -= apdu.resplen;
  100|      0|		out_ptr += apdu.resplen;
  101|      0|		len = MIN(left, apdu.sw2);
  ------------------
  |  |   70|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  102|      0|	}
  103|      1|	if (r < 0) {
  ------------------
  |  Branch (103:6): [True: 1, False: 0]
  ------------------
  104|      1|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  105|      1|	}
  106|      0|	r = (int)(size - left);
  107|      0|	if (*out_buf == NULL) {
  ------------------
  |  Branch (107:6): [True: 0, False: 0]
  ------------------
  108|      0|		*out_buf = malloc(r);
  109|      0|		if (*out_buf == NULL) {
  ------------------
  |  Branch (109:7): [True: 0, False: 0]
  ------------------
  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|      0|		memcpy(*out_buf, buf, r);
  114|      0|	}
  115|      0|	*out_len = r;
  116|      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]
  |  |  ------------------
  ------------------
  117|      0|}
card-cac1.c:cac_init:
  502|      5|{
  503|      5|	int r;
  504|      5|	unsigned long flags;
  505|       |
  506|      5|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  507|       |
  508|      5|	r = cac_find_and_initialize(card, 1);
  509|      5|	if (r < 0) {
  ------------------
  |  Branch (509:6): [True: 4, False: 1]
  ------------------
  510|      4|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  511|      4|	}
  512|      1|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  111|      1|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  513|       |
  514|      1|	_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
  515|      1|	_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
  516|      1|	_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
  517|       |
  518|      1|	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  557|      1|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|      1|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  519|       |
  520|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  521|      1|}
card-cac1.c:cac_finish:
  345|      1|{
  346|      1|	cac_private_data_t * priv = CAC_DATA(card);
  ------------------
  |  |   61|      1|#define CAC_DATA(card) ((cac_private_data_t*)card->drv_data)
  ------------------
  347|       |
  348|      1|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  349|      1|	if (priv) {
  ------------------
  |  Branch (349:6): [True: 1, False: 0]
  ------------------
  350|      1|		cac_free_private_data(priv);
  351|      1|	}
  352|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  353|      1|}

sc_get_cardos_driver:
 1570|  3.69k|{
 1571|  3.69k|	return sc_get_driver();
 1572|  3.69k|}
card-cardos.c:sc_get_driver:
 1545|  3.69k|{
 1546|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1546:6): [True: 1, False: 3.69k]
  ------------------
 1547|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1548|  3.69k|	cardos_ops = *iso_ops;
 1549|  3.69k|	cardos_ops.match_card = cardos_match_card;
 1550|  3.69k|	cardos_ops.init = cardos_init;
 1551|  3.69k|	cardos_ops.finish = cardos_finish;
 1552|  3.69k|	cardos_ops.select_file = cardos_select_file;
 1553|  3.69k|	cardos_ops.create_file = cardos_create_file;
 1554|  3.69k|	cardos_ops.set_security_env = cardos_set_security_env;
 1555|  3.69k|	cardos_ops.restore_security_env = cardos_restore_security_env;
 1556|  3.69k|	cardos_ops.compute_signature = cardos_compute_signature;
 1557|  3.69k|	cardos_ops.decipher = cardos_decipher;
 1558|       |
 1559|  3.69k|	cardos_ops.list_files = cardos_list_files;
 1560|  3.69k|	cardos_ops.check_sw = cardos_check_sw;
 1561|  3.69k|	cardos_ops.card_ctl = cardos_card_ctl;
 1562|  3.69k|	cardos_ops.pin_cmd = cardos_pin_cmd;
 1563|  3.69k|	cardos_ops.logout  = cardos_logout;
 1564|       |
 1565|  3.69k|	return &cardos_drv;
 1566|  3.69k|}
card-cardos.c:cardos_match_card:
   76|  3.64k|{
   77|  3.64k|	unsigned char atr[SC_MAX_ATR_SIZE] = {0};
   78|  3.64k|	int i;
   79|       |
   80|  3.64k|	i = _sc_match_atr(card, cardos_atrs, &card->type);
   81|  3.64k|	if (i < 0)
  ------------------
  |  Branch (81:6): [True: 3.39k, False: 243]
  ------------------
   82|  3.39k|		return 0;
   83|       |
   84|    243|	memcpy(atr, card->atr.value, card->atr.len);
   85|       |
   86|       |	/* Do not change card type for CIE! */
   87|    243|	if (card->type == SC_CARD_TYPE_CARDOS_CIE_V1)
  ------------------
  |  Branch (87:6): [True: 0, False: 243]
  ------------------
   88|      0|		return 1;
   89|    243|	if (card->type == SC_CARD_TYPE_CARDOS_M4_4)
  ------------------
  |  Branch (89:6): [True: 0, False: 243]
  ------------------
   90|      0|		return 1;
   91|    243|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0)
  ------------------
  |  Branch (91:6): [True: 0, False: 243]
  ------------------
   92|      0|		return 1;
   93|    243|	if (card->type == SC_CARD_TYPE_CARDOS_V5_3)
  ------------------
  |  Branch (93:6): [True: 129, False: 114]
  ------------------
   94|    129|		return 1;
   95|    114|	if (card->type == SC_CARD_TYPE_CARDOS_M4_2) {
  ------------------
  |  Branch (95:6): [True: 114, False: 0]
  ------------------
   96|    114|		int rv;
   97|    114|		sc_apdu_t apdu = {0};
   98|    114|		u8 rbuf[SC_MAX_APDU_BUFFER_SIZE] = {0};
   99|       |		/* first check some additional ATR bytes */
  100|    114|		if ((atr[4] != 0xff && atr[4] != 0x02) ||
  ------------------
  |  Branch (100:8): [True: 0, False: 114]
  |  Branch (100:26): [True: 0, False: 0]
  ------------------
  101|    114|		    (atr[6] != 0x10 && atr[6] != 0x0a) ||
  ------------------
  |  Branch (101:8): [True: 114, False: 0]
  |  Branch (101:26): [True: 0, False: 114]
  ------------------
  102|    114|		    (atr[9] != 0x55 && atr[9] != 0x58))
  ------------------
  |  Branch (102:8): [True: 0, False: 114]
  |  Branch (102:26): [True: 0, False: 0]
  ------------------
  103|      0|			return 0;
  104|       |		/* get the os version using GET DATA and compare it with
  105|       |		 * version in the ATR */
  106|    114|		sc_log(card->ctx,  "checking cardos version ...");
  ------------------
  |  |   71|    114|#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|    114|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x82);
  ------------------
  |  |  292|    114|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  108|    114|		apdu.resp = rbuf;
  109|    114|		apdu.resplen = sizeof(rbuf);
  110|    114|		apdu.le = 256;
  111|    114|		apdu.lc = 0;
  112|    114|		rv = sc_transmit_apdu(card, &apdu);
  113|    114|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  114|    114|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00 || apdu.resplen < 2)
  ------------------
  |  Branch (114:7): [True: 0, False: 114]
  |  Branch (114:27): [True: 0, False: 114]
  |  Branch (114:47): [True: 0, False: 114]
  ------------------
  115|      0|			return 0;
  116|    114|		if (apdu.resp[0] != atr[10] ||
  ------------------
  |  Branch (116:7): [True: 0, False: 114]
  ------------------
  117|    114|		    apdu.resp[1] != atr[11])
  ------------------
  |  Branch (117:7): [True: 0, False: 114]
  ------------------
  118|       |			/* version mismatch */
  119|      0|			return 0;
  120|    114|		if (atr[11] <= 0x04) {
  ------------------
  |  Branch (120:7): [True: 109, False: 5]
  ------------------
  121|    109|			sc_log(card->ctx,  "found cardos m4.01");
  ------------------
  |  |   71|    109|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  122|    109|			card->type = SC_CARD_TYPE_CARDOS_M4_01;
  123|    109|		} else if (atr[11] == 0x08) {
  ------------------
  |  Branch (123:14): [True: 0, False: 5]
  ------------------
  124|      0|			sc_log(card->ctx,  "found cardos v4.3b");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  125|      0|			card->type = SC_CARD_TYPE_CARDOS_M4_3;
  126|      5|		} else if (atr[11] == 0x09) {
  ------------------
  |  Branch (126:14): [True: 0, False: 5]
  ------------------
  127|      0|			sc_log(card->ctx,  "found cardos v4.2b");
  ------------------
  |  |   71|      0|#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|      0|			card->type = SC_CARD_TYPE_CARDOS_M4_2B;
  129|      5|		} else if (atr[11] >= 0x0B) {
  ------------------
  |  Branch (129:14): [True: 0, False: 5]
  ------------------
  130|      0|			sc_log(card->ctx,  "found cardos v4.2c or higher");
  ------------------
  |  |   71|      0|#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|      0|			card->type = SC_CARD_TYPE_CARDOS_M4_2C;
  132|      5|		} else {
  133|      5|			sc_log(card->ctx,  "found cardos m4.2");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  134|      5|		}
  135|    114|	}
  136|    114|	return 1;
  137|    114|}
card-cardos.c:cardos_init:
  212|    243|{
  213|    243|	cardos_data_t * priv = NULL;
  214|    243|	unsigned long flags = 0;
  215|    243|	size_t data_field_length;
  216|    243|	sc_apdu_t apdu;
  217|    243|	u8 rbuf[2];
  218|    243|	int r;
  219|       |
  220|    243|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  221|       |
  222|    243|	priv = calloc(1, sizeof(cardos_data_t));
  223|    243|	if (!priv)
  ------------------
  |  Branch (223:6): [True: 0, False: 243]
  ------------------
  224|    243|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  225|    243|	card->drv_data = priv;
  226|       |
  227|    243|	card->name = "Atos CardOS";
  228|    243|	card->cla = 0x00;
  229|       |
  230|       |	/* let user override flags and type from opensc.conf */
  231|       |	/* user can override card->type too.*/
  232|    243|	if (card->flags) {
  ------------------
  |  Branch (232:6): [True: 0, False: 243]
  ------------------
  233|      0|	    flags = card->flags;
  234|    243|	} else {
  235|       |
  236|       |		/* Set up algorithm info. */
  237|    243|		flags = 0;
  238|    243|		if (card->type == SC_CARD_TYPE_CARDOS_V5_0) {
  ------------------
  |  Branch (238:7): [True: 0, False: 243]
  ------------------
  239|      0|			flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  120|      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) */
  |  |  ------------------
  |  |  |  |  118|      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) */
  |  |  ------------------
  |  |  |  |  119|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  240|    243|		} else if(card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (240:13): [True: 129, False: 114]
  ------------------
  241|    129|			flags |= SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  111|    129|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  242|    129|				| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  142|    129|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  243|    129|				| SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    129|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  244|    129|		} else {
  245|    114|			flags |= SC_ALGORITHM_RSA_RAW
  ------------------
  |  |  111|    114|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  246|    114|				| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  142|    114|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  247|    114|				| SC_ALGORITHM_NEED_USAGE
  ------------------
  |  |  104|    114|#define SC_ALGORITHM_NEED_USAGE		0x40000000
  ------------------
  248|    114|				| SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    114|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  249|    114|		}
  250|    243|	}
  251|       |
  252|    243|	priv->flags = flags;
  253|       |
  254|    243|	if (card->type == SC_CARD_TYPE_CARDOS_M4_2) {
  ------------------
  |  Branch (254:6): [True: 5, False: 238]
  ------------------
  255|      5|		r = cardos_have_2048bit_package(card);
  256|      5|		if (r < 0) {
  ------------------
  |  Branch (256:7): [True: 0, False: 5]
  ------------------
  257|      0|			r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  258|      0|			goto err;
  259|      0|		}
  260|      5|		if (r == 1)
  ------------------
  |  Branch (260:7): [True: 1, False: 4]
  ------------------
  261|      1|			priv->rsa_2048 = 1;
  262|      5|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|      5|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  263|    238|	} else if (card->type == SC_CARD_TYPE_CARDOS_M4_3
  ------------------
  |  Branch (263:13): [True: 0, False: 238]
  ------------------
  264|    238|		|| card->type == SC_CARD_TYPE_CARDOS_M4_2B
  ------------------
  |  Branch (264:6): [True: 0, False: 238]
  ------------------
  265|    238|		|| card->type == SC_CARD_TYPE_CARDOS_M4_2C
  ------------------
  |  Branch (265:6): [True: 0, False: 238]
  ------------------
  266|    238|		|| card->type == SC_CARD_TYPE_CARDOS_M4_4
  ------------------
  |  Branch (266:6): [True: 0, False: 238]
  ------------------
  267|    238|		|| card->type == SC_CARD_TYPE_CARDOS_V5_0
  ------------------
  |  Branch (267:6): [True: 0, False: 238]
  ------------------
  268|    238|		|| card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (268:6): [True: 129, False: 109]
  ------------------
  269|    129|		priv->rsa_2048 = 1;
  270|    129|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|    129|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  271|       |		/* TODO check this. EC only if in supported_algo */
  272|    129|		priv->ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  210|    129|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		priv->ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  211|    129|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  273|    129|	}
  274|       |
  275|       |	/* probe DATA FIELD LENGTH with GET DATA */
  276|    243|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x8D);
  ------------------
  |  |  292|    243|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  277|    243|	apdu.le = sizeof rbuf;
  278|    243|	apdu.resp = rbuf;
  279|    243|	apdu.resplen = sizeof(rbuf);
  280|       |
  281|    243|	r = sc_transmit_apdu(card, &apdu);
  282|    243|	if (r < 0)
  ------------------
  |  Branch (282:6): [True: 0, False: 243]
  ------------------
  283|    243|		LOG_TEST_GOTO_ERR(card->ctx,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  284|    243|				SC_ERROR_INVALID_CARD,
  285|    243|				"APDU transmit failed");
  286|    243|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  287|    243|	if (r < 0)
  ------------------
  |  Branch (287:6): [True: 5, False: 238]
  ------------------
  288|    243|		LOG_TEST_GOTO_ERR(card->ctx,
  ------------------
  |  |  184|      5|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      5|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      5|	int _ret = (r); \
  |  |  |  |  178|      5|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      5|		goto err; \
  |  |  |  |  182|      5|	} \
  |  |  |  |  183|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  289|    238|				SC_ERROR_INVALID_CARD,
  290|    238|				"GET DATA command returned error");
  291|    238|	if (apdu.resplen != 2) {
  ------------------
  |  Branch (291:6): [True: 1, False: 237]
  ------------------
  292|      1|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      1|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  293|      1|		goto err;
  294|      1|	}
  295|    237|	data_field_length = ((rbuf[0] << 8) | rbuf[1]);
  296|       |
  297|       |	/* TODO is this really needed? strip the length of possible Lc and Le bytes */
  298|       |
  299|       |	/* Use Min card sizes and reader too. for V5_3 at least*/
  300|       |
  301|    237|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (301:6): [True: 0, False: 237]
  |  Branch (301:48): [True: 128, False: 109]
  ------------------
  302|    128|		sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "data_field_length:%"SC_FORMAT_LEN_SIZE_T"u "
  ------------------
  |  |   70|    128|#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)
  |  |  ------------------
  |  |  |  |  305|    128|				data_field_length, card->reader->max_send_size, card->reader->max_recv_size,
  |  |  |  |  306|    128|				(card->caps & SC_CARD_CAP_APDU_EXT) ? "SC_CARD_CAP_APDU_EXT" : " ");
  |  |  |  |  ------------------
  |  |  |  |  |  |  554|    128|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  303|    128|				"card->reader->max_send_size:%"SC_FORMAT_LEN_SIZE_T"u "
  304|    128|				"card->reader->max_recv_size:%"SC_FORMAT_LEN_SIZE_T"u %s",
  305|    128|				data_field_length, card->reader->max_send_size, card->reader->max_recv_size,
  306|    128|				(card->caps & SC_CARD_CAP_APDU_EXT) ? "SC_CARD_CAP_APDU_EXT" : " ");
  307|       |
  308|    128|		if (card->caps & SC_CARD_CAP_APDU_EXT) {
  ------------------
  |  |  554|    128|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (308:7): [True: 128, False: 0]
  ------------------
  309|    128|			card->max_send_size  = data_field_length - 6;
  310|       |#ifdef _WIN32
  311|       |			/* Windows does not support PCSC PART_10 and may have forced reader to 255/256
  312|       |			 * https://github.com/OpenSC/OpenSC/commit/eddea6f3c2d3dafc2c09eba6695c745a61b5186f
  313|       |			 * may have reset this. if so, will override and force extended
  314|       |			 * Most, if not all, cardos cards do extended, but not chaining
  315|       |			 */
  316|       |			if (card->reader->max_send_size == 255 && card->reader->max_recv_size == 256) {
  317|       |				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "resetting reader to use data_field_length");
  318|       |				card->reader->max_send_size = data_field_length - 6;
  319|       |				card->reader->max_recv_size = data_field_length - 3;
  320|       |			}
  321|       |#endif
  322|    128|		} else
  323|      0|			card->max_send_size = data_field_length - 3;
  324|       |
  325|    128|		card->max_send_size = sc_get_max_send_size(card); /* include reader sizes and protocol */
  326|    128|		card->max_recv_size = data_field_length - 2;
  327|    128|		card->max_recv_size = sc_get_max_recv_size(card);
  328|    128|	} else {
  329|       |		/* old way, disregards reader capabilities */
  330|    109|		if (card->caps & SC_CARD_CAP_APDU_EXT)
  ------------------
  |  |  554|    109|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (330:7): [True: 0, False: 109]
  ------------------
  331|      0|			card->max_send_size = data_field_length - 6;
  332|    109|		else
  333|    109|			card->max_send_size = data_field_length - 3;
  334|       |		/* strip the length of SW bytes */
  335|    109|		card->max_recv_size = data_field_length - 2;
  336|    109|	}
  337|       |
  338|       |	/*for new cards, wait till after sc_pkcs15_bind_internal reads tokeninfo */
  339|    237|	if (card->type != SC_CARD_TYPE_CARDOS_V5_0 && card->type != SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (339:6): [True: 237, False: 0]
  |  Branch (339:48): [True: 109, False: 128]
  ------------------
  340|    109|		r = cardos_add_algs(card, flags, 0, 0);
  341|    109|	}
  342|       |
  343|    243|err:
  344|    243|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    243|#define SC_SUCCESS				0
  ------------------
  |  Branch (344:6): [True: 6, False: 237]
  ------------------
  345|      6|		free(priv);
  346|      6|		card->drv_data = NULL;
  347|      6|	}
  348|       |
  349|    243|	return r;
  350|    237|}
card-cardos.c:cardos_have_2048bit_package:
  140|      5|{
  141|      5|	sc_apdu_t apdu;
  142|      5|        u8        rbuf[SC_MAX_APDU_BUFFER_SIZE];
  143|      5|        int       r;
  144|      5|	const u8  *p = rbuf, *q, *pp;
  145|      5|	size_t    len, tlen = 0, ilen = 0;
  146|       |
  147|      5|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x88);
  ------------------
  |  |  292|      5|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  148|      5|	apdu.resp    = rbuf;
  149|      5|	apdu.resplen = sizeof(rbuf);
  150|      5|	apdu.lc = 0;
  151|      5|	apdu.le = 256;
  152|      5|	r = sc_transmit_apdu(card, &apdu);
  153|      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: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|       |
  155|      5|	if ((len = apdu.resplen) == 0)
  ------------------
  |  Branch (155:6): [True: 0, False: 5]
  ------------------
  156|       |		/* looks like no package has been installed  */
  157|      0|		return 0;
  158|       |
  159|      8|	while (len != 0) {
  ------------------
  |  Branch (159:9): [True: 7, False: 1]
  ------------------
  160|      7|		pp = sc_asn1_find_tag(card->ctx, p, len, 0xe1, &tlen);
  161|      7|		if (pp == NULL)
  ------------------
  |  Branch (161:7): [True: 1, False: 6]
  ------------------
  162|      1|			return 0;
  163|      6|		q = sc_asn1_find_tag(card->ctx, pp, tlen, 0x01, &ilen);
  164|      6|		if (q == NULL || ilen != 4)
  ------------------
  |  Branch (164:7): [True: 1, False: 5]
  |  Branch (164:20): [True: 1, False: 4]
  ------------------
  165|      2|			return 0;
  166|      4|		if (q[0] == 0x1c)
  ------------------
  |  Branch (166:7): [True: 1, False: 3]
  ------------------
  167|      1|			return 1;
  168|      3|		p   += tlen;
  169|      3|		len -= tlen + 2;
  170|      3|	}
  171|       |
  172|      1|	return 0;
  173|      5|}
card-cardos.c:cardos_add_algs:
  179|    163|{
  180|       |
  181|    163|	cardos_data_t * priv = (cardos_data_t *)card->drv_data;
  182|       |
  183|    163|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    163|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    163|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    163|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 163]
  |  |  ------------------
  ------------------
  184|       |
  185|    163|	_sc_card_add_rsa_alg(card,  512, flags, 0);
  186|    163|	_sc_card_add_rsa_alg(card,  768, flags, 0);
  187|    163|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  188|    163|	if (priv->rsa_2048 == 1) {
  ------------------
  |  Branch (188:6): [True: 54, False: 109]
  ------------------
  189|     54|		_sc_card_add_rsa_alg(card, 1280, flags, 0);
  190|     54|		_sc_card_add_rsa_alg(card, 1536, flags, 0);
  191|     54|		_sc_card_add_rsa_alg(card, 1792, flags, 0);
  192|     54|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  193|     54|	}
  194|       |
  195|    163|	if (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3) {
  ------------------
  |  Branch (195:6): [True: 0, False: 163]
  |  Branch (195:48): [True: 54, False: 109]
  ------------------
  196|       |		/* Starting with CardOS 5, the card supports PIN query commands */
  197|     54|		card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|     54|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  198|     54|		_sc_card_add_rsa_alg(card, 3072, flags, 0);
  199|     54|		_sc_card_add_rsa_alg(card, 4096, flags, 0);
  200|     54|	}
  201|       |
  202|       |	/* TODO need to get sizes from supported_algos too */
  203|    163|	if (ec_flags != 0) {
  ------------------
  |  Branch (203:6): [True: 2, False: 161]
  ------------------
  204|      2|		 _sc_card_add_ec_alg(card, 256, ec_flags, priv->ext_flags, NULL);
  205|      2|		 _sc_card_add_ec_alg(card, 384, ec_flags, priv->ext_flags, NULL);
  206|      2|	}
  207|       |
  208|    163|	return 0;
  209|    163|}
card-cardos.c:cardos_finish:
  377|    237|{
  378|    237|	int r = 0;
  379|       |
  380|    237|	if (card == NULL )
  ------------------
  |  Branch (380:6): [True: 0, False: 237]
  ------------------
  381|      0|		return 0;
  382|       |
  383|    237|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    237|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    237|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    237|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 237]
  |  |  ------------------
  ------------------
  384|       |
  385|       |	/* free priv data */
  386|    237|	if (card->drv_data) { /* priv */
  ------------------
  |  Branch (386:6): [True: 237, False: 0]
  ------------------
  387|    237|		free(card->drv_data);
  388|    237|		card->drv_data = NULL;
  389|    237|	}
  390|       |
  391|    237|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 237]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  392|    237|}
card-cardos.c:cardos_select_file:
  634|  20.9k|{
  635|  20.9k|	int r;
  636|       |
  637|  20.9k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  20.9k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  20.9k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  20.9k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 20.9k]
  |  |  ------------------
  ------------------
  638|  20.9k|	r = iso_ops->select_file(card, in_path, file);
  639|  20.9k|	if (r >= 0 && file)
  ------------------
  |  Branch (639:6): [True: 2.54k, False: 18.4k]
  |  Branch (639:16): [True: 2.12k, False: 422]
  ------------------
  640|  2.12k|		parse_sec_attr((*file), (*file)->sec_attr, (*file)->sec_attr_len);
  641|  20.9k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  20.9k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  20.9k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  20.9k|	int _ret = r; \
  |  |  |  |  155|  20.9k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 20.9k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  20.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|  18.4k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 18.4k, False: 2.54k]
  |  |  |  |  ------------------
  |  |  |  |  157|  20.9k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  20.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|  20.9k|	return _ret; \
  |  |  |  |  163|  20.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  642|  20.9k|}
card-cardos.c:parse_sec_attr:
  619|  2.12k|{
  620|  2.12k|	size_t i;
  621|  2.12k|	const int *idx;
  622|       |
  623|  2.12k|	idx = (file->type == SC_FILE_TYPE_DF) ?  df_acl : ef_acl;
  ------------------
  |  |  214|  2.12k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (623:8): [True: 61, False: 2.06k]
  ------------------
  624|       |
  625|       |	/* acl defaults to 0xFF if unspecified */
  626|  21.2k|	for (i = 0; i < 9; i++)
  ------------------
  |  Branch (626:14): [True: 19.0k, False: 2.12k]
  ------------------
  627|  19.0k|		if (idx[i] != -1)
  ------------------
  |  Branch (627:7): [True: 14.7k, False: 4.30k]
  ------------------
  628|  14.7k|			add_acl_entry(file, idx[i], (u8)((i < len) ? buf[i] : 0xFF));
  ------------------
  |  Branch (628:37): [True: 2.63k, False: 12.1k]
  ------------------
  629|  2.12k|}
card-cardos.c:add_acl_entry:
  546|  14.7k|{
  547|  14.7k|	unsigned int method, key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  14.7k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  548|       |
  549|  14.7k|	switch (byte) {
  550|    193|	case 0x00:
  ------------------
  |  Branch (550:2): [True: 193, False: 14.6k]
  ------------------
  551|    193|		method = SC_AC_NONE;
  ------------------
  |  |  150|    193|#define SC_AC_NONE			0x00000000
  ------------------
  552|    193|		break;
  553|  12.3k|	case 0xFF:
  ------------------
  |  Branch (553:2): [True: 12.3k, False: 2.47k]
  ------------------
  554|  12.3k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  12.3k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  555|  12.3k|		break;
  556|  2.28k|	default:
  ------------------
  |  Branch (556:2): [True: 2.28k, False: 12.5k]
  ------------------
  557|  2.28k|		if (byte > 0x7F) {
  ------------------
  |  Branch (557:7): [True: 794, False: 1.48k]
  ------------------
  558|    794|			method = SC_AC_UNKNOWN;
  ------------------
  |  |  162|    794|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  559|  1.48k|		} else {
  560|  1.48k|			method = SC_AC_CHV;
  ------------------
  |  |  151|  1.48k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  561|  1.48k|			key_ref = byte;
  562|  1.48k|		}
  563|  2.28k|		break;
  564|  14.7k|	}
  565|  14.7k|	sc_file_add_acl_entry(file, op, method, key_ref);
  566|  14.7k|}
card-cardos.c:cardos_create_file:
  848|     45|{
  849|     45|	int       r;
  850|       |
  851|     45|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     45|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     45|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     45|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 45]
  |  |  ------------------
  ------------------
  852|       |
  853|     45|	if (card->type == SC_CARD_TYPE_CARDOS_GENERIC ||
  ------------------
  |  Branch (853:6): [True: 0, False: 45]
  ------------------
  854|     45|	    card->type == SC_CARD_TYPE_CARDOS_M4_01) {
  ------------------
  |  Branch (854:6): [True: 45, False: 0]
  ------------------
  855|     45|		r = cardos_set_file_attributes(card, file);
  856|     45|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     45|#define SC_SUCCESS				0
  ------------------
  |  Branch (856:7): [True: 1, False: 44]
  ------------------
  857|      1|			return r;
  858|     44|		return iso_ops->create_file(card, file);
  859|     45|	} else if (card->type == SC_CARD_TYPE_CARDOS_M4_2 ||
  ------------------
  |  Branch (859:13): [True: 0, False: 0]
  ------------------
  860|      0|	           card->type == SC_CARD_TYPE_CARDOS_M4_3 ||
  ------------------
  |  Branch (860:13): [True: 0, False: 0]
  ------------------
  861|      0|		   card->type == SC_CARD_TYPE_CARDOS_M4_2B ||
  ------------------
  |  Branch (861:6): [True: 0, False: 0]
  ------------------
  862|      0|	           card->type == SC_CARD_TYPE_CARDOS_M4_2C ||
  ------------------
  |  Branch (862:13): [True: 0, False: 0]
  ------------------
  863|      0|		   card->type == SC_CARD_TYPE_CARDOS_M4_4) {
  ------------------
  |  Branch (863:6): [True: 0, False: 0]
  ------------------
  864|      0|		u8        sbuf[SC_MAX_APDU_BUFFER_SIZE];
  865|      0|		size_t    len = sizeof(sbuf);
  866|      0|		sc_apdu_t apdu;
  867|       |
  868|      0|		r = cardos_construct_fcp(card, file, sbuf, &len);
  869|      0|		if (r < 0) {
  ------------------
  |  Branch (869:7): [True: 0, False: 0]
  ------------------
  870|      0|			sc_log(card->ctx,  "unable to create FCP");
  ------------------
  |  |   71|      0|#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|      0|			return r;
  872|      0|		}
  873|       |
  874|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  875|      0|		apdu.lc      = len;
  876|      0|		apdu.datalen = len;
  877|      0|		apdu.data    = sbuf;
  878|       |
  879|      0|		r = sc_transmit_apdu(card, &apdu);
  880|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  881|       |
  882|      0|		return sc_check_sw(card, apdu.sw1, apdu.sw2);
  883|      0|	} else
  884|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  885|     45|}
card-cardos.c:cardos_set_file_attributes:
  671|     45|{
  672|     45|	int r;
  673|       |
  674|     45|	if (file->type_attr_len == 0) {
  ------------------
  |  Branch (674:6): [True: 45, False: 0]
  ------------------
  675|     45|		u8 type[3];
  676|       |
  677|     45|		memset(type, 0, sizeof(type));
  678|     45|		type[0] = 0x00;
  679|     45|		switch (file->type) {
  680|      1|		case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|      1|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (680:3): [True: 1, False: 44]
  ------------------
  681|      1|			break;
  682|     43|		case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|     43|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (682:3): [True: 43, False: 2]
  ------------------
  683|     43|			type[0] = 0x38;
  684|     43|			break;
  685|      1|		default:
  ------------------
  |  Branch (685:3): [True: 1, False: 44]
  ------------------
  686|      1|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  687|     45|		}
  688|     44|		if (file->type != SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     44|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (688:7): [True: 1, False: 43]
  ------------------
  689|      1|			switch (file->ef_structure) {
  690|      0|			case SC_FILE_EF_LINEAR_FIXED_TLV:
  ------------------
  |  |  223|      0|#define SC_FILE_EF_LINEAR_FIXED_TLV	0x03
  ------------------
  |  Branch (690:4): [True: 0, False: 1]
  ------------------
  691|      0|			case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (691:4): [True: 0, False: 1]
  ------------------
  692|      0|			case SC_FILE_EF_CYCLIC_TLV:
  ------------------
  |  |  227|      0|#define SC_FILE_EF_CYCLIC_TLV		0x07
  ------------------
  |  Branch (692:4): [True: 0, False: 1]
  ------------------
  693|      0|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  694|       |				/* No idea what this means, but it
  695|       |				 * seems to be required for key
  696|       |				 * generation. */
  697|      0|			case SC_FILE_EF_LINEAR_VARIABLE_TLV:
  ------------------
  |  |  225|      0|#define SC_FILE_EF_LINEAR_VARIABLE_TLV	0x05
  ------------------
  |  Branch (697:4): [True: 0, False: 1]
  ------------------
  698|      0|				type[1] = 0xff;
  699|       |				/* fall through */
  700|      1|			default:
  ------------------
  |  Branch (700:4): [True: 1, False: 0]
  ------------------
  701|      1|				type[0] |= file->ef_structure & 7;
  702|      1|				break;
  703|      1|			}
  704|      1|		}
  705|     44|		r = sc_file_set_type_attr(file, type, sizeof(type));
  706|     44|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     44|#define SC_SUCCESS				0
  ------------------
  |  Branch (706:7): [True: 0, False: 44]
  ------------------
  707|      0|			return r;
  708|     44|	}
  709|     44|	if (file->prop_attr_len == 0) {
  ------------------
  |  Branch (709:6): [True: 44, False: 0]
  ------------------
  710|     44|		u8 status[3];
  711|       |
  712|     44|		status[0] = 0x01;
  713|     44|		if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     44|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (713:7): [True: 43, False: 1]
  ------------------
  714|     43|			status[1] = (file->size >> 8) & 0xFF;
  715|     43|			status[2] = file->size & 0xFF;
  716|     43|		} else {
  717|      1|			status[1] = status[2] = 0x00; /* not used */
  718|      1|		}
  719|     44|		r = sc_file_set_prop_attr(file, status, sizeof(status));
  720|     44|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     44|#define SC_SUCCESS				0
  ------------------
  |  Branch (720:7): [True: 0, False: 44]
  ------------------
  721|      0|			return r;
  722|     44|	}
  723|     44|	if (file->sec_attr_len == 0) {
  ------------------
  |  Branch (723:6): [True: 44, False: 0]
  ------------------
  724|     44|		u8     acl[9];
  725|     44|		size_t blen = sizeof(acl);
  726|       |
  727|     44|		r = cardos_acl_to_bytes(card, file, acl, &blen);
  728|     44|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     44|#define SC_SUCCESS				0
  ------------------
  |  Branch (728:7): [True: 0, False: 44]
  ------------------
  729|      0|			return r;
  730|     44|		r = sc_file_set_sec_attr(file, acl, blen);
  731|     44|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     44|#define SC_SUCCESS				0
  ------------------
  |  Branch (731:7): [True: 0, False: 44]
  ------------------
  732|      0|			return r;
  733|     44|	}
  734|     44|	return SC_SUCCESS;
  ------------------
  |  |   28|     44|#define SC_SUCCESS				0
  ------------------
  735|     44|}
card-cardos.c:cardos_acl_to_bytes:
  646|     44|{
  647|     44|	int       i, byte;
  648|     44|	const int *idx;
  649|       |
  650|     44|	if (buf == NULL || *outlen < 9)
  ------------------
  |  Branch (650:6): [True: 0, False: 44]
  |  Branch (650:21): [True: 0, False: 44]
  ------------------
  651|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  652|       |
  653|     44|	idx = (file->type == SC_FILE_TYPE_DF) ?  df_acl : ef_acl;
  ------------------
  |  |  214|     44|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (653:8): [True: 43, False: 1]
  ------------------
  654|    440|	for (i = 0; i < 9; i++) {
  ------------------
  |  Branch (654:14): [True: 396, False: 44]
  ------------------
  655|    396|		if (idx[i] < 0)
  ------------------
  |  Branch (655:7): [True: 131, False: 265]
  ------------------
  656|    131|			byte = 0x00;
  657|    265|		else
  658|    265|			byte = acl_to_byte(sc_file_get_acl_entry(file, idx[i]));
  659|    396|		if (byte < 0) {
  ------------------
  |  Branch (659:7): [True: 0, False: 396]
  ------------------
  660|      0|			sc_log(card->ctx,  "Invalid 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__
  |  |  ------------------
  ------------------
  661|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  662|      0|		}
  663|    396|		buf[i] = byte;
  664|    396|	}
  665|     44|	*outlen = 9;
  666|       |
  667|     44|	return SC_SUCCESS;
  ------------------
  |  |   28|     44|#define SC_SUCCESS				0
  ------------------
  668|     44|}
card-cardos.c:acl_to_byte:
  569|    265|{
  570|    265|	if (e != NULL) {
  ------------------
  |  Branch (570:6): [True: 265, False: 0]
  ------------------
  571|    265|		switch (e->method) {
  ------------------
  |  Branch (571:11): [True: 154, False: 111]
  ------------------
  572|    132|		case SC_AC_NONE:
  ------------------
  |  |  150|    132|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (572:3): [True: 132, False: 133]
  ------------------
  573|    132|			return 0x00;
  574|      0|		case SC_AC_NEVER:
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (574:3): [True: 0, False: 265]
  ------------------
  575|      0|			return 0xFF;
  576|      6|		case SC_AC_CHV:
  ------------------
  |  |  151|      6|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (576:3): [True: 6, False: 259]
  ------------------
  577|     13|		case SC_AC_TERM:
  ------------------
  |  |  152|     13|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (577:3): [True: 7, False: 258]
  ------------------
  578|     22|		case SC_AC_AUT:
  ------------------
  |  |  154|     22|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (578:3): [True: 9, False: 256]
  ------------------
  579|     22|			if (e->key_ref == SC_AC_KEY_REF_NONE)
  ------------------
  |  |  204|     22|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (579:8): [True: 0, False: 22]
  ------------------
  580|      0|				return -1;
  581|     22|			if (e->key_ref > 0x7F)
  ------------------
  |  Branch (581:8): [True: 0, False: 22]
  ------------------
  582|      0|				return -1;
  583|     22|			return e->key_ref;
  584|    265|		}
  585|    265|	}
  586|    111|        return 0x00;
  587|    265|}
card-cardos.c:cardos_list_files:
  476|     17|{
  477|     17|	sc_apdu_t apdu;
  478|     17|	u8        rbuf[256], offset = 0;
  479|     17|	const u8  *p, *q, *tag;
  480|     17|	int       r;
  481|     17|	size_t    fids = 0, len;
  482|       |
  483|     17|	SC_FUNC_CALLED(card->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]
  |  |  ------------------
  ------------------
  484|       |
  485|       |	/* 0x16: DIRECTORY */
  486|       |	/* 0x02: list both DF and EF */
  487|       |
  488|     29|get_next_part:
  489|     29|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x16, 0x02, offset);
  ------------------
  |  |  292|     29|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  490|     29|	apdu.cla = 0x80;
  491|     29|	apdu.le = 256;
  492|     29|	apdu.resplen = 256;
  493|     29|	apdu.resp = rbuf;
  494|       |
  495|     29|	r = sc_transmit_apdu(card, &apdu);
  496|     29|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 0, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  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|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  497|     29|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  498|     29|	LOG_TEST_RET(card->ctx, r, "DIRECTORY command returned 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: 4, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  499|       |
  500|     25|	if (apdu.resplen > 256) {
  ------------------
  |  Branch (500:6): [True: 0, False: 25]
  ------------------
  501|      0|		sc_log(card->ctx,  "directory listing > 256 bytes, cutting");
  ------------------
  |  |   71|      0|#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|      0|	}
  503|       |
  504|     25|	p = rbuf;
  505|     25|	len = apdu.resplen;
  506|     52|	while (len != 0) {
  ------------------
  |  Branch (506:9): [True: 47, False: 5]
  ------------------
  507|     47|		size_t   tlen = 0, ilen = 0;
  508|       |		/* is there a file information block (0x6f) ? */
  509|     47|		tag = sc_asn1_find_tag(card->ctx, p, len, 0x6f, &tlen);
  510|     47|		if (tag == NULL) {
  ------------------
  |  Branch (510:7): [True: 7, False: 40]
  ------------------
  511|      7|			sc_log(card->ctx,  "directory tag missing");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  512|      7|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      7|#define SC_ERROR_INTERNAL			-1400
  ------------------
  513|      7|		}
  514|     40|		len = len - tlen - (tag - p);
  515|     40|		p = tag + tlen;
  516|     40|		if (tlen == 0)
  ------------------
  |  Branch (516:7): [True: 1, False: 39]
  ------------------
  517|       |			/* empty directory */
  518|      1|			break;
  519|     39|		q = sc_asn1_find_tag(card->ctx, tag, tlen, 0x86, &ilen);
  520|     39|		if (q == NULL || ilen != 2) {
  ------------------
  |  Branch (520:7): [True: 0, False: 39]
  |  Branch (520:20): [True: 0, False: 39]
  ------------------
  521|      0|			sc_log(card->ctx,  "error parsing file id TLV object");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  522|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  523|      0|		}
  524|       |		/* put file id in buf */
  525|     39|		if (buflen >= 2) {
  ------------------
  |  Branch (525:7): [True: 39, False: 0]
  ------------------
  526|     39|			buf[fids++] = q[0];
  527|     39|			buf[fids++] = q[1];
  528|     39|			buflen -= 2;
  529|     39|		} else
  530|       |			/* not enough space left in buffer => break */
  531|      0|			break;
  532|       |		/* extract next offset */
  533|     39|		q = sc_asn1_find_tag(card->ctx, tag, tlen, 0x8a, &ilen);
  534|     39|		if (q != NULL && ilen == 1) {
  ------------------
  |  Branch (534:7): [True: 18, False: 21]
  |  Branch (534:20): [True: 12, False: 6]
  ------------------
  535|     12|			offset = (u8)ilen;
  536|     12|			goto get_next_part;
  537|     12|		}
  538|     39|	}
  539|       |
  540|      6|	r = (int)fids;
  541|       |
  542|      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: 1, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|      5|	} else { \
  |  |  |  |  159|      5|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      5|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      5|	} \
  |  |  |  |  162|      6|	return _ret; \
  |  |  |  |  163|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  543|      6|}
card-cardos.c:cardos_check_sw:
  458|  23.5k|{
  459|  23.5k|	const int err_count = sizeof(cardos_errors)/sizeof(cardos_errors[0]);
  460|  23.5k|	int i;
  461|       |
  462|   424k|	for (i = 0; i < err_count; i++) {
  ------------------
  |  Branch (462:14): [True: 422k, False: 1.99k]
  ------------------
  463|   422k|		if (cardos_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (463:7): [True: 21.5k, False: 400k]
  ------------------
  464|  21.5k|			if ( cardos_errors[i].errorstr )
  ------------------
  |  Branch (464:9): [True: 16.1k, False: 5.33k]
  ------------------
  465|  16.1k|				sc_log(card->ctx,  "%s\n",
  ------------------
  |  |   71|  16.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__
  |  |  ------------------
  ------------------
  466|  21.5k|				 	cardos_errors[i].errorstr);
  467|  21.5k|			return cardos_errors[i].errorno;
  468|  21.5k|		}
  469|   422k|	}
  470|       |
  471|  1.99k|        sc_log(card->ctx,  "Unknown SWs; SW1=%02X, SW2=%02X\n", sw1, sw2);
  ------------------
  |  |   71|  1.99k|#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|  1.99k|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|  1.99k|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  473|  23.5k|}
card-cardos.c:cardos_card_ctl:
 1447|    580|{
 1448|    580|	switch (cmd) {
  ------------------
  |  Branch (1448:10): [True: 580, False: 0]
  ------------------
 1449|      0|	case SC_CARDCTL_CARDOS_PUT_DATA_FCI:
  ------------------
  |  Branch (1449:2): [True: 0, False: 580]
  ------------------
 1450|      0|		break;
 1451|      9|	case SC_CARDCTL_CARDOS_PUT_DATA_OCI:
  ------------------
  |  Branch (1451:2): [True: 9, False: 571]
  ------------------
 1452|      9|		return cardos_put_data_oci(card,
 1453|      9|			(struct sc_cardctl_cardos_obj_info *) ptr);
 1454|      0|		break;
 1455|     13|	case SC_CARDCTL_CARDOS_PUT_DATA_SECI:
  ------------------
  |  Branch (1455:2): [True: 13, False: 567]
  ------------------
 1456|     13|		return cardos_put_data_seci(card,
 1457|     13|			(struct sc_cardctl_cardos_obj_info *) ptr);
 1458|      0|		break;
 1459|      0|	case SC_CARDCTL_CARDOS_GENERATE_KEY:
  ------------------
  |  Branch (1459:2): [True: 0, False: 580]
  ------------------
 1460|      0|		return cardos_generate_key(card,
 1461|      0|			(struct sc_cardctl_cardos_genkey_info *) ptr);
 1462|    108|	case  SC_CARDCTL_CARDOS_PASS_ALGO_FLAGS:
  ------------------
  |  Branch (1462:2): [True: 108, False: 472]
  ------------------
 1463|    108|		return cardos_pass_algo_flags(card,
 1464|    108|			(struct sc_cardctl_cardos_pass_algo_flags *) ptr);
 1465|      0|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1465:2): [True: 0, False: 580]
  ------------------
 1466|      0|		return cardos_lifecycle_get(card, (int *) ptr);
 1467|    363|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1467:2): [True: 363, False: 217]
  ------------------
 1468|    363|		return cardos_lifecycle_set(card, (int *) ptr);
 1469|     87|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1469:2): [True: 87, False: 493]
  ------------------
 1470|     87|		return cardos_get_serialnr(card, (sc_serial_number_t *)ptr);
 1471|    580|	}
 1472|      0|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1473|    580|}
card-cardos.c:cardos_put_data_oci:
 1328|      9|{
 1329|      9|	sc_apdu_t	apdu;
 1330|      9|	int		r;
 1331|       |
 1332|      9|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|      9|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|      9|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|      9|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 9]
  |  |  ------------------
  ------------------
 1333|       |
 1334|      9|	memset(&apdu, 0, sizeof(apdu));
 1335|      9|	apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      9|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1336|      9|	apdu.cla = 0x00;
 1337|      9|	apdu.ins = 0xda;
 1338|      9|	apdu.p1  = 0x01;
 1339|      9|	apdu.p2  = 0x6e;
 1340|      9|	apdu.lc  = args->len;
 1341|      9|	apdu.data = args->data;
 1342|      9|	apdu.datalen = args->len;
 1343|       |
 1344|      9|	r = sc_transmit_apdu(card, &apdu);
 1345|      9|	LOG_TEST_RET(card->ctx, r, "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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1346|       |
 1347|      9|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1348|      9|	LOG_TEST_RET(card->ctx, r, "Card returned 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: 2, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1349|       |
 1350|      7|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1351|      7|}
card-cardos.c:cardos_put_data_seci:
 1356|     13|{
 1357|     13|	sc_apdu_t	apdu;
 1358|     13|	int		r;
 1359|       |
 1360|     13|	memset(&apdu, 0, sizeof(apdu));
 1361|     13|	apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|     13|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1362|     13|	apdu.cla = 0x00;
 1363|     13|	apdu.ins = 0xda;
 1364|     13|	apdu.p1  = 0x01;
 1365|     13|	apdu.p2  = 0x6d;
 1366|     13|	apdu.lc  = args->len;
 1367|     13|	apdu.data = args->data;
 1368|     13|	apdu.datalen = args->len;
 1369|       |
 1370|     13|	r = sc_transmit_apdu(card, &apdu);
 1371|     13|	LOG_TEST_RET(card->ctx, r, "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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1372|       |
 1373|     12|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1374|     12|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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: 2, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1375|       |
 1376|     10|	return r;
 1377|     12|}
card-cardos.c:cardos_pass_algo_flags:
  353|    108|{
  354|    108|	cardos_data_t * priv = (cardos_data_t *)card->drv_data;
  355|    108|	int r = 0;
  356|       |
  357|    108|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    108|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    108|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    108|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 108]
  |  |  ------------------
  ------------------
  358|    108|	switch (ptr->pass) {
  359|     54|		case 1:
  ------------------
  |  Branch (359:3): [True: 54, False: 54]
  ------------------
  360|     54|			ptr->card_flags = card->flags;
  361|     54|			ptr->used_flags = priv->flags;
  362|     54|			ptr->ec_flags = priv->ec_flags;
  363|     54|			ptr->ext_flags = priv->ext_flags;
  364|     54|			break;
  365|     54|		case 2:
  ------------------
  |  Branch (365:3): [True: 54, False: 54]
  ------------------
  366|     54|			r = cardos_add_algs(card,ptr->new_flags, ptr->ec_flags, ptr->ext_flags);
  367|     54|			break;
  368|      0|		default:
  ------------------
  |  Branch (368:3): [True: 0, False: 108]
  ------------------
  369|      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__
  |  |  ------------------
  ------------------
  370|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  371|    108|	}
  372|    108|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  373|    108|}
card-cardos.c:cardos_lifecycle_get:
 1247|    363|{
 1248|    363|	sc_apdu_t	apdu;
 1249|    363|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1250|    363|	int		r;
 1251|       |
 1252|    363|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    363|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    363|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    363|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 363]
  |  |  ------------------
  ------------------
 1253|       |
 1254|    363|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x83);
  ------------------
  |  |  292|    363|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1255|    363|	apdu.cla = 0x00;
 1256|    363|	apdu.le = 256;
 1257|    363|	apdu.resplen = sizeof(rbuf);
 1258|    363|	apdu.resp = rbuf;
 1259|       |
 1260|    363|	r = sc_transmit_apdu(card, &apdu);
 1261|    363|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    363|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    363|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    363|	int _ret = (r); \
  |  |  |  |  168|    363|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 357]
  |  |  |  |  ------------------
  |  |  |  |  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|    363|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 357]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1262|       |
 1263|    357|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1264|    357|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    357|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    357|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    357|	int _ret = (r); \
  |  |  |  |  168|    357|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 35, False: 322]
  |  |  |  |  ------------------
  |  |  |  |  169|     35|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     35|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     35|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     35|		return _ret; \
  |  |  |  |  172|     35|	} \
  |  |  |  |  173|    357|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 322]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1265|       |
 1266|    322|	if (apdu.resplen < 1) {
  ------------------
  |  Branch (1266:6): [True: 5, False: 317]
  ------------------
 1267|      5|		LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Lifecycle byte not in response");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1268|      5|	}
 1269|       |
 1270|    317|	r = SC_SUCCESS;
  ------------------
  |  |   28|    317|#define SC_SUCCESS				0
  ------------------
 1271|    317|	switch (rbuf[0]) {
 1272|    209|	case 0x10:
  ------------------
  |  Branch (1272:2): [True: 209, False: 108]
  ------------------
 1273|    209|		*mode = SC_CARDCTRL_LIFECYCLE_USER;
 1274|    209|		break;
 1275|     68|	case 0x20:
  ------------------
  |  Branch (1275:2): [True: 68, False: 249]
  ------------------
 1276|     68|		*mode = SC_CARDCTRL_LIFECYCLE_ADMIN;
 1277|     68|		break;
 1278|     26|	case 0x34: /* MANUFACTURING */
  ------------------
  |  Branch (1278:2): [True: 26, False: 291]
  ------------------
 1279|     26|		*mode = SC_CARDCTRL_LIFECYCLE_OTHER;
 1280|     26|		break;
 1281|     14|	default:
  ------------------
  |  Branch (1281:2): [True: 14, False: 303]
  ------------------
 1282|     14|		sc_log(card->ctx,  "Unknown lifecycle byte %d", rbuf[0]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1283|     14|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     14|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1284|    317|	}
 1285|       |
 1286|    317|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    317|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    317|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    317|	int _ret = r; \
  |  |  |  |  155|    317|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 317, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    317|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 303]
  |  |  |  |  ------------------
  |  |  |  |  157|    317|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    317|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    317|	return _ret; \
  |  |  |  |  163|    317|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1287|    317|}
card-cardos.c:cardos_lifecycle_set:
 1291|    363|{
 1292|    363|	sc_apdu_t	apdu;
 1293|    363|	int		r;
 1294|       |
 1295|    363|	int current;
 1296|    363|	int target;
 1297|       |
 1298|    363|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    363|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    363|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    363|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 363]
  |  |  ------------------
  ------------------
 1299|       |
 1300|    363|	target = *mode;
 1301|       |
 1302|    363|	r = cardos_lifecycle_get(card, &current);
 1303|       |
 1304|    363|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    363|#define SC_SUCCESS				0
  ------------------
  |  Branch (1304:6): [True: 60, False: 303]
  ------------------
 1305|     60|		return r;
 1306|       |
 1307|    303|	if (current == target || current == SC_CARDCTRL_LIFECYCLE_OTHER)
  ------------------
  |  Branch (1307:6): [True: 68, False: 235]
  |  Branch (1307:27): [True: 26, False: 209]
  ------------------
 1308|     94|		return SC_SUCCESS;
  ------------------
  |  |   28|     94|#define SC_SUCCESS				0
  ------------------
 1309|       |
 1310|    209|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x10, 0, 0);
  ------------------
  |  |  291|    209|#define SC_APDU_CASE_1			0x01
  ------------------
 1311|    209|	apdu.cla = 0x80;
 1312|    209|	apdu.le = 0;
 1313|    209|	apdu.resplen = 0;
 1314|    209|	apdu.resp = NULL;
 1315|       |
 1316|    209|	r = sc_transmit_apdu(card, &apdu);
 1317|    209|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    209|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    209|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    209|	int _ret = (r); \
  |  |  |  |  168|    209|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  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|    209|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 209]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1318|       |
 1319|    209|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1320|    209|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    209|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    209|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    209|	int _ret = (r); \
  |  |  |  |  168|    209|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  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|    209|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 209]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1321|       |
 1322|    209|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    209|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    209|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    209|	int _ret = r; \
  |  |  |  |  155|    209|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 209, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    209|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 209]
  |  |  |  |  ------------------
  |  |  |  |  157|    209|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    209|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    209|	return _ret; \
  |  |  |  |  163|    209|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1323|    209|}
card-cardos.c:cardos_get_serialnr:
 1414|     87|{
 1415|     87|	int r;
 1416|     87|	sc_apdu_t apdu;
 1417|     87|	u8  rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1418|       |
 1419|     87|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x81);
  ------------------
  |  |  292|     87|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1420|     87|	apdu.resp = rbuf;
 1421|     87|	apdu.resplen = sizeof(rbuf);
 1422|     87|	apdu.le   = 256;
 1423|     87|	r = sc_transmit_apdu(card, &apdu);
 1424|     87|	LOG_TEST_RET(card->ctx, r,  "APDU transmit 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: 1, False: 86]
  |  |  |  |  ------------------
  |  |  |  |  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|     87|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 86]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1425|     86|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1425:6): [True: 34, False: 52]
  |  Branch (1425:26): [True: 3, False: 49]
  ------------------
 1426|     37|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     37|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1427|     49|	if ((apdu.resplen == 8) && (card->type == SC_CARD_TYPE_CARDOS_V5_0 || card->type == SC_CARD_TYPE_CARDOS_V5_3)) {
  ------------------
  |  Branch (1427:6): [True: 5, False: 44]
  |  Branch (1427:30): [True: 0, False: 5]
  |  Branch (1427:72): [True: 0, False: 5]
  ------------------
 1428|       |		/* cache serial number */
 1429|      0|		memcpy(card->serialnr.value, rbuf, 8);
 1430|      0|		card->serialnr.len = 8;
 1431|     49|	} else if (apdu.resplen == 32) {
  ------------------
  |  Branch (1431:13): [True: 0, False: 49]
  ------------------
 1432|       |		/* cache serial number */
 1433|      0|		memcpy(card->serialnr.value, &rbuf[10], 6);
 1434|      0|		card->serialnr.len = 6;
 1435|     49|	} else {
 1436|     49|		sc_log(card->ctx,  "unexpected response to GET DATA serial"
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1437|     49|				" number\n");
 1438|     49|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     49|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1439|     49|	}
 1440|       |	/* copy and return serial number */
 1441|      0|	memcpy(serial, &card->serialnr, sizeof(*serial));
 1442|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1443|     49|}
card-cardos.c:cardos_pin_cmd:
 1482|     42|{
 1483|     42|	struct sc_context *ctx = card->ctx;
 1484|     42|	int rv;
 1485|       |
 1486|     42|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     42|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     42|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     42|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     42|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 42]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1487|       |
 1488|     42|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  429|     42|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1489|     42|	data->pin_reference |= 0x80;
 1490|       |
 1491|     42|	sc_log(ctx, "PIN_CMD(cmd:%i, ref:%i)", data->cmd, data->pin_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1492|     42|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1493|     42|	       "PIN1(max:%"SC_FORMAT_LEN_SIZE_T"u, min:%"SC_FORMAT_LEN_SIZE_T"u)",
 1494|     42|	       data->pin1.max_length, data->pin1.min_length);
 1495|     42|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1496|     42|	       "PIN2(max:%"SC_FORMAT_LEN_SIZE_T"u, min:%"SC_FORMAT_LEN_SIZE_T"u)",
 1497|     42|	       data->pin2.max_length, data->pin2.min_length);
 1498|       |
 1499|       |	/* FIXME: the following values depend on what pin length was
 1500|       |	 * used when creating the BS objects */
 1501|     42|	if (data->pin1.max_length == 0)
  ------------------
  |  Branch (1501:6): [True: 42, False: 0]
  ------------------
 1502|     42|		data->pin1.max_length = 8;
 1503|     42|	if (data->pin2.max_length == 0)
  ------------------
  |  Branch (1503:6): [True: 42, False: 0]
  ------------------
 1504|     42|		data->pin2.max_length = 8;
 1505|       |
 1506|     42|	rv = iso_ops->pin_cmd(card, data);
 1507|     42|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     42|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     42|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     42|	int _ret = r; \
  |  |  |  |  155|     42|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 42, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     42|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     42|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     42|	} else { \
  |  |  |  |  159|      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|	return _ret; \
  |  |  |  |  163|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1508|     42|}

coolkey_compare_id:
  757|  14.6k|{
  758|  14.6k|	if (a == NULL || b == NULL)
  ------------------
  |  Branch (758:6): [True: 0, False: 14.6k]
  |  Branch (758:19): [True: 0, False: 14.6k]
  ------------------
  759|      0|		return 1;
  760|  14.6k|	return ((sc_cardctl_coolkey_object_t *)a)->id
  761|  14.6k|	    != ((sc_cardctl_coolkey_object_t *)b)->id;
  762|  14.6k|}
coolkey_list_meter:
  765|    347|size_t coolkey_list_meter(const void *el) {
  766|    347|	return sizeof(sc_cardctl_coolkey_object_t);
  767|    347|}
sc_get_coolkey_driver:
 2476|  3.69k|{
 2477|  3.69k|	return sc_get_driver();
 2478|  3.69k|}
card-coolkey.c:coolkey_v1_get_attribute_len:
  313|   225k|{
  314|   225k|	coolkey_attribute_header_t *attribute_head = (coolkey_attribute_header_t *)attr;
  315|       |
  316|   225k|	*len = 0;
  317|       |	/* don't reference beyond our buffer */
  318|   225k|	if (buf_len < sizeof(coolkey_attribute_header_t)) {
  ------------------
  |  Branch (318:6): [True: 224k, False: 826]
  ------------------
  319|   224k|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|   224k|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  320|   224k|	}
  321|    826|	switch (attribute_head->attribute_data_type) {
  322|    190|	case COOLKEY_ATTR_TYPE_STRING:
  ------------------
  |  |  246|    190|#define COOLKEY_ATTR_TYPE_STRING      0
  ------------------
  |  Branch (322:2): [True: 190, False: 636]
  ------------------
  323|    190|		if (buf_len < (sizeof(coolkey_attribute_header_t) +2)) {
  ------------------
  |  Branch (323:7): [True: 1, False: 189]
  ------------------
  324|      1|			break;
  325|      1|		}
  326|    189|		*len = bebytes2ushort(attr + sizeof(coolkey_attribute_header_t));
  327|    189|		if (encoded_len) {
  ------------------
  |  Branch (327:7): [True: 189, False: 0]
  ------------------
  328|    189|			*len += 2;
  329|    189|		}
  330|    189|		return SC_SUCCESS;
  ------------------
  |  |   28|    189|#define SC_SUCCESS				0
  ------------------
  331|    130|	case COOLKEY_ATTR_TYPE_BOOL_FALSE:
  ------------------
  |  |  248|    130|#define COOLKEY_ATTR_TYPE_BOOL_FALSE  2
  ------------------
  |  Branch (331:2): [True: 130, False: 696]
  ------------------
  332|    278|	case COOLKEY_ATTR_TYPE_BOOL_TRUE:
  ------------------
  |  |  249|    278|#define COOLKEY_ATTR_TYPE_BOOL_TRUE   3
  ------------------
  |  Branch (332:2): [True: 148, False: 678]
  ------------------
  333|       |		/* NOTE: there is no encoded data from TYPE_BOOL_XXX, so we return length 0, but the length
  334|       |		 * of the attribute is actually 1 byte, so if encoded_len == false, return 1 */
  335|    278|		*len = encoded_len ? 0: 1;
  ------------------
  |  Branch (335:10): [True: 278, False: 0]
  ------------------
  336|    278|		return SC_SUCCESS;
  ------------------
  |  |   28|    278|#define SC_SUCCESS				0
  ------------------
  337|      0|		break;
  338|    344|	case COOLKEY_ATTR_TYPE_INTEGER:
  ------------------
  |  |  247|    344|#define COOLKEY_ATTR_TYPE_INTEGER     1
  ------------------
  |  Branch (338:2): [True: 344, False: 482]
  ------------------
  339|    344|		*len = 4; /* length is 4 in both encoded length and attribute length */
  340|    344|		return SC_SUCCESS;
  ------------------
  |  |   28|    344|#define SC_SUCCESS				0
  ------------------
  341|     14|	default:
  ------------------
  |  Branch (341:2): [True: 14, False: 812]
  ------------------
  342|     14|		break;
  343|    826|	}
  344|     15|	return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     15|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  345|    826|}
card-coolkey.c:coolkey_read_object:
 1100|     52|{
 1101|     52|	coolkey_read_object_param_t params;
 1102|     52|	u8 *out_ptr;
 1103|     52|	size_t left = 0;
 1104|     52|	size_t len;
 1105|     52|	int r;
 1106|       |
 1107|     52|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1108|       |
 1109|     52|	ulong2bebytes(&params.object_id[0], object_id);
 1110|       |
 1111|     52|	out_ptr = out_buf;
 1112|     52|	left = out_len;
 1113|    440|	do {
 1114|    440|		ulong2bebytes(&params.offset[0], offset);
 1115|    440|		params.length = MIN(left, COOLKEY_MAX_CHUNK_SIZE);
  ------------------
  |  |   70|    440|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 60, False: 380]
  |  |  ------------------
  ------------------
 1116|    440|		len = left;
 1117|    440|		r = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_READ_OBJECT, 0, 0,
  ------------------
  |  |   72|    440|#define COOLKEY_CLASS           0xb0
  ------------------
              		r = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_READ_OBJECT, 0, 0,
  ------------------
  |  |   88|    440|#define COOLKEY_INS_READ_OBJECT                0x56
  ------------------
 1118|    440|			(u8 *)&params, sizeof(params), &out_ptr, &len, nonce, nonce_size);
 1119|    440|		if (r < 0) {
  ------------------
  |  Branch (1119:7): [True: 12, False: 428]
  ------------------
 1120|     12|			goto fail;
 1121|     12|		}
 1122|       |		/* sanity check to make sure we don't overflow left */
 1123|    428|		if ((left < len) || (len == 0)) {
  ------------------
  |  Branch (1123:7): [True: 0, False: 428]
  |  Branch (1123:23): [True: 0, False: 428]
  ------------------
 1124|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1125|      0|			goto fail;
 1126|      0|		}
 1127|    428|		out_ptr += len;
 1128|    428|		offset += len;
 1129|    428|		left -= len;
 1130|    428|	} while (left != 0);
  ------------------
  |  Branch (1130:11): [True: 388, False: 40]
  ------------------
 1131|       |
 1132|     40|	return (int)out_len;
 1133|       |
 1134|     12|fail:
 1135|     12|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1136|     12|}
card-coolkey.c:coolkey_apdu_io:
  912|  3.70k|{
  913|  3.70k|	int r;
  914|  3.70k|	sc_apdu_t apdu;
  915|  3.70k|	u8 rbufinitbuf[COOLKEY_MAX_SIZE];
  916|  3.70k|	u8 rsendbuf[COOLKEY_MAX_SIZE];
  917|  3.70k|	u8 *rbuf;
  918|  3.70k|	size_t rbuflen;
  919|  3.70k|	int cse = 0;
  920|       |
  921|       |
  922|  3.70k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.70k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.70k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.70k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.70k]
  |  |  ------------------
  ------------------
  923|       |
  924|  3.70k|	sc_log(card->ctx,
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  925|  3.70k|		 "%02x %02x %02x %"SC_FORMAT_LEN_SIZE_T"u : %"SC_FORMAT_LEN_SIZE_T"u %"SC_FORMAT_LEN_SIZE_T"u\n",
  926|  3.70k|		 ins, p1, p2, sendbuflen, card->max_send_size,
  927|  3.70k|		 card->max_recv_size);
  928|       |
  929|  3.70k|	rbuf = rbufinitbuf;
  930|  3.70k|	rbuflen = sizeof(rbufinitbuf);
  931|       |
  932|       |	/* if caller provided a buffer and length */
  933|  3.70k|	if (recvbuf && *recvbuf && recvbuflen && *recvbuflen) {
  ------------------
  |  Branch (933:6): [True: 2.28k, False: 1.42k]
  |  Branch (933:17): [True: 2.28k, False: 0]
  |  Branch (933:29): [True: 2.28k, False: 0]
  |  Branch (933:43): [True: 2.28k, False: 0]
  ------------------
  934|  2.28k|		rbuf = *recvbuf;
  935|  2.28k|		rbuflen = *recvbuflen;
  936|  2.28k|	}
  937|       |
  938|  3.70k|	if (sendbuf || nonce) {
  ------------------
  |  Branch (938:6): [True: 1.86k, False: 1.84k]
  |  Branch (938:17): [True: 0, False: 1.84k]
  ------------------
  939|  1.86k|		if (recvbuf) {
  ------------------
  |  Branch (939:7): [True: 440, False: 1.42k]
  ------------------
  940|    440|			cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|    440|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  941|  1.42k|		} else {
  942|  1.42k|			cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|  1.42k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  943|  1.42k|		}
  944|  1.86k|	} else {
  945|  1.84k|		if (recvbuf) {
  ------------------
  |  Branch (945:7): [True: 1.84k, False: 0]
  ------------------
  946|  1.84k|			cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|  1.84k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  947|  1.84k|		} else {
  948|      0|			cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
  949|      0|		}
  950|  1.84k|	}
  951|       |
  952|       |	/* append the nonce if we have it. Coolkey just blindly puts this at the end
  953|       |	 * of the APDU (while adjusting lc). This converts case 1 to case 3. coolkey
  954|       |	 * also always drops le in case 4 (which happens when proto = T0). nonces are
  955|       |	 * never used on case 2 commands, so we can simply append the nonce to the data
  956|       |	 * and we should be fine */
  957|  3.70k|	if (nonce) {
  ------------------
  |  Branch (957:6): [True: 440, False: 3.26k]
  ------------------
  958|    440|		u8 *buf = rsendbuf;
  959|    440|		if (sendbuf) {
  ------------------
  |  Branch (959:7): [True: 440, False: 0]
  ------------------
  960|    440|			sendbuflen = MIN(sendbuflen,sizeof(rsendbuf)-nonce_len);
  ------------------
  |  |   70|    440|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 440, False: 0]
  |  |  ------------------
  ------------------
  961|    440|			memcpy(rsendbuf, sendbuf, sendbuflen);
  962|    440|			buf += sendbuflen;
  963|    440|		}
  964|    440|		memcpy(buf, nonce, nonce_len);
  965|    440|		sendbuflen += nonce_len;
  966|    440|		sendbuf =rsendbuf;
  967|    440|	}
  968|       |
  969|  3.70k|	sc_format_apdu(card, &apdu, cse, ins, p1, p2);
  970|       |
  971|  3.70k|	apdu.lc = sendbuflen;
  972|  3.70k|	apdu.datalen = sendbuflen;
  973|  3.70k|	apdu.data = sendbuf;
  974|       |
  975|       |
  976|       |	/* coolkey uses non-standard classes */
  977|  3.70k|	apdu.cla = cla;
  978|       |
  979|  3.70k|	if (recvbuf) {
  ------------------
  |  Branch (979:6): [True: 2.28k, False: 1.42k]
  ------------------
  980|  2.28k|		apdu.resp = rbuf;
  981|  2.28k|		apdu.le = (rbuflen > 255) ? 255 : rbuflen;
  ------------------
  |  Branch (981:13): [True: 375, False: 1.91k]
  ------------------
  982|  2.28k|		apdu.resplen = rbuflen;
  983|  2.28k|	} else {
  984|  1.42k|		 apdu.resp =  rbuf;
  985|  1.42k|		 apdu.le = 0;
  986|  1.42k|		 apdu.resplen = 0;
  987|  1.42k|	}
  988|       |
  989|  3.70k|	sc_log(card->ctx,
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  990|  3.70k|		 "calling sc_transmit_apdu flags=%lx le=%"SC_FORMAT_LEN_SIZE_T"u, resplen=%"SC_FORMAT_LEN_SIZE_T"u, resp=%p",
  991|  3.70k|		 apdu.flags, apdu.le, apdu.resplen, apdu.resp);
  992|       |
  993|       |	/* with new adpu.c and chaining, this actually reads the whole object */
  994|  3.70k|	r = sc_transmit_apdu(card, &apdu);
  995|       |
  996|  3.70k|	sc_log(card->ctx,
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  997|  3.70k|		 "result r=%d apdu.resplen=%"SC_FORMAT_LEN_SIZE_T"u sw1=%02x sw2=%02x",
  998|  3.70k|		 r, apdu.resplen, apdu.sw1, apdu.sw2);
  999|       |
 1000|  3.70k|	if (r < 0) {
  ------------------
  |  Branch (1000:6): [True: 0, False: 3.70k]
  ------------------
 1001|      0|		sc_log(card->ctx, "Transmit 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__
  |  |  ------------------
  ------------------
 1002|      0|		goto err;
 1003|      0|	}
 1004|  3.70k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1005|  3.70k|	if (r < 0) {
  ------------------
  |  Branch (1005:6): [True: 1.13k, False: 2.57k]
  ------------------
 1006|  1.13k|		sc_log(card->ctx, "Transmit failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1007|  1.13k|		goto err;
 1008|  1.13k|	}
 1009|       |
 1010|  2.57k|	if (recvbuflen) {
  ------------------
  |  Branch (1010:6): [True: 2.24k, False: 327]
  ------------------
 1011|  2.24k|		if (recvbuf && *recvbuf == NULL) {
  ------------------
  |  Branch (1011:7): [True: 2.24k, False: 0]
  |  Branch (1011:18): [True: 0, False: 2.24k]
  ------------------
 1012|      0|			*recvbuf =  malloc(apdu.resplen);
 1013|      0|			if (*recvbuf == NULL) {
  ------------------
  |  Branch (1013:8): [True: 0, False: 0]
  ------------------
 1014|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1015|      0|				goto err;
 1016|      0|			}
 1017|      0|			memcpy(*recvbuf, rbuf, apdu.resplen);
 1018|      0|		}
 1019|  2.24k|		*recvbuflen =  apdu.resplen;
 1020|  2.24k|		r = (int)*recvbuflen;
 1021|  2.24k|	}
 1022|       |
 1023|  3.70k|err:
 1024|  3.70k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.70k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.70k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.70k|	int _ret = r; \
  |  |  |  |  155|  3.70k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.46k, False: 2.24k]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|  1.13k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.13k, False: 327]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.46k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.24k|	} else { \
  |  |  |  |  159|  2.24k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  2.24k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  2.24k|	} \
  |  |  |  |  162|  3.70k|	return _ret; \
  |  |  |  |  163|  3.70k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1025|  3.70k|}
card-coolkey.c:coolkey_find_object_by_id:
  825|  1.73k|{
  826|  1.73k|	int pos;
  827|  1.73k|	static sc_cardctl_coolkey_object_t cmp = {{
  828|  1.73k|		"", 0, 0, 0, SC_PATH_TYPE_DF_NAME,
  ------------------
  |  |  118|  1.73k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  829|  1.73k|		{ COOLKEY_AID, sizeof(COOLKEY_AID)-1 }
  ------------------
  |  |  822|  1.73k|#define COOLKEY_AID "\xA0\x00\x00\x01\x16"
  ------------------
              		{ COOLKEY_AID, sizeof(COOLKEY_AID)-1 }
  ------------------
  |  |  822|  1.73k|#define COOLKEY_AID "\xA0\x00\x00\x01\x16"
  ------------------
  830|  1.73k|	}, 0, 0, NULL};
  831|       |
  832|  1.73k|	cmp.id = object_id;
  833|  1.73k|	if ((pos = list_locate(list, &cmp)) < 0)
  ------------------
  |  Branch (833:6): [True: 347, False: 1.38k]
  ------------------
  834|    347|		return NULL;
  835|       |
  836|  1.38k|	return list_get_at(list, pos);
  837|  1.73k|}
card-coolkey.c:coolkey_v1_get_attribute_record_len:
  364|   225k|{
  365|   225k|	size_t attribute_len = sizeof(coolkey_attribute_header_t);
  366|   225k|	size_t len = 0;
  367|   225k|	int r;
  368|       |
  369|   225k|	r = coolkey_v1_get_attribute_len(attr, buf_len, &len, 1);
  370|   225k|	if (r < 0) {
  ------------------
  |  Branch (370:6): [True: 224k, False: 811]
  ------------------
  371|   224k|		return buf_len; /* skip to the end, ignore the rest of the record */
  372|   224k|	}
  373|       |
  374|    811|	return MIN(buf_len,attribute_len+len);
  ------------------
  |  |   70|    811|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 6, False: 805]
  |  |  ------------------
  ------------------
  375|   225k|}
card-coolkey.c:sc_get_driver:
 2449|  3.69k|{
 2450|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2451|       |
 2452|  3.69k|	coolkey_ops = *iso_drv->ops;
 2453|  3.69k|	coolkey_ops.match_card = coolkey_match_card;
 2454|  3.69k|	coolkey_ops.init = coolkey_init;
 2455|  3.69k|	coolkey_ops.finish = coolkey_finish;
 2456|       |
 2457|  3.69k|	coolkey_ops.select_file =  coolkey_select_file; /* need to record object type */
 2458|  3.69k|	coolkey_ops.get_challenge = coolkey_get_challenge;
 2459|  3.69k|	coolkey_ops.read_binary = coolkey_read_binary;
 2460|  3.69k|	coolkey_ops.write_binary = coolkey_write_binary;
 2461|  3.69k|	coolkey_ops.set_security_env = coolkey_set_security_env;
 2462|  3.69k|	coolkey_ops.restore_security_env = coolkey_restore_security_env;
 2463|  3.69k|	coolkey_ops.compute_signature = coolkey_compute_crypt;
 2464|  3.69k|	coolkey_ops.decipher =  coolkey_compute_crypt;
 2465|  3.69k|	coolkey_ops.card_ctl = coolkey_card_ctl;
 2466|  3.69k|	coolkey_ops.check_sw = coolkey_check_sw;
 2467|  3.69k|	coolkey_ops.pin_cmd = coolkey_pin_cmd;
 2468|  3.69k|	coolkey_ops.logout = coolkey_logout;
 2469|  3.69k|	coolkey_ops.card_reader_lock_obtained = coolkey_card_reader_lock_obtained;
 2470|       |
 2471|  3.69k|	return &coolkey_drv;
 2472|  3.69k|}
card-coolkey.c:coolkey_match_card:
 2288|  1.35k|{
 2289|  1.35k|	int r;
 2290|       |
 2291|  1.35k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.35k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.35k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.35k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.35k]
  |  |  ------------------
  ------------------
 2292|       |
 2293|  1.35k|	r = coolkey_select_applet(card);
 2294|  1.35k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  1.35k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2294:6): [True: 259, False: 1.09k]
  ------------------
 2295|    259|		sc_apdu_t apdu;
 2296|       |
 2297|       |		/* The GET STATUS INS with P1 = 1 returns invalid instruction (0x6D00)
 2298|       |		 * on Coolkey applet (reserved for GetMemory function),
 2299|       |		 * while incorrect P1 (0x9C10) on Muscle applets
 2300|       |		 */
 2301|    259|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, COOLKEY_INS_GET_STATUS, 0x01, 0x00);
  ------------------
  |  |  291|    259|#define SC_APDU_CASE_1			0x01
  ------------------
              		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, COOLKEY_INS_GET_STATUS, 0x01, 0x00);
  ------------------
  |  |   79|    259|#define COOLKEY_INS_GET_STATUS                 0x3c
  ------------------
 2302|    259|		apdu.cla = COOLKEY_CLASS;
  ------------------
  |  |   72|    259|#define COOLKEY_CLASS           0xb0
  ------------------
 2303|    259|		apdu.le = 0x00;
 2304|    259|		apdu.resplen = 0;
 2305|    259|		apdu.resp = NULL;
 2306|    259|		r = sc_transmit_apdu(card, &apdu);
 2307|    259|		if (r == SC_SUCCESS && apdu.sw1 == 0x6d && apdu.sw2 == 0x00) {
  ------------------
  |  |   28|    518|#define SC_SUCCESS				0
  ------------------
  |  Branch (2307:7): [True: 259, False: 0]
  |  Branch (2307:26): [True: 71, False: 188]
  |  Branch (2307:46): [True: 70, False: 1]
  ------------------
 2308|     70|			return 1;
 2309|     70|		}
 2310|    189|		return 0;
 2311|    259|	}
 2312|  1.09k|	return 0;
 2313|  1.35k|}
card-coolkey.c:coolkey_select_applet:
 1074|  1.42k|{
 1075|  1.42k|	u8 aid[] = { 0x62, 0x76, 0x01, 0xff, 0x00, 0x00, 0x00 };
 1076|  1.42k|	return coolkey_apdu_io(card, ISO7816_CLASS, ISO7816_INS_SELECT_FILE, 4, 0,
  ------------------
  |  |   71|  1.42k|#define ISO7816_CLASS           0x00
  ------------------
              	return coolkey_apdu_io(card, ISO7816_CLASS, ISO7816_INS_SELECT_FILE, 4, 0,
  ------------------
  |  |   75|  1.42k|#define ISO7816_INS_SELECT_FILE 0xa4
  ------------------
 1077|  1.42k|			&aid[0], sizeof(aid), NULL, NULL,  NULL, 0);
 1078|  1.42k|}
card-coolkey.c:coolkey_init:
 2317|     70|{
 2318|     70|	int r;
 2319|     70|	unsigned long flags;
 2320|     70|	unsigned long ext_flags;
 2321|     70|	coolkey_private_data_t * priv;
 2322|       |
 2323|     70|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 2324|       |
 2325|     70|	r = coolkey_initialize(card);
 2326|     70|	if (r < 0) {
  ------------------
  |  Branch (2326:6): [True: 69, False: 1]
  ------------------
 2327|     69|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  164|     69|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     69|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     69|	int _ret = r; \
  |  |  |  |  155|     69|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 69, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     69|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     69|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 69, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     69|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     69|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     69|	return _ret; \
  |  |  |  |  163|     69|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2328|     69|	}
 2329|       |
 2330|      1|	card->type = SC_CARD_TYPE_COOLKEY_GENERIC;
 2331|       |
 2332|       |	/* set Token Major/minor version */
 2333|      1|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  111|      1|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 2334|       |
 2335|      1|	_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
 2336|      1|	_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
 2337|      1|	_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
 2338|       |
 2339|      1|	flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  183|      1|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              	flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  182|      1|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              	flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  184|      1|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|      1|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
 2340|      1|	ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  210|      1|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              	ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  211|      1|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
 2341|       |
 2342|      1|	_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
 2343|      1|	_sc_card_add_ec_alg(card, 384, flags, ext_flags, NULL);
 2344|      1|	_sc_card_add_ec_alg(card, 521, flags, ext_flags, NULL);
 2345|       |
 2346|       |
 2347|      1|	priv = COOLKEY_DATA(card);
  ------------------
  |  |  753|      1|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 2348|      1|	if (priv->pin_count != 0) {
  ------------------
  |  Branch (2348:6): [True: 1, False: 0]
  ------------------
 2349|      1|		card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|      1|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 2350|      1|	}
 2351|       |
 2352|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2353|      1|}
card-coolkey.c:coolkey_initialize:
 2157|     70|{
 2158|     70|	int r;
 2159|     70|	coolkey_private_data_t *priv = NULL;
 2160|     70|	coolkey_life_cycle_t life_cycle;
 2161|     70|	coolkey_object_info_t object_info;
 2162|     70|	int combined_processed = 0;
 2163|       |
 2164|       |	/* already found? */
 2165|     70|	if (card->drv_data) {
  ------------------
  |  Branch (2165:6): [True: 0, False: 70]
  ------------------
 2166|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2167|      0|	}
 2168|     70|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,"Coolkey Applet found");
  ------------------
  |  |   70|     70|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2169|       |
 2170|     70|	priv = coolkey_new_private_data();
 2171|     70|	if (priv == NULL) {
  ------------------
  |  Branch (2171:6): [True: 0, False: 70]
  ------------------
 2172|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2173|      0|		goto cleanup;
 2174|      0|	}
 2175|     70|	r = coolkey_get_life_cycle(card, &life_cycle);
 2176|     70|	if (r < 0) {
  ------------------
  |  Branch (2176:6): [True: 2, False: 68]
  ------------------
 2177|      2|		goto cleanup;
 2178|      2|	}
 2179|       |
 2180|       |	/* Select a coolkey read the coolkey objects out */
 2181|     68|	r = coolkey_select_applet(card);
 2182|     68|	if (r < 0) {
  ------------------
  |  Branch (2182:6): [True: 0, False: 68]
  ------------------
 2183|      0|		goto cleanup;
 2184|      0|	}
 2185|       |
 2186|     68|	priv->protocol_version_major = life_cycle.protocol_version_major;
 2187|     68|	priv->protocol_version_minor = life_cycle.protocol_version_minor;
 2188|     68|	priv->pin_count = life_cycle.pin_count;
 2189|     68|	priv->life_cycle = life_cycle.life_cycle;
 2190|       |
 2191|       |	/* walk down the list of objects and read them off the token */
 2192|     68|	r = coolkey_list_object(card, COOLKEY_LIST_RESET, &object_info);
  ------------------
  |  |  104|     68|#define COOLKEY_LIST_RESET 0x00
  ------------------
 2193|  1.76k|	while (r >= 0) {
  ------------------
  |  Branch (2193:9): [True: 1.75k, False: 19]
  ------------------
 2194|  1.75k|		unsigned long object_id;
 2195|  1.75k|		unsigned long object_len;
 2196|       |
 2197|       |		/* The card did not return what we expected: Lets try other objects */
 2198|  1.75k|		if ((size_t)r < (sizeof(object_info)))
  ------------------
  |  Branch (2198:7): [True: 0, False: 1.75k]
  ------------------
 2199|      0|			break;
 2200|       |
 2201|       |		/* TODO also look at the ACL... */
 2202|       |
 2203|  1.75k|		object_id = bebytes2ulong(object_info.object_id);
 2204|  1.75k|		object_len = bebytes2ulong(object_info.object_length);
 2205|       |		/* Avoid insanely large data */
 2206|  1.75k|		if (object_len > MAX_FILE_SIZE) {
  ------------------
  |  |  229|  1.75k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (2206:7): [True: 1, False: 1.74k]
  ------------------
 2207|      1|			r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      1|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2208|      1|			goto cleanup;
 2209|      1|		}
 2210|       |
 2211|       |		/* the combined object is a single object that can store the other objects.
 2212|       |		 * most coolkeys provisioned by TPS has a single combined object that is
 2213|       |		 * compressed greatly increasing the effectiveness of compress (since lots
 2214|       |		 * of certs on the token share the same Subject and Issuer DN's). We now
 2215|       |		 * process it separately so that we can have both combined objects managed
 2216|       |		 * by TPS and user managed certs on the same token */
 2217|  1.74k|		if (object_id == COOLKEY_COMBINED_OBJECT_ID) {
  ------------------
  |  |  109|  1.74k|#define COOLKEY_COMBINED_OBJECT_ID 0x7a300000 /* 'z0\0\0' */
  ------------------
  |  Branch (2217:7): [True: 52, False: 1.69k]
  ------------------
 2218|     52|			u8 *object = malloc(object_len);
 2219|     52|			if (object == NULL) {
  ------------------
  |  Branch (2219:8): [True: 0, False: 52]
  ------------------
 2220|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2221|      0|				break;
 2222|      0|			}
 2223|     52|			r = coolkey_read_object(card, COOLKEY_COMBINED_OBJECT_ID, 0, object, object_len,
  ------------------
  |  |  109|     52|#define COOLKEY_COMBINED_OBJECT_ID 0x7a300000 /* 'z0\0\0' */
  ------------------
 2224|     52|				priv->nonce, sizeof(priv->nonce));
 2225|     52|			if (r < 0) {
  ------------------
  |  Branch (2225:8): [True: 12, False: 40]
  ------------------
 2226|     12|				free(object);
 2227|     12|				break;
 2228|     12|			}
 2229|     40|			r = coolkey_process_combined_object(card, priv, object, r);
 2230|     40|			free(object);
 2231|     40|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     40|#define SC_SUCCESS				0
  ------------------
  |  Branch (2231:8): [True: 36, False: 4]
  ------------------
 2232|     36|				break;
 2233|     36|			}
 2234|      4|			combined_processed = 1;
 2235|  1.69k|		} else {
 2236|  1.69k|			sc_log(card->ctx, "Add new object id=%ld, len=%lu", object_id, object_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2237|  1.69k|			r = coolkey_add_object(priv, object_id, NULL, object_len, 0);
 2238|  1.69k|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|  1.69k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2238:8): [True: 1.38k, False: 313]
  ------------------
 2239|  1.38k|				sc_log(card->ctx, "coolkey_add_object() returned %d", r);
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 2240|  1.69k|		}
 2241|       |
 2242|       |		/* Read next object: error is handled on the cycle condition and below after cycle */
 2243|  1.70k|		r = coolkey_list_object(card, COOLKEY_LIST_NEXT, &object_info);
  ------------------
  |  |  105|  1.70k|#define COOLKEY_LIST_NEXT  0x01
  ------------------
 2244|  1.70k|	}
 2245|     67|	if (r != SC_ERROR_FILE_END_REACHED) {
  ------------------
  |  |   69|     67|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (2245:6): [True: 66, False: 1]
  ------------------
 2246|       |		/* This means the card does not cooperate at all: bail out */
 2247|     66|		if (r >= 0) {
  ------------------
  |  Branch (2247:7): [True: 0, False: 66]
  ------------------
 2248|      0|			r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 2249|      0|		}
 2250|     66|		goto cleanup;
 2251|     66|	}
 2252|       |	/* if we didn't pull the cuid from the combined object, then grab it now */
 2253|      1|	if (!combined_processed) {
  ------------------
  |  Branch (2253:6): [True: 0, False: 1]
  ------------------
 2254|      0|		global_platform_cplc_data_t cplc_data;
 2255|       |		/* select the card manager, because a card with applet only will have
 2256|       |		   already selected the coolkey applet */
 2257|       |
 2258|      0|		r = gp_select_card_manager(card);
 2259|      0|		if (r < 0) {
  ------------------
  |  Branch (2259:7): [True: 0, False: 0]
  ------------------
 2260|      0|			goto cleanup;
 2261|      0|		}
 2262|       |
 2263|      0|		r = gp_get_cplc_data(card, &cplc_data);
 2264|      0|		if (r < 0) {
  ------------------
  |  Branch (2264:7): [True: 0, False: 0]
  ------------------
 2265|      0|			goto cleanup;
 2266|      0|		}
 2267|      0|		coolkey_make_cuid_from_cplc(&priv->cuid, &cplc_data);
 2268|      0|		priv->token_name = (u8 *)strdup("COOLKEY");
 2269|      0|		if (priv->token_name == NULL) {
  ------------------
  |  Branch (2269:7): [True: 0, False: 0]
  ------------------
 2270|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2271|      0|			goto cleanup;
 2272|      0|		}
 2273|      0|		priv->token_name_length = sizeof("COOLKEY")-1;
 2274|      0|	}
 2275|      1|	card->drv_data = priv;
 2276|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2277|       |
 2278|     69|cleanup:
 2279|     69|	if (priv) {
  ------------------
  |  Branch (2279:6): [True: 69, False: 0]
  ------------------
 2280|     69|		coolkey_free_private_data(priv);
 2281|     69|	}
 2282|     69|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     69|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     69|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     69|	int _ret = r; \
  |  |  |  |  155|     69|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 69, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     69|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     69|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 69, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     69|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     69|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     69|	return _ret; \
  |  |  |  |  163|     69|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2283|     69|}
card-coolkey.c:coolkey_new_private_data:
  772|     70|{
  773|     70|	coolkey_private_data_t *priv;
  774|       |
  775|       |	/* allocate priv and zero all the fields */
  776|     70|	priv = calloc(1, sizeof(coolkey_private_data_t));
  777|     70|	if (!priv)
  ------------------
  |  Branch (777:6): [True: 0, False: 70]
  ------------------
  778|      0|		return NULL;
  779|       |
  780|       |	/* set other fields as appropriate */
  781|     70|	priv->key_id = COOLKEY_INVALID_KEY;
  ------------------
  |  |  110|     70|#define COOLKEY_INVALID_KEY        0xff00
  ------------------
  782|     70|	if (list_init(&priv->objects_list) != 0 ||
  ------------------
  |  Branch (782:6): [True: 0, False: 70]
  ------------------
  783|     70|	    list_attributes_comparator(&priv->objects_list, coolkey_compare_id) != 0 ||
  ------------------
  |  Branch (783:6): [True: 0, False: 70]
  ------------------
  784|     70|	    list_attributes_copy(&priv->objects_list, coolkey_list_meter, 1) != 0) {
  ------------------
  |  Branch (784:6): [True: 0, False: 70]
  ------------------
  785|      0|		coolkey_free_private_data(priv);
  786|      0|		return NULL;
  787|      0|	}
  788|       |
  789|     70|	return priv;
  790|     70|}
card-coolkey.c:coolkey_get_life_cycle:
 1032|     70|{
 1033|     70|	coolkey_status_t status;
 1034|     70|	u8 *receive_buf;
 1035|     70|	size_t receive_len;
 1036|     70|	int len;
 1037|       |
 1038|     70|	receive_len = sizeof(*life_cycle);
 1039|     70|	receive_buf = (u8 *)life_cycle;
 1040|     70|	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_LIFE_CYCLE, 0, 0,
  ------------------
  |  |   72|     70|#define COOLKEY_CLASS           0xb0
  ------------------
              	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_LIFE_CYCLE, 0, 0,
  ------------------
  |  |   78|     70|#define COOLKEY_INS_GET_LIFE_CYCLE             0xf2
  ------------------
 1041|     70|			NULL, 0, &receive_buf, &receive_len, NULL, 0);
 1042|     70|	if (len == sizeof(*life_cycle)) {
  ------------------
  |  Branch (1042:6): [True: 65, False: 5]
  ------------------
 1043|     65|		return SC_SUCCESS;
  ------------------
  |  |   28|     65|#define SC_SUCCESS				0
  ------------------
 1044|     65|	}
 1045|       |
 1046|      5|	receive_len = 1;
 1047|      5|	receive_buf = &life_cycle->life_cycle;
 1048|      5|	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_LIFE_CYCLE, 0, 0,
  ------------------
  |  |   72|      5|#define COOLKEY_CLASS           0xb0
  ------------------
              	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_LIFE_CYCLE, 0, 0,
  ------------------
  |  |   78|      5|#define COOLKEY_INS_GET_LIFE_CYCLE             0xf2
  ------------------
 1049|      5|			NULL, 0, &receive_buf, &receive_len, NULL, 0);
 1050|      5|	if (len < 0) { /* Error from the trasmittion */
  ------------------
  |  Branch (1050:6): [True: 2, False: 3]
  ------------------
 1051|      2|		return len;
 1052|      2|	}
 1053|      3|	if (len != 1) { /* The returned data is invalid */
  ------------------
  |  Branch (1053:6): [True: 0, False: 3]
  ------------------
 1054|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1055|      0|	}
 1056|      3|	receive_len = sizeof(status);
 1057|      3|	receive_buf = (u8 *)&status;
 1058|      3|	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_STATUS, 0, 0,
  ------------------
  |  |   72|      3|#define COOLKEY_CLASS           0xb0
  ------------------
              	len = coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_GET_STATUS, 0, 0,
  ------------------
  |  |   79|      3|#define COOLKEY_INS_GET_STATUS                 0x3c
  ------------------
 1059|      3|			NULL, 0, &receive_buf, &receive_len, NULL, 0);
 1060|      3|	if (len < 0) { /* Error from the trasmittion */
  ------------------
  |  Branch (1060:6): [True: 0, False: 3]
  ------------------
 1061|      0|		return len;
 1062|      0|	}
 1063|      3|	if (len != sizeof(status)) { /* The returned data is invalid */
  ------------------
  |  Branch (1063:6): [True: 0, False: 3]
  ------------------
 1064|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1065|      0|	}
 1066|      3|	life_cycle->protocol_version_major = status.protocol_version_major;
 1067|      3|	life_cycle->protocol_version_minor = status.protocol_version_minor;
 1068|      3|	life_cycle->pin_count = status.pin_count;
 1069|      3|	return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
 1070|      3|}
card-coolkey.c:coolkey_list_object:
 2144|  1.76k|{
 2145|  1.76k|	u8 *rbuf = (u8 *) object_info;
 2146|  1.76k|	size_t rbuflen = sizeof(*object_info);
 2147|       |
 2148|  1.76k|	return coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_LIST_OBJECTS, seq, 0,
  ------------------
  |  |   72|  1.76k|#define COOLKEY_CLASS           0xb0
  ------------------
              	return coolkey_apdu_io(card, COOLKEY_CLASS, COOLKEY_INS_LIST_OBJECTS, seq, 0,
  ------------------
  |  |   81|  1.76k|#define COOLKEY_INS_LIST_OBJECTS               0x58
  ------------------
 2149|  1.76k|			NULL, 0, &rbuf, &rbuflen, NULL, 0);
 2150|       |
 2151|  1.76k|}
card-coolkey.c:coolkey_process_combined_object:
 2013|     40|{
 2014|     40|	coolkey_combined_header_t *header = (coolkey_combined_header_t *)object;
 2015|     40|	unsigned short compressed_offset;
 2016|     40|	unsigned short compressed_length;
 2017|     40|	unsigned short compressed_type;
 2018|     40|	unsigned short object_offset;
 2019|     40|	unsigned short object_count;
 2020|     40|	coolkey_decompressed_header_t *decompressed_header;
 2021|     40|	u8 *decompressed_object = NULL;
 2022|     40|	size_t decompressed_object_len = 0;
 2023|     40|	int free_decompressed = 0;
 2024|     40|	int i, r;
 2025|       |
 2026|     40|	if (object_length < sizeof(coolkey_combined_header_t)) {
  ------------------
  |  Branch (2026:6): [True: 0, False: 40]
  ------------------
 2027|      0|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2028|      0|	}
 2029|     40|	compressed_offset = bebytes2ushort(header->compression_offset);
 2030|     40|	compressed_length = bebytes2ushort(header->compression_length);
 2031|     40|	compressed_type   = bebytes2ushort(header->compression_type);
 2032|       |
 2033|     40|	if ((((size_t)compressed_offset) + (size_t)compressed_length) >  object_length) {
  ------------------
  |  Branch (2033:6): [True: 1, False: 39]
  ------------------
 2034|      1|		return SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      1|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2035|      1|	}
 2036|       |
 2037|       |	/* store the CUID */
 2038|     39|	memcpy(&priv->cuid, &header->cuid, sizeof(priv->cuid));
 2039|       |
 2040|     39|	if (compressed_type == COOLKEY_COMPRESSION_ZLIB) {
  ------------------
  |  |  180|     39|#define COOLKEY_COMPRESSION_ZLIB 1
  ------------------
  |  Branch (2040:6): [True: 5, False: 34]
  ------------------
 2041|      5|#ifdef ENABLE_ZLIB
 2042|      5|		r = sc_decompress_alloc(&decompressed_object, &decompressed_object_len, &object[compressed_offset], compressed_length, COMPRESSION_AUTO);
  ------------------
  |  |   26|      5|#define COMPRESSION_AUTO	0
  ------------------
 2043|      5|		if (r)
  ------------------
  |  Branch (2043:7): [True: 5, False: 0]
  ------------------
 2044|      5|			goto done;
 2045|      0|		free_decompressed = 1;
 2046|       |#else
 2047|       |		sc_log(card->ctx, "Coolkey compression not supported, no zlib");
 2048|       |		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
 2049|       |#endif
 2050|     34|	}  else {
 2051|     34|		decompressed_object =&object[compressed_offset];
 2052|     34|		decompressed_object_len = (size_t) compressed_length;
 2053|     34|	}
 2054|       |
 2055|     34|	decompressed_header = (coolkey_decompressed_header_t *)decompressed_object;
 2056|       |
 2057|     34|	if (decompressed_object_len < sizeof(coolkey_decompressed_header_t)) {
  ------------------
  |  Branch (2057:6): [True: 3, False: 31]
  ------------------
 2058|      3|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      3|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2059|      3|		goto done;
 2060|      3|	}
 2061|     31|	object_offset = bebytes2ushort(decompressed_header->object_offset);
 2062|     31|	object_count = bebytes2ushort(decompressed_header->object_count);
 2063|       |
 2064|       |
 2065|       |	/*
 2066|       |	 * using 2 different tests here so we can log different errors if logging is
 2067|       |	 * turned on.
 2068|       |	 */
 2069|       |	/* make sure token_name doesn't overrun the buffer */
 2070|     31|	if (decompressed_header->token_name_length +
  ------------------
  |  Branch (2070:6): [True: 0, False: 31]
  ------------------
 2071|     31|		offsetof(coolkey_decompressed_header_t, token_name) > decompressed_object_len) {
 2072|      0|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2073|      0|		goto done;
 2074|      0|	}
 2075|       |	/* make sure it doesn't overlap the object space */
 2076|     31|	if (decompressed_header->token_name_length +
  ------------------
  |  Branch (2076:6): [True: 1, False: 30]
  ------------------
 2077|     31|		offsetof(coolkey_decompressed_header_t, token_name) > object_offset) {
 2078|      1|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      1|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2079|      1|		goto done;
 2080|      1|	}
 2081|       |
 2082|       |	/* store the token name in the priv structure so the emulator can set it */
 2083|     30|	free(priv->token_name);
 2084|     30|	priv->token_name = malloc(decompressed_header->token_name_length+1);
 2085|     30|	if (priv->token_name == NULL) {
  ------------------
  |  Branch (2085:6): [True: 0, False: 30]
  ------------------
 2086|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2087|      0|		goto done;
 2088|      0|	}
 2089|     30|	memcpy(priv->token_name, &decompressed_header->token_name[0],
 2090|     30|							decompressed_header->token_name_length);
 2091|     30|	priv->token_name[decompressed_header->token_name_length] = '\0';
 2092|     30|	priv->token_name_length = decompressed_header->token_name_length;
 2093|       |
 2094|       |
 2095|     64|	for (i=0; i < object_count; i++) {
  ------------------
  |  Branch (2095:12): [True: 60, False: 4]
  ------------------
 2096|     60|		u8 *current_object = NULL;
 2097|     60|		coolkey_combined_object_header_t *object_header = NULL;
 2098|     60|		unsigned long object_id;
 2099|     60|		int current_object_len;
 2100|       |
 2101|       |		/* Can we read the object header at all? */
 2102|     60|		if ((object_offset + sizeof(coolkey_combined_object_header_t)) > decompressed_object_len) {
  ------------------
  |  Branch (2102:7): [True: 24, False: 36]
  ------------------
 2103|     24|			r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|     24|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2104|     24|			goto done;
 2105|     24|		}
 2106|       |
 2107|     36|		current_object = &decompressed_object[object_offset];
 2108|     36|		object_header = (coolkey_combined_object_header_t *)current_object;
 2109|       |
 2110|       |		/* Parse object ID */
 2111|     36|		object_id = bebytes2ulong(object_header->object_id);
 2112|       |
 2113|       |		/* figure out how big it is */
 2114|     36|		r = coolkey_v1_get_object_length(current_object, decompressed_object_len-object_offset);
 2115|     36|		if (r < 0) {
  ------------------
  |  Branch (2115:7): [True: 0, False: 36]
  ------------------
 2116|      0|			goto done;
 2117|      0|		}
 2118|     36|		if ((size_t)r + object_offset > decompressed_object_len) {
  ------------------
  |  Branch (2118:7): [True: 0, False: 36]
  ------------------
 2119|      0|			r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 2120|      0|			goto done;
 2121|      0|		}
 2122|     36|		current_object_len = r;
 2123|     36|		object_offset += current_object_len;
 2124|       |
 2125|       |		/* record this object */
 2126|     36|		sc_log(card->ctx, "Add new object id=%ld", object_id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2127|     36|		r = coolkey_add_object(priv, object_id, current_object, current_object_len, 1);
 2128|     36|		if (r) {
  ------------------
  |  Branch (2128:7): [True: 2, False: 34]
  ------------------
 2129|      2|			goto done;
 2130|      2|		}
 2131|       |
 2132|     36|	}
 2133|      4|	r = SC_SUCCESS;
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
 2134|       |
 2135|     39|done:
 2136|     39|	if (free_decompressed) {
  ------------------
  |  Branch (2136:6): [True: 0, False: 39]
  ------------------
 2137|      0|		free(decompressed_object);
 2138|      0|	}
 2139|     39|	return r;
 2140|      4|}
card-coolkey.c:coolkey_v1_get_object_length:
  706|     36|{
  707|     36|	coolkey_combined_object_header_t *object_head = (coolkey_combined_object_header_t *) obj;
  708|     36|	int attribute_count;
  709|     36|	u8 *current_attribute;
  710|     36|	int j;
  711|     36|	size_t len;
  712|       |
  713|     36|	len = sizeof(coolkey_combined_object_header_t);
  714|     36|	if (buf_len <= len) {
  ------------------
  |  Branch (714:6): [True: 0, False: 36]
  ------------------
  715|      0|		return (int)buf_len;
  716|      0|	}
  717|     36|	attribute_count = bebytes2ushort(object_head->attribute_count);
  718|     36|	buf_len -= len;
  719|       |
  720|   225k|	for (current_attribute = obj + len, j = 0; j < attribute_count; j++) {
  ------------------
  |  Branch (720:45): [True: 225k, False: 36]
  ------------------
  721|   225k|		size_t attribute_len = coolkey_v1_get_attribute_record_len(current_attribute, buf_len);
  722|       |
  723|   225k|		len += attribute_len;
  724|   225k|		current_attribute += attribute_len;
  725|   225k|		buf_len -= attribute_len;
  726|   225k|	}
  727|     36|	return (int)len;
  728|     36|}
card-coolkey.c:coolkey_add_object:
 1972|  1.73k|{
 1973|  1.73k|	sc_cardctl_coolkey_object_t new_object;
 1974|  1.73k|	int r;
 1975|       |
 1976|  1.73k|	memset(&new_object, 0, sizeof(new_object));
 1977|  1.73k|	new_object.path = coolkey_template_path;
 1978|  1.73k|	new_object.path.len = 4;
 1979|  1.73k|	ulong2bebytes(new_object.path.value, object_id);
 1980|  1.73k|	new_object.id = object_id;
 1981|  1.73k|	new_object.length = object_length;
 1982|       |
 1983|       |	/* The object ID needs to be unique */
 1984|  1.73k|	if (coolkey_find_object_by_id(&priv->objects_list, object_id) != NULL) {
  ------------------
  |  Branch (1984:6): [True: 1.38k, False: 347]
  ------------------
 1985|  1.38k|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  1.38k|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1986|  1.38k|	}
 1987|       |
 1988|    347|	if (object_data) {
  ------------------
  |  Branch (1988:6): [True: 34, False: 313]
  ------------------
 1989|     34|		new_object.data = malloc(object_length + add_v1_record);
 1990|     34|		if (new_object.data == NULL) {
  ------------------
  |  Branch (1990:7): [True: 0, False: 34]
  ------------------
 1991|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1992|      0|		}
 1993|     34|		if (add_v1_record) {
  ------------------
  |  Branch (1993:7): [True: 34, False: 0]
  ------------------
 1994|     34|			new_object.data[0] = COOLKEY_V1_OBJECT;
  ------------------
  |  |  229|     34|#define COOLKEY_V1_OBJECT 1
  ------------------
 1995|     34|			new_object.length++;
 1996|     34|		}
 1997|     34|		memcpy(&new_object.data[add_v1_record], object_data, object_length);
 1998|     34|	}
 1999|       |
 2000|    347|	r = coolkey_add_object_to_list(&priv->objects_list, &new_object);
 2001|    347|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    347|#define SC_SUCCESS				0
  ------------------
  |  Branch (2001:6): [True: 0, False: 347]
  ------------------
 2002|       |		/* if we didn't successfully put the object on the list,
 2003|       |		 * the data space didn't get adopted. free it before we return */
 2004|      0|		free(new_object.data);
 2005|       |		new_object.data = NULL;
 2006|      0|	}
 2007|    347|	return r;
 2008|    347|}
card-coolkey.c:coolkey_add_object_to_list:
  816|    347|{
  817|    347|	if (list_append(list, object) < 0)
  ------------------
  |  Branch (817:6): [True: 0, False: 347]
  ------------------
  818|      0|		return SC_ERROR_UNKNOWN;
  ------------------
  |  |  130|      0|#define SC_ERROR_UNKNOWN			-1900
  ------------------
  819|    347|	return SC_SUCCESS;
  ------------------
  |  |   28|    347|#define SC_SUCCESS				0
  ------------------
  820|    347|}
card-coolkey.c:coolkey_free_private_data:
  793|     70|{
  794|     70|	list_t *l = &priv->objects_list;
  795|     70|	sc_cardctl_coolkey_object_t *o;
  796|       |
  797|       |	/* Clean up the allocated memory in the items */
  798|     70|	list_iterator_start(l);
  799|    417|	while (list_iterator_hasnext(l)) {
  ------------------
  |  Branch (799:9): [True: 347, False: 70]
  ------------------
  800|    347|		o = (sc_cardctl_coolkey_object_t *)list_iterator_next(l);
  801|    347|		free(o->data);
  802|    347|		o->data = NULL;
  803|    347|	}
  804|     70|	list_iterator_stop(l);
  805|       |
  806|     70|	list_destroy(&priv->objects_list);
  807|     70|	free(priv->token_name);
  808|     70|	free(priv);
  809|     70|	return;
  810|     70|}
card-coolkey.c:coolkey_finish:
 1960|      1|{
 1961|      1|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  753|      1|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1962|       |
 1963|      1|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1964|      1|	if (priv) {
  ------------------
  |  Branch (1964:6): [True: 1, False: 0]
  ------------------
 1965|      1|		coolkey_free_private_data(priv);
 1966|      1|	}
 1967|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1968|      1|}
card-coolkey.c:coolkey_card_ctl:
 1589|      1|{
 1590|      1|	coolkey_private_data_t * priv = COOLKEY_DATA(card);
  ------------------
  |  |  753|      1|#define COOLKEY_DATA(card) ((coolkey_private_data_t*)card->drv_data)
  ------------------
 1591|       |
 1592|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1593|      1|	sc_log(card->ctx, "cmd=%ld ptr=%p", cmd, ptr);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1594|       |
 1595|      1|	if (priv == NULL) {
  ------------------
  |  Branch (1595:6): [True: 0, False: 1]
  ------------------
 1596|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1597|      0|	}
 1598|      1|	switch(cmd) {
  ------------------
  |  Branch (1598:9): [True: 0, False: 1]
  ------------------
 1599|      0|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1599:3): [True: 0, False: 1]
  ------------------
 1600|      0|			return coolkey_get_serial_nr_from_CUID(card, (sc_serial_number_t *) ptr);
 1601|      0|		case SC_CARDCTL_COOLKEY_GET_TOKEN_INFO:
  ------------------
  |  Branch (1601:3): [True: 0, False: 1]
  ------------------
 1602|      0|			return coolkey_get_token_info(card, (sc_pkcs15_tokeninfo_t *) ptr);
 1603|      0|		case SC_CARDCTL_COOLKEY_FIND_OBJECT:
  ------------------
  |  Branch (1603:3): [True: 0, False: 1]
  ------------------
 1604|      0|			return coolkey_find_object(card, (sc_cardctl_coolkey_find_object_t *)ptr);
 1605|      0|		case SC_CARDCTL_COOLKEY_INIT_GET_OBJECTS:
  ------------------
  |  Branch (1605:3): [True: 0, False: 1]
  ------------------
 1606|      0|			return coolkey_get_init_and_get_count(&priv->objects_list, (int *)ptr);
 1607|      0|		case SC_CARDCTL_COOLKEY_GET_NEXT_OBJECT:
  ------------------
  |  Branch (1607:3): [True: 0, False: 1]
  ------------------
 1608|      0|			return coolkey_fetch_object(&priv->objects_list, (sc_cardctl_coolkey_object_t *)ptr);
 1609|      0|		case SC_CARDCTL_COOLKEY_FINAL_GET_OBJECTS:
  ------------------
  |  Branch (1609:3): [True: 0, False: 1]
  ------------------
 1610|      0|			return coolkey_final_iterator(&priv->objects_list);
 1611|      0|		case SC_CARDCTL_COOLKEY_GET_ATTRIBUTE:
  ------------------
  |  Branch (1611:3): [True: 0, False: 1]
  ------------------
 1612|      0|			return coolkey_find_attribute(card,(sc_cardctl_coolkey_attribute_t *)ptr);
 1613|      1|	}
 1614|       |
 1615|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1616|      1|}
card-coolkey.c:coolkey_check_sw:
  876|  3.93k|{
  877|  3.93k|	sc_log(card->ctx,
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  878|  3.93k|		"sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
  879|       |
  880|  3.93k|	if (sw1 == 0x90 && sw2 == 0x00)
  ------------------
  |  Branch (880:6): [True: 2.80k, False: 1.12k]
  |  Branch (880:21): [True: 2.79k, False: 6]
  ------------------
  881|  2.79k|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.79k|#define SC_SUCCESS				0
  ------------------
  882|       |
  883|  1.13k|	if (sw1 == 0x9c) {
  ------------------
  |  Branch (883:6): [True: 0, False: 1.13k]
  ------------------
  884|      0|		if (sw2 == 0xff) {
  ------------------
  |  Branch (884:7): [True: 0, False: 0]
  ------------------
  885|       |			/* shouldn't happen on a production applet, 0x9cff is a debugging error code */
  886|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  887|      0|		}
  888|      0|		if (sw2 >= coolkey_number_of_error_codes) {
  ------------------
  |  Branch (888:7): [True: 0, False: 0]
  ------------------
  889|      0|			return SC_ERROR_UNKNOWN;
  ------------------
  |  |  130|      0|#define SC_ERROR_UNKNOWN			-1900
  ------------------
  890|      0|		}
  891|      0|		return coolkey_error_codes[sw2].sc_error;
  892|      0|	}
  893|       |
  894|       |	/* iso error */
  895|  1.13k|        return sc_get_iso7816_driver()->ops->check_sw(card, sw1, sw2);
  896|  1.13k|}
card-coolkey.c:coolkey_card_reader_lock_obtained:
 2427|  3.96k|{
 2428|  3.96k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  3.96k|#define SC_SUCCESS				0
  ------------------
 2429|       |
 2430|  3.96k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.96k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.96k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.96k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.96k]
  |  |  ------------------
  ------------------
 2431|       |
 2432|  3.96k|	if (was_reset > 0) {
  ------------------
  |  Branch (2432:6): [True: 0, False: 3.96k]
  ------------------
 2433|      0|		r = coolkey_select_applet(card);
 2434|      0|	}
 2435|       |
 2436|  3.96k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.96k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.96k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.96k|	int _ret = r; \
  |  |  |  |  155|  3.96k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.96k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.96k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.96k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.96k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.96k|	} else { \
  |  |  |  |  159|      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.96k|	return _ret; \
  |  |  |  |  163|  3.96k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2437|  3.96k|}

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

dnie_match_card:
  738|  4.82k|{
  739|  4.82k|	int result = 0;
  740|  4.82k|	int matched = -1;
  741|  4.82k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  4.82k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.82k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.82k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.82k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.82k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|  4.82k|	matched = _sc_match_atr(card, dnie_atrs, &card->type);
  743|  4.82k|	result = (matched >= 0) ? 1 : 0;
  ------------------
  |  Branch (743:11): [True: 0, False: 4.82k]
  ------------------
  744|  4.82k|	LOG_FUNC_RETURN(card->ctx, result);
  ------------------
  |  |  164|  4.82k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.82k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.82k|	int _ret = r; \
  |  |  |  |  155|  4.82k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.82k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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: 4.82k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.82k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.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|  4.82k|	return _ret; \
  |  |  |  |  163|  4.82k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  745|  4.82k|}
sc_get_dnie_driver:
 2305|  3.69k|{
 2306|  3.69k|	return get_dnie_driver();
 2307|  3.69k|}
card-dnie.c:get_dnie_driver:
 2242|  3.69k|{
 2243|  3.69k|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 2244|       |
 2245|       |	/* memcpy() from standard iso7816 declared operations */
 2246|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2246:6): [True: 1, False: 3.69k]
  ------------------
 2247|      1|		iso_ops = iso_drv->ops;
 2248|  3.69k|	dnie_ops = *iso_drv->ops;
 2249|       |
 2250|       |	/* fill card specific function pointers */
 2251|       |	/* NULL means that function is not supported neither by DNIe nor iso7816.c */
 2252|       |	/* if pointer is omitted, default ISO7816 function will be used */
 2253|       |
 2254|       |	/* initialization */
 2255|  3.69k|	dnie_ops.match_card	= dnie_match_card;
 2256|  3.69k|	dnie_ops.init		= dnie_init;
 2257|  3.69k|	dnie_ops.finish		= dnie_finish;
 2258|       |
 2259|       |	/* iso7816-4 functions */
 2260|  3.69k|	dnie_ops.read_binary	= dnie_read_binary;
 2261|  3.69k|	dnie_ops.write_binary	= NULL;
 2262|  3.69k|	dnie_ops.update_binary	= NULL;
 2263|  3.69k|	dnie_ops.erase_binary	= NULL;
 2264|  3.69k|	dnie_ops.read_record	= NULL;
 2265|  3.69k|	dnie_ops.write_record	= NULL;
 2266|  3.69k|	dnie_ops.append_record	= NULL;
 2267|  3.69k|	dnie_ops.update_record	= NULL;
 2268|  3.69k|	dnie_ops.select_file	= dnie_select_file;
 2269|  3.69k|	dnie_ops.get_challenge	= dnie_get_challenge;
 2270|       |
 2271|       |	/* iso7816-8 functions */
 2272|  3.69k|	dnie_ops.verify		= NULL;
 2273|  3.69k|	dnie_ops.logout		= dnie_logout;
 2274|       |	/* dnie_ops.restore_security_env */
 2275|  3.69k|	dnie_ops.set_security_env = dnie_set_security_env;
 2276|  3.69k|	dnie_ops.decipher	= dnie_decipher;
 2277|  3.69k|	dnie_ops.compute_signature = dnie_compute_signature;
 2278|  3.69k|	dnie_ops.change_reference_data = NULL;
 2279|  3.69k|	dnie_ops.reset_retry_counter = NULL;
 2280|       |
 2281|       |	/* iso7816-9 functions */
 2282|  3.69k|	dnie_ops.create_file	= NULL;
 2283|  3.69k|	dnie_ops.delete_file	= NULL;
 2284|  3.69k|	dnie_ops.list_files	= dnie_list_files;
 2285|  3.69k|	dnie_ops.check_sw	= dnie_check_sw;
 2286|  3.69k|	dnie_ops.card_ctl	= dnie_card_ctl;
 2287|  3.69k|	dnie_ops.process_fci	= dnie_process_fci;
 2288|       |	/* dnie_ops.construct_fci */
 2289|  3.69k|	dnie_ops.pin_cmd	= dnie_pin_cmd;
 2290|  3.69k|	dnie_ops.get_data	= NULL;
 2291|  3.69k|	dnie_ops.put_data	= NULL;
 2292|  3.69k|	dnie_ops.delete_record	= NULL;
 2293|       |
 2294|  3.69k|	return &dnie_driver;
 2295|  3.69k|}

sc_get_dtrust_driver:
 1048|  3.69k|{
 1049|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1049:6): [True: 1, False: 3.69k]
  ------------------
 1050|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1051|       |
 1052|  3.69k|	dtrust_ops = *iso_ops;
 1053|  3.69k|	dtrust_ops.match_card = dtrust_match_card;
 1054|  3.69k|	dtrust_ops.init = dtrust_init;
 1055|  3.69k|	dtrust_ops.finish = dtrust_finish;
 1056|  3.69k|	dtrust_ops.pin_cmd = dtrust_pin_cmd;
 1057|  3.69k|	dtrust_ops.set_security_env = dtrust_set_security_env;
 1058|  3.69k|	dtrust_ops.compute_signature = dtrust_compute_signature;
 1059|  3.69k|	dtrust_ops.decipher = dtrust_decipher;
 1060|  3.69k|	dtrust_ops.logout = dtrust_logout;
 1061|       |
 1062|  3.69k|	return &dtrust_drv;
 1063|  3.69k|}
card-dtrust.c:dtrust_match_card:
  232|  3.64k|{
  233|  3.64k|	if (_sc_match_atr(card, dtrust_atrs, &card->type) < 0)
  ------------------
  |  Branch (233:6): [True: 3.51k, False: 129]
  ------------------
  234|  3.51k|		return 0;
  235|       |
  236|    129|	if (_dtrust_match_cardos(card) != SC_SUCCESS)
  ------------------
  |  |   28|    129|#define SC_SUCCESS				0
  ------------------
  |  Branch (236:6): [True: 129, False: 0]
  ------------------
  237|    129|		return 0;
  238|       |
  239|      0|	if (_dtrust_match_profile(card) != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (239:6): [True: 0, False: 0]
  ------------------
  240|      0|		return 0;
  241|       |
  242|      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__
  |  |  ------------------
  ------------------
  243|       |
  244|      0|	return 1;
  245|      0|}
card-dtrust.c:_dtrust_match_cardos:
  114|    129|{
  115|    129|	int r;
  116|    129|	size_t prodlen;
  117|    129|	u8 buf[32];
  118|       |
  119|       |	/* check OS version */
  120|    129|	r = sc_get_data(card, 0x0182, buf, 32);
  121|    129|	LOG_TEST_RET(card->ctx, r, "OS version check failed");
  ------------------
  |  |  174|    129|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    129|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    129|	int _ret = (r); \
  |  |  |  |  168|    129|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 129, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    129|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    129|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    129|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    129|		return _ret; \
  |  |  |  |  172|    129|	} \
  |  |  |  |  173|    129|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|       |
  123|      0|	if (card->type == SC_CARD_TYPE_DTRUST_V4_1_STD) {
  ------------------
  |  Branch (123:6): [True: 0, False: 0]
  ------------------
  124|      0|		if (r != 2 || buf[0] != 0xc9 || buf[1] != 0x04)
  ------------------
  |  Branch (124:7): [True: 0, False: 0]
  |  Branch (124:17): [True: 0, False: 0]
  |  Branch (124:35): [True: 0, False: 0]
  ------------------
  125|      0|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  126|      0|	} else if (card->type == SC_CARD_TYPE_DTRUST_V5_1_STD) {
  ------------------
  |  Branch (126:13): [True: 0, False: 0]
  ------------------
  127|      0|		if (r != 2 || buf[0] != 0xcb || buf[1] != 0x01)
  ------------------
  |  Branch (127:7): [True: 0, False: 0]
  |  Branch (127:17): [True: 0, False: 0]
  |  Branch (127:35): [True: 0, False: 0]
  ------------------
  128|      0|			return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  129|      0|	}
  130|       |
  131|       |	/* check product name */
  132|      0|	r = sc_get_data(card, 0x0180, buf, 32);
  133|      0|	LOG_TEST_RET(card->ctx, r, "Product name 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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|  3.69k|struct sc_card_driver* sc_get_edo_driver(void) {
  307|  3.69k|	edo_ops = *sc_get_iso7816_driver()->ops;
  308|  3.69k|	edo_ops.match_card = edo_match_card;
  309|  3.69k|	edo_ops.init = edo_init;
  310|  3.69k|	edo_ops.select_file = edo_select_file;
  311|  3.69k|	edo_ops.set_security_env = edo_set_security_env;
  312|  3.69k|	edo_ops.compute_signature = edo_compute_signature;
  313|  3.69k|	edo_ops.logout = edo_logout;
  314|       |
  315|  3.69k|	return &edo_drv;
  316|  3.69k|}
card-edo.c:edo_match_card:
   62|  1.35k|static int edo_match_card(sc_card_t* card) {
   63|  1.35k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.35k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.35k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.35k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.35k]
  |  |  ------------------
  ------------------
   64|  1.35k|	if (_sc_match_atr(card, edo_atrs, &card->type) >= 0) {
  ------------------
  |  Branch (64:6): [True: 0, False: 1.35k]
  ------------------
   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|  1.35k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  1.35k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.35k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.35k|	int _ret = r; \
  |  |  |  |  155|  1.35k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.35k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.35k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.35k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.35k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.35k|	} else { \
  |  |  |  |  159|      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.35k|	return _ret; \
  |  |  |  |  163|  1.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   69|  1.35k|}

sc_get_entersafe_driver:
 1579|  3.69k|{
 1580|  3.69k|	return sc_get_driver();
 1581|  3.69k|}
card-entersafe.c:sc_get_driver:
 1553|  3.69k|{
 1554|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1555|       |
 1556|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1556:6): [True: 1, False: 3.69k]
  ------------------
 1557|      1|		iso_ops = iso_drv->ops;
 1558|       |
 1559|  3.69k|	entersafe_ops = *iso_drv->ops;
 1560|  3.69k|	entersafe_ops.match_card = entersafe_match_card;
 1561|  3.69k|	entersafe_ops.init = entersafe_init;
 1562|  3.69k|	entersafe_ops.read_binary = entersafe_read_binary;
 1563|  3.69k|	entersafe_ops.write_binary = NULL;
 1564|  3.69k|	entersafe_ops.update_binary = entersafe_update_binary;
 1565|  3.69k|	entersafe_ops.select_file = entersafe_select_file;
 1566|  3.69k|	entersafe_ops.restore_security_env = entersafe_restore_security_env;
 1567|  3.69k|	entersafe_ops.set_security_env = entersafe_set_security_env;
 1568|  3.69k|	entersafe_ops.decipher = entersafe_decipher;
 1569|  3.69k|	entersafe_ops.compute_signature = entersafe_compute_signature;
 1570|  3.69k|	entersafe_ops.create_file = entersafe_create_file;
 1571|       |	entersafe_ops.delete_file = NULL;
 1572|  3.69k|	entersafe_ops.pin_cmd = entersafe_pin_cmd;
 1573|  3.69k|	entersafe_ops.card_ctl = entersafe_card_ctl_2048;
 1574|  3.69k|	entersafe_ops.process_fci = entersafe_process_fci;
 1575|  3.69k|	return &entersafe_drv;
 1576|  3.69k|}
card-entersafe.c:entersafe_match_card:
  135|  2.45k|{
  136|  2.45k|	int i;
  137|  2.45k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  138|       |
  139|  2.45k|	i = _sc_match_atr(card, entersafe_atrs, &card->type);
  140|  2.45k|	if (i < 0)
  ------------------
  |  Branch (140:6): [True: 2.42k, False: 33]
  ------------------
  141|  2.42k|		return 0;
  142|       |
  143|     33|	return 1;
  144|  2.45k|}
card-entersafe.c:entersafe_init:
  147|     33|{
  148|     33|	unsigned int flags;
  149|       |
  150|     33|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     33|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     33|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     33|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 33]
  |  |  ------------------
  ------------------
  151|       |
  152|     33|	card->name = "entersafe";
  153|     33|	card->cla  = 0x00;
  154|     33|	card->drv_data = NULL;
  155|       |
  156|     33|	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  102|     33|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  111|     33|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  142|     33|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  157|       |
  158|     33|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  159|     33|	_sc_card_add_rsa_alg(card, 768, flags, 0);
  160|     33|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  161|     33|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  162|       |
  163|     33|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  557|     33|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  164|       |
  165|       |	/* we need read_binary&friends with max 224 bytes per read */
  166|     33|	card->max_send_size = 224;
  167|     33|	card->max_recv_size = 224;
  168|     33|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  169|     33|}
card-entersafe.c:entersafe_read_binary:
  427|  2.38k|{
  428|  2.38k|	sc_apdu_t apdu;
  429|  2.38k|	u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
  430|  2.38k|	int r;
  431|       |
  432|  2.38k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  433|       |
  434|  2.38k|	if (count > card->max_recv_size)
  ------------------
  |  Branch (434:6): [True: 0, False: 2.38k]
  ------------------
  435|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  436|  2.38k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (idx >> 8) & 0xFF, idx & 0xFF);
  ------------------
  |  |  292|  2.38k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  437|       |
  438|  2.38k|	apdu.cla = idx > 0x7fff ? 0x80 : 0x00;
  ------------------
  |  Branch (438:13): [True: 59, False: 2.32k]
  ------------------
  439|  2.38k|	apdu.le = count;
  440|  2.38k|	apdu.resplen = count;
  441|  2.38k|	apdu.resp = recvbuf;
  442|       |
  443|  2.38k|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
  444|  2.38k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.38k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.38k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.38k|	int _ret = (r); \
  |  |  |  |  168|  2.38k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 2.38k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.38k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.38k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|  2.38k|	if (apdu.resplen == 0)
  ------------------
  |  Branch (445:6): [True: 17, False: 2.36k]
  ------------------
  446|     17|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 9, False: 8]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  447|  2.36k|	memcpy(buf, recvbuf, apdu.resplen);
  448|       |
  449|  2.36k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)apdu.resplen);
  ------------------
  |  |  153|  2.36k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  2.36k|	int _ret = r; \
  |  |  155|  2.36k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 2.36k]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  2.36k|	} else { \
  |  |  159|  2.36k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|  2.36k|			"returning with: %d\n", _ret); \
  |  |  161|  2.36k|	} \
  |  |  162|  2.36k|	return _ret; \
  |  |  163|  2.36k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  450|  2.36k|}
card-entersafe.c:entersafe_transmit_apdu:
  370|  3.06k|{
  371|  3.06k|	u8 *cipher_data = NULL, *mac_data = NULL;
  372|  3.06k|	size_t cipher_data_size, mac_data_size, blocks;
  373|  3.06k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  3.06k|#define SC_SUCCESS				0
  ------------------
  374|  3.06k|	u8 *sbuf = NULL;
  375|  3.06k|	size_t ssize = 0;
  376|       |
  377|  3.06k|	if (card == NULL || apdu == NULL)
  ------------------
  |  Branch (377:6): [True: 0, False: 3.06k]
  |  Branch (377:22): [True: 0, False: 3.06k]
  ------------------
  378|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  379|       |
  380|  3.06k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.06k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.06k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.06k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.06k]
  |  |  ------------------
  ------------------
  381|       |
  382|  3.06k|	if ((cipher || mac) && (!key || (keylen != 8 && keylen != 16)))
  ------------------
  |  Branch (382:7): [True: 2, False: 3.06k]
  |  Branch (382:17): [True: 13, False: 3.05k]
  |  Branch (382:26): [True: 0, False: 15]
  |  Branch (382:35): [True: 8, False: 7]
  |  Branch (382:50): [True: 0, False: 8]
  ------------------
  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|  3.06k|	r = sc_apdu_get_octets(card->ctx, apdu, &sbuf, &ssize, SC_PROTO_RAW);
  ------------------
  |  |  361|  3.06k|#define SC_PROTO_RAW		0x00001000
  ------------------
  386|  3.06k|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|  3.06k|#define SC_SUCCESS				0
  ------------------
  |  Branch (386:6): [True: 3.06k, False: 0]
  ------------------
  387|  3.06k|		sc_apdu_log(card->ctx, sbuf, ssize, 1);
  ------------------
  |  |  292|  3.06k|	sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, is_outgoing != 0 ? "Outgoing APDU" : "Incoming APDU", data, len)
  |  |  ------------------
  |  |  |  |  127|  6.13k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (127:65): [True: 3.06k, Folded]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  388|  3.06k|	if (sbuf)
  ------------------
  |  Branch (388:6): [True: 3.06k, False: 0]
  ------------------
  389|  3.06k|		free(sbuf);
  390|       |
  391|  3.06k|	if (cipher) {
  ------------------
  |  Branch (391:6): [True: 2, False: 3.06k]
  ------------------
  392|      2|		blocks = (apdu->lc + 2) / 8 + 1;
  393|      2|		cipher_data_size = blocks * 8;
  394|      2|		cipher_data = malloc(cipher_data_size);
  395|      2|		if (!cipher_data) {
  ------------------
  |  Branch (395:7): [True: 0, False: 2]
  ------------------
  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|      2|		if ((r = entersafe_cipher_apdu(card, apdu, key, keylen, cipher_data, cipher_data_size)) < 0)
  ------------------
  |  Branch (400:7): [True: 0, False: 2]
  ------------------
  401|      0|			goto out;
  402|      2|	}
  403|  3.06k|	if (mac) {
  ------------------
  |  Branch (403:6): [True: 15, False: 3.05k]
  ------------------
  404|     15|		mac_data_size = apdu->lc + 4;
  405|     15|		mac_data = malloc(mac_data_size);
  406|     15|		if (!mac_data) {
  ------------------
  |  Branch (406:7): [True: 0, False: 15]
  ------------------
  407|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  408|      0|			goto out;
  409|      0|		}
  410|     15|		r = entersafe_mac_apdu(card, apdu, key, keylen, mac_data, mac_data_size);
  411|     15|		if (r < 0)
  ------------------
  |  Branch (411:7): [True: 0, False: 15]
  ------------------
  412|      0|			goto out;
  413|     15|	}
  414|       |
  415|  3.06k|	r = sc_transmit_apdu(card, apdu);
  416|       |
  417|  3.06k|out:
  418|  3.06k|	free(cipher_data);
  419|  3.06k|	free(mac_data);
  420|       |
  421|  3.06k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  3.06k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  3.06k|	int _ret = r; \
  |  |  155|  3.06k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 3.06k, False: 0]
  |  |  ------------------
  |  |  156|  3.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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 3, False: 3.06k]
  |  |  ------------------
  |  |  157|  3.06k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  3.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|  3.06k|	return _ret; \
  |  |  163|  3.06k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  422|  3.06k|}
card-entersafe.c:entersafe_cipher_apdu:
  197|      2|{
  198|      2|	EVP_CIPHER_CTX *ctx = NULL;
  199|      2|	EVP_CIPHER *alg = NULL;
  200|       |
  201|      2|	u8 iv[8] = {0};
  202|      2|	int len;
  203|       |
  204|      2|	if (card == NULL || apdu == NULL || key == NULL || buff == NULL)
  ------------------
  |  Branch (204:6): [True: 0, False: 2]
  |  Branch (204:22): [True: 0, False: 2]
  |  Branch (204:38): [True: 0, False: 2]
  |  Branch (204:53): [True: 0, False: 2]
  ------------------
  205|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  206|       |
  207|      2|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  208|       |
  209|       |	/* padding as 0x80 0x00 0x00...... */
  210|      2|	memset(buff, 0, buffsize);
  211|      2|	buff[0] = apdu->lc;
  212|      2|	memcpy(buff + 1, apdu->data, apdu->lc);
  213|      2|	buff[apdu->lc + 1] = 0x80;
  214|       |
  215|      2|	ctx = EVP_CIPHER_CTX_new();
  216|      2|	if (ctx == NULL) {
  ------------------
  |  Branch (216:6): [True: 0, False: 2]
  ------------------
  217|      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__
  |  |  ------------------
  ------------------
  218|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|      0|	}
  220|      2|	EVP_CIPHER_CTX_set_padding(ctx, 0);
  221|       |
  222|      2|	if (keylen == 8) {
  ------------------
  |  Branch (222:6): [True: 0, False: 2]
  ------------------
  223|      0|		alg = sc_evp_cipher(card->ctx, "DES-ECB");
  224|      2|	} else if (keylen == 16) {
  ------------------
  |  Branch (224:13): [True: 2, False: 0]
  ------------------
  225|      2|		alg = sc_evp_cipher(card->ctx, "DES-EDE");
  226|      2|	} else {
  227|      0|		EVP_CIPHER_CTX_free(ctx);
  228|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  229|      0|	}
  230|       |
  231|      2|	if (EVP_EncryptInit_ex(ctx, alg, NULL, key, iv) != 1) {
  ------------------
  |  Branch (231:6): [True: 0, False: 2]
  ------------------
  232|      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__
  |  |  ------------------
  ------------------
  233|      0|		sc_evp_cipher_free(alg);
  234|      0|		EVP_CIPHER_CTX_free(ctx);
  235|      0|		sc_log(card->ctx, "entersafe encryption error.");
  ------------------
  |  |   71|      0|#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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|      0|	}
  238|       |
  239|      2|	len = (int)apdu->lc;
  240|      2|	if (!EVP_EncryptUpdate(ctx, buff, &len, buff, (int)buffsize)) {
  ------------------
  |  Branch (240:6): [True: 0, False: 2]
  ------------------
  241|      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__
  |  |  ------------------
  ------------------
  242|      0|		sc_evp_cipher_free(alg);
  243|      0|		EVP_CIPHER_CTX_free(ctx);
  244|      0|		sc_log(card->ctx, "entersafe encryption error.");
  ------------------
  |  |   71|      0|#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|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|      0|	}
  247|      2|	apdu->lc = len;
  248|       |
  249|      2|	sc_evp_cipher_free(alg);
  250|      2|	EVP_CIPHER_CTX_free(ctx);
  251|       |
  252|      2|	if (apdu->lc != buffsize) {
  ------------------
  |  Branch (252:6): [True: 0, False: 2]
  ------------------
  253|      0|		sc_log(card->ctx, "entersafe build cipher apdu 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__
  |  |  ------------------
  ------------------
  254|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INTERNAL);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  255|      0|	}
  256|       |
  257|      2|	apdu->data = buff;
  258|      2|	apdu->datalen = apdu->lc;
  259|       |
  260|      2|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  261|      2|}
card-entersafe.c:entersafe_mac_apdu:
  266|     15|{
  267|     15|	int r;
  268|     15|	u8 iv[8];
  269|     15|	u8 *tmp = NULL, *tmp_rounded = NULL;
  270|     15|	size_t tmpsize = 0, tmpsize_rounded = 0;
  271|     15|	int outl = 0;
  272|     15|	EVP_CIPHER_CTX *ctx = NULL;
  273|     15|	EVP_CIPHER *alg = NULL;
  274|       |
  275|     15|	if (card == NULL || apdu == NULL || key == NULL || buff == NULL)
  ------------------
  |  Branch (275:6): [True: 0, False: 15]
  |  Branch (275:22): [True: 0, False: 15]
  |  Branch (275:38): [True: 0, False: 15]
  |  Branch (275:53): [True: 0, False: 15]
  ------------------
  276|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  277|       |
  278|     15|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     15|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     15|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     15|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15]
  |  |  ------------------
  ------------------
  279|       |
  280|     15|	if (apdu->cse != SC_APDU_CASE_3_SHORT)
  ------------------
  |  |  293|     15|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (280:6): [True: 0, False: 15]
  ------------------
  281|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  282|     15|	if (keylen != 8 && keylen != 16)
  ------------------
  |  Branch (282:6): [True: 8, False: 7]
  |  Branch (282:21): [True: 0, False: 8]
  ------------------
  283|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  284|       |
  285|     15|	r = entersafe_gen_random(card, iv, sizeof(iv));
  286|     15|	LOG_TEST_RET(card->ctx, r, "entersafe gen random failed");
  ------------------
  |  |  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: 0, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  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|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  287|       |
  288|       |	/* encode the APDU in the buffer */
  289|     15|	if ((r = sc_apdu_get_octets(card->ctx, apdu, &tmp, &tmpsize, SC_PROTO_RAW)) != SC_SUCCESS)
  ------------------
  |  |  361|     15|#define SC_PROTO_RAW		0x00001000
  ------------------
              	if ((r = sc_apdu_get_octets(card->ctx, apdu, &tmp, &tmpsize, SC_PROTO_RAW)) != SC_SUCCESS)
  ------------------
  |  |   28|     15|#define SC_SUCCESS				0
  ------------------
  |  Branch (289:6): [True: 0, False: 15]
  ------------------
  290|      0|		goto out;
  291|       |
  292|       |	/* round to 8 */
  293|     15|	tmpsize_rounded = (tmpsize / 8 + 1) * 8;
  294|       |
  295|     15|	tmp_rounded = malloc(tmpsize_rounded);
  296|     15|	if (tmp_rounded == NULL) {
  ------------------
  |  Branch (296:6): [True: 0, False: 15]
  ------------------
  297|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  298|      0|		goto out;
  299|      0|	}
  300|       |
  301|       |	/* build content and padded buffer by 0x80 0x00 0x00..... */
  302|     15|	memset(tmp_rounded, 0, tmpsize_rounded);
  303|     15|	memcpy(tmp_rounded, tmp, tmpsize);
  304|     15|	tmp_rounded[4] += 4;
  305|     15|	tmp_rounded[tmpsize] = 0x80;
  306|       |
  307|       |	/* block_size-1 blocks*/
  308|     15|	ctx = EVP_CIPHER_CTX_new();
  309|     15|	if (ctx == NULL) {
  ------------------
  |  Branch (309:6): [True: 0, False: 15]
  ------------------
  310|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  311|      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__
  |  |  ------------------
  ------------------
  312|      0|		goto out;
  313|      0|	}
  314|     15|	EVP_CIPHER_CTX_set_padding(ctx, 0);
  315|     15|	alg = sc_evp_cipher(card->ctx, "DES-CBC");
  316|     15|	if (!alg ||
  ------------------
  |  Branch (316:6): [True: 0, False: 15]
  ------------------
  317|     15|			EVP_EncryptInit_ex(ctx, alg, NULL, key, iv) != 1) {
  ------------------
  |  Branch (317:4): [True: 0, False: 15]
  ------------------
  318|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  319|      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__
  |  |  ------------------
  ------------------
  320|      0|		goto out;
  321|      0|	}
  322|       |
  323|     15|	if (tmpsize_rounded > 8) {
  ------------------
  |  Branch (323:6): [True: 15, False: 0]
  ------------------
  324|     15|		if (!EVP_EncryptUpdate(ctx, tmp_rounded, &outl, tmp_rounded, (int)tmpsize_rounded - 8)) {
  ------------------
  |  Branch (324:7): [True: 0, False: 15]
  ------------------
  325|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  326|      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__
  |  |  ------------------
  ------------------
  327|      0|			goto out;
  328|      0|		}
  329|     15|	}
  330|       |	/* last block */
  331|     15|	if (keylen == 8) {
  ------------------
  |  Branch (331:6): [True: 7, False: 8]
  ------------------
  332|      7|		if (!EVP_EncryptUpdate(ctx, tmp_rounded + outl, &outl, tmp_rounded + outl, 8)) {
  ------------------
  |  Branch (332:7): [True: 0, False: 7]
  ------------------
  333|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  334|      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__
  |  |  ------------------
  ------------------
  335|      0|			goto out;
  336|      0|		}
  337|      8|	} else {
  338|      8|		if (EVP_EncryptInit_ex(ctx, EVP_des_ede_cbc(), NULL, key, tmp_rounded + outl - 8) != 1 ||
  ------------------
  |  Branch (338:7): [True: 0, False: 8]
  ------------------
  339|      8|				!EVP_EncryptUpdate(ctx, tmp_rounded + outl, &outl, tmp_rounded + outl, 8)) {
  ------------------
  |  Branch (339:5): [True: 0, False: 8]
  ------------------
  340|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  341|      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__
  |  |  ------------------
  ------------------
  342|      0|			goto out;
  343|      0|		}
  344|      8|	}
  345|       |
  346|     15|	if (apdu->lc + 4 > buffsize) {
  ------------------
  |  Branch (346:6): [True: 0, False: 15]
  ------------------
  347|      0|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  348|      0|		goto out;
  349|      0|	}
  350|       |
  351|     15|	memcpy(buff, apdu->data, apdu->lc);
  352|       |	/* use first 4 bytes of last block as mac value */
  353|     15|	memcpy(buff + apdu->lc, tmp_rounded + tmpsize_rounded - 8, 4);
  354|     15|	apdu->data = buff;
  355|     15|	apdu->lc += 4;
  356|     15|	apdu->datalen = apdu->lc;
  357|       |
  358|     15|out:
  359|     15|	free(tmp);
  360|     15|	free(tmp_rounded);
  361|     15|	sc_evp_cipher_free(alg);
  362|     15|	EVP_CIPHER_CTX_free(ctx);
  363|       |
  364|     15|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  365|     15|}
card-entersafe.c:entersafe_gen_random:
  172|     15|{
  173|     15|	int r = SC_SUCCESS;
  ------------------
  |  |   28|     15|#define SC_SUCCESS				0
  ------------------
  174|     15|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE] = {0};
  175|     15|	sc_apdu_t apdu;
  176|       |
  177|     15|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     15|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     15|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     15|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15]
  |  |  ------------------
  ------------------
  178|       |
  179|     15|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x84, 0x00, 0x00);
  ------------------
  |  |  292|     15|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  180|     15|	apdu.resp = rbuf;
  181|     15|	apdu.le = size;
  182|     15|	apdu.resplen = sizeof(rbuf);
  183|       |
  184|     15|	r = sc_transmit_apdu(card, &apdu);
  185|     15|	LOG_TEST_RET(card->ctx, r, "entersafe gen random failed");
  ------------------
  |  |  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: 0, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  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|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  186|       |
  187|     15|	if (apdu.resplen != size)
  ------------------
  |  Branch (187:6): [True: 0, False: 15]
  ------------------
  188|     15|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|     15|	memcpy(buff, rbuf, size);
  190|       |
  191|     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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|     15|}
card-entersafe.c:entersafe_update_binary:
  455|    654|{
  456|    654|	sc_apdu_t apdu;
  457|    654|	int r;
  458|       |
  459|    654|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    654|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    654|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    654|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 654]
  |  |  ------------------
  ------------------
  460|       |
  461|    654|	if (count > card->max_send_size)
  ------------------
  |  Branch (461:6): [True: 0, False: 654]
  ------------------
  462|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  463|       |
  464|    654|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xD6, (idx >> 8) & 0xFF, idx & 0xFF);
  ------------------
  |  |  293|    654|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  465|    654|	apdu.cla = idx > 0x7fff ? 0x80 : 0x00;
  ------------------
  |  Branch (465:13): [True: 2, False: 652]
  ------------------
  466|    654|	apdu.lc = count;
  467|    654|	apdu.datalen = count;
  468|    654|	apdu.data = buf;
  469|       |
  470|    654|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
  471|    654|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    654|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    654|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    654|	int _ret = (r); \
  |  |  |  |  168|    654|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 654]
  |  |  |  |  ------------------
  |  |  |  |  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|    654|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 654]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  472|    654|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2),
  ------------------
  |  |  174|    654|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    654|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    654|	int _ret = (r); \
  |  |  |  |  168|    654|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 648]
  |  |  |  |  ------------------
  |  |  |  |  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|    654|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 648]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|    648|		    "Card returned error");
  474|    648|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, (int)count);
  ------------------
  |  |  153|    648|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    648|	int _ret = r; \
  |  |  155|    648|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 648]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    648|	} else { \
  |  |  159|    648|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|    648|			"returning with: %d\n", _ret); \
  |  |  161|    648|	} \
  |  |  162|    648|	return _ret; \
  |  |  163|    648|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  475|    648|}
card-entersafe.c:entersafe_select_file:
  590|    102|{
  591|    102|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (591:6): [True: 0, False: 102]
  |  Branch (591:22): [True: 0, False: 102]
  ------------------
  592|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  593|    102|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  594|       |
  595|    102|	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: 102]
  ------------------
  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|     19|		case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|     19|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (600:3): [True: 19, False: 83]
  ------------------
  601|     19|			return entersafe_select_aid(card, in_path, file_out);
  602|     83|		case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|     83|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (602:3): [True: 83, False: 19]
  ------------------
  603|     83|			return entersafe_select_path(card, in_path->value, in_path->len, file_out);
  604|      0|		default:
  ------------------
  |  Branch (604:3): [True: 0, False: 102]
  ------------------
  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|    102|	}
  607|    102|}
card-entersafe.c:entersafe_select_fid:
  503|    133|{
  504|    133|	int r;
  505|    133|	sc_file_t *file = NULL;
  506|    133|	sc_path_t path;
  507|       |
  508|    133|	memset(&path, 0, sizeof(sc_path_t));
  509|       |
  510|    133|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    133|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  511|    133|	path.value[0] = id_hi;
  512|    133|	path.value[1] = id_lo;
  513|    133|	path.len = 2;
  514|       |
  515|    133|	r = iso_ops->select_file(card, &path, &file);
  516|    133|	if (r < 0)
  ------------------
  |  Branch (516:6): [True: 55, False: 78]
  ------------------
  517|     55|		sc_file_free(file);
  518|    133|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    133|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    133|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    133|	int _ret = (r); \
  |  |  |  |  168|    133|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 55, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  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|    133|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|       |
  520|     78|	if (file_out)
  ------------------
  |  Branch (520:6): [True: 26, False: 52]
  ------------------
  521|     26|		*file_out = file;
  522|     52|	else
  523|     52|		sc_file_free(file);
  524|       |
  525|     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]
  |  |  ------------------
  ------------------
  526|     78|}
card-entersafe.c:entersafe_select_aid:
  531|     19|{
  532|     19|	int r;
  533|       |
  534|     19|	r = iso_ops->select_file(card, in_path, file_out);
  535|     19|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 14, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  536|       |
  537|      5|	if (file_out) {
  ------------------
  |  Branch (537:6): [True: 0, False: 5]
  ------------------
  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|      5|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  552|      5|}
card-entersafe.c:entersafe_select_path:
  557|     83|{
  558|     83|	u8 n_pathbuf[SC_MAX_PATH_SIZE];
  559|     83|	const u8 *path = pathbuf;
  560|     83|	size_t pathlen = len;
  561|     83|	unsigned int i;
  562|     83|	int r;
  563|       |
  564|     83|	if (pathlen % 2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (564:6): [True: 0, False: 83]
  |  Branch (564:26): [True: 0, False: 83]
  |  Branch (564:41): [True: 0, False: 83]
  ------------------
  565|      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]
  |  |  ------------------
  ------------------
  566|       |
  567|       |	/* if pathlen == 6 then the first FID must be MF (== 3F00) */
  568|     83|	if (pathlen == 6 && (path[0] != 0x3f || path[1] != 0x00))
  ------------------
  |  Branch (568:6): [True: 35, False: 48]
  |  Branch (568:23): [True: 0, False: 35]
  |  Branch (568:42): [True: 0, False: 35]
  ------------------
  569|      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]
  |  |  ------------------
  ------------------
  570|       |
  571|       |	/* unify path (the first FID should be MF) */
  572|     83|	if (path[0] != 0x3f || path[1] != 0x00) {
  ------------------
  |  Branch (572:6): [True: 8, False: 75]
  |  Branch (572:25): [True: 0, False: 75]
  ------------------
  573|      8|		n_pathbuf[0] = 0x3f;
  574|      8|		n_pathbuf[1] = 0x00;
  575|      8|		memcpy(n_pathbuf + 2, path, pathlen);
  576|      8|		path = n_pathbuf;
  577|      8|		pathlen += 2;
  578|      8|	}
  579|       |
  580|    133|	for (i = 0; i < pathlen - 2; i += 2) {
  ------------------
  |  Branch (580:14): [True: 98, False: 35]
  ------------------
  581|     98|		r = entersafe_select_fid(card, path[i], path[i + 1], NULL);
  582|     98|		LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|     98|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     98|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     98|	int _ret = (r); \
  |  |  |  |  168|     98|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 48, False: 50]
  |  |  |  |  ------------------
  |  |  |  |  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|     98|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|     98|	}
  584|     35|	return entersafe_select_fid(card, path[pathlen - 2], path[pathlen - 1], file_out);
  585|     83|}
card-entersafe.c:entersafe_create_ef:
  666|      6|{
  667|      6|	int r;
  668|      6|	sc_apdu_t apdu;
  669|       |
  670|      6|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  671|       |
  672|      6|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x02, 0x00);
  ------------------
  |  |  293|      6|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  673|      6|	apdu.cla = 0x84;
  674|      6|	apdu.data = (u8*)&data->data.ef;
  675|      6|	apdu.lc = apdu.datalen = sizeof(data->data.ef);
  676|       |
  677|      6|	r = entersafe_transmit_apdu(card, &apdu, init_key, sizeof(init_key), 0, 1);
  678|      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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  679|      6|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
  680|      6|}
card-entersafe.c:entersafe_card_ctl_2048:
 1522|     60|{
 1523|     60|	sc_entersafe_create_data *tmp = (sc_entersafe_create_data *)ptr;
 1524|       |
 1525|     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]
  |  |  ------------------
  ------------------
 1526|       |
 1527|     60|	switch (cmd) {
 1528|     13|		case SC_CARDCTL_ENTERSAFE_CREATE_FILE:
  ------------------
  |  Branch (1528:3): [True: 13, False: 47]
  ------------------
 1529|     13|			if (tmp->type == SC_ENTERSAFE_MF_DATA)
  ------------------
  |  |  664|     13|#define	SC_ENTERSAFE_MF_DATA	0x01
  ------------------
  |  Branch (1529:8): [True: 7, False: 6]
  ------------------
 1530|      7|				return entersafe_create_mf(card, tmp);
 1531|      6|			else if (tmp->type == SC_ENTERSAFE_DF_DATA)
  ------------------
  |  |  665|      6|#define SC_ENTERSAFE_DF_DATA	0x02
  ------------------
  |  Branch (1531:13): [True: 0, False: 6]
  ------------------
 1532|      0|				return entersafe_create_df(card, tmp);
 1533|      6|			else if (tmp->type == SC_ENTERSAFE_EF_DATA)
  ------------------
  |  |  666|      6|#define SC_ENTERSAFE_EF_DATA	0x04
  ------------------
  |  Branch (1533:13): [True: 6, False: 0]
  ------------------
 1534|      6|				return entersafe_create_ef(card, tmp);
 1535|      0|			else
 1536|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1537|      2|		case SC_CARDCTL_ENTERSAFE_WRITE_KEY:
  ------------------
  |  Branch (1537:3): [True: 2, False: 58]
  ------------------
 1538|      2|			return entersafe_write_key(card, (sc_entersafe_wkey_data *)ptr);
 1539|      0|		case SC_CARDCTL_ENTERSAFE_GENERATE_KEY:
  ------------------
  |  Branch (1539:3): [True: 0, False: 60]
  ------------------
 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: 60]
  ------------------
 1542|      0|			return entersafe_erase_card(card);
 1543|     12|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1543:3): [True: 12, False: 48]
  ------------------
 1544|     12|			return entersafe_get_serialnr(card, (sc_serial_number_t *)ptr);
 1545|      0|		case SC_CARDCTL_ENTERSAFE_PREINSTALL_KEYS:
  ------------------
  |  Branch (1545:3): [True: 0, False: 60]
  ------------------
 1546|      0|			return entersafe_preinstall_keys(card, entersafe_preinstall_rsa_2048);
 1547|     33|		default:
  ------------------
  |  Branch (1547:3): [True: 33, False: 27]
  ------------------
 1548|     33|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     33|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1549|     60|	}
 1550|     60|}
card-entersafe.c:entersafe_create_mf:
  610|      7|{
  611|      7|	int r;
  612|      7|	sc_apdu_t apdu;
  613|       |
  614|      7|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  615|       |
  616|      7|	memcpy(data->data.df.init_key, init_key, sizeof(init_key));
  617|       |
  618|      7|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|      7|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  619|      7|	apdu.cla = 0x84;
  620|      7|	apdu.data = (u8 *)&data->data.df;
  621|      7|	apdu.datalen = apdu.lc = sizeof(data->data.df);
  622|       |
  623|      7|	switch(card->type) {
  624|      0|		case SC_CARD_TYPE_ENTERSAFE_3K:
  ------------------
  |  Branch (624:3): [True: 0, False: 7]
  ------------------
  625|      0|			r = entersafe_transmit_apdu(card, &apdu, trans_code_3k, sizeof(trans_code_3k), 0, 1);
  626|      0|			break;
  627|      7|		case SC_CARD_TYPE_ENTERSAFE_FTCOS_PK_01C:
  ------------------
  |  Branch (627:3): [True: 7, False: 0]
  ------------------
  628|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_PK_01C:
  ------------------
  |  Branch (628:3): [True: 0, False: 7]
  ------------------
  629|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_PK_01C_T0:
  ------------------
  |  Branch (629:3): [True: 0, False: 7]
  ------------------
  630|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_H10CR_PK_01C_T1:
  ------------------
  |  Branch (630:3): [True: 0, False: 7]
  ------------------
  631|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_D11CR_PK_01C_T1:
  ------------------
  |  Branch (631:3): [True: 0, False: 7]
  ------------------
  632|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_C21C_PK_01C_T1:
  ------------------
  |  Branch (632:3): [True: 0, False: 7]
  ------------------
  633|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_A22CR_PK_01C_T1:
  ------------------
  |  Branch (633:3): [True: 0, False: 7]
  ------------------
  634|      7|		case SC_CARD_TYPE_ENTERSAFE_EJAVA_A40CR_PK_01C_T1:
  ------------------
  |  Branch (634:3): [True: 0, False: 7]
  ------------------
  635|      7|			r = entersafe_transmit_apdu(card, &apdu, trans_code_ftcos_pk_01c, sizeof(trans_code_ftcos_pk_01c), 0, 1);
  636|      7|			break;
  637|      0|		default:
  ------------------
  |  Branch (637:3): [True: 0, False: 7]
  ------------------
  638|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  639|      0|			break;
  640|      7|	}
  641|       |
  642|      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: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|      7|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
  644|      7|}
card-entersafe.c:entersafe_write_key:
 1227|      2|{
 1228|      2|	struct sc_pkcs15_prkey_rsa *rsa = data->key_data.rsa;
 1229|       |
 1230|      2|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1231|       |
 1232|      2|	switch(data->usage) {
 1233|      0|		case 0x22:
  ------------------
  |  Branch (1233:3): [True: 0, False: 2]
  ------------------
 1234|      0|			if(rsa->modulus.len < 256)
  ------------------
  |  Branch (1234:7): [True: 0, False: 0]
  ------------------
 1235|      0|				return entersafe_write_small_rsa_key(card,data->key_id, rsa);
 1236|      0|			else
 1237|      0|				return entersafe_write_large_rsa_key(card,data->key_id, rsa);
 1238|      0|			break;
 1239|      0|		case 0x2A:
  ------------------
  |  Branch (1239:3): [True: 0, False: 2]
  ------------------
 1240|      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]
  |  |  ------------------
  ------------------
 1241|      0|			break;
 1242|      2|		default:
  ------------------
  |  Branch (1242:3): [True: 2, False: 0]
  ------------------
 1243|      2|			return entersafe_write_symmetric_key(card,data->key_id,data->usage,
 1244|      2|												data->key_data.symmetric.EC,
 1245|      2|												data->key_data.symmetric.ver,
 1246|      2|												data->key_data.symmetric.key_val,
 1247|      2|												data->key_data.symmetric.key_len);
 1248|      0|			break;
 1249|      2|	}
 1250|      0|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
 1251|      0|}
card-entersafe.c:entersafe_write_symmetric_key:
 1201|      2|{
 1202|      2|	sc_apdu_t apdu;
 1203|      2|	u8 sbuff[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1204|      2|	int r;
 1205|       |
 1206|      2|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1207|       |
 1208|      2|	if (len > 240)
  ------------------
  |  Branch (1208:6): [True: 0, False: 2]
  ------------------
 1209|      0|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
 1210|       |
 1211|      2|	sbuff[0] = EC;
 1212|      2|	sbuff[1] = ver;
 1213|      2|	memcpy(&sbuff[2], data, len);
 1214|       |
 1215|      2|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xF4, usage, key_id);
  ------------------
  |  |  293|      2|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1216|      2|	apdu.cla = 0x84;
 1217|      2|	apdu.data = sbuff;
 1218|      2|	apdu.lc = apdu.datalen = len + 2;
 1219|       |
 1220|      2|	r = entersafe_transmit_apdu(card, &apdu, key_maintain, sizeof(key_maintain), 1, 1);
 1221|      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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1222|      2|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "Write prkey 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1223|      2|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
 1224|      2|}
card-entersafe.c:entersafe_get_serialnr:
 1347|     12|{
 1348|     12|	int	r;
 1349|     12|	sc_apdu_t apdu;
 1350|     12|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1351|       |
 1352|     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]
  |  |  ------------------
  ------------------
 1353|     12|	if (serial == NULL)
  ------------------
  |  Branch (1353:6): [True: 0, False: 12]
  ------------------
 1354|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1355|       |
 1356|     12|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xEA, 0x00, 0x00);
  ------------------
  |  |  292|     12|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1357|     12|	apdu.cla = 0x80;
 1358|     12|	apdu.resp = rbuf;
 1359|     12|	apdu.resplen = sizeof(rbuf);
 1360|     12|	apdu.le = 0x08;
 1361|       |
 1362|     12|	r = entersafe_transmit_apdu(card, &apdu, 0, 0, 0, 0);
 1363|     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: 0, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1364|     12|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "EnterSafe get SN 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: 8, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1365|      4|	if (apdu.resplen != 8)
  ------------------
  |  Branch (1365:6): [True: 4, False: 0]
  ------------------
 1366|      4|		LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Invalid length of SN");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1367|       |
 1368|      0|	card->serialnr.len = serial->len = 8;
 1369|      0|	memcpy(card->serialnr.value, rbuf, 8);
 1370|      0|	memcpy(serial->value, rbuf, 8);
 1371|       |
 1372|      0|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
 1373|      0|}
card-entersafe.c:entersafe_process_fci:
  479|     65|{
  480|     65|	int r;
  481|       |
  482|     65|	if (file == NULL)
  ------------------
  |  Branch (482:6): [True: 0, False: 65]
  ------------------
  483|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  484|     65|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     65|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     65|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     65|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 65]
  |  |  ------------------
  ------------------
  485|       |
  486|     65|	r = iso_ops->process_fci(card, file, buf, buflen);
  487|     65|	LOG_TEST_RET(card->ctx, r, "Process fci failed");
  ------------------
  |  |  174|     65|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     65|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     65|	int _ret = (r); \
  |  |  |  |  168|     65|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 65]
  |  |  |  |  ------------------
  |  |  |  |  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|     65|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|     65|	if (file->namelen) {
  ------------------
  |  Branch (489:6): [True: 0, False: 65]
  ------------------
  490|      0|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  491|      0|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      0|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  492|     65|	} else {
  493|     65|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     65|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  494|     65|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     65|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  495|     65|	}
  496|       |
  497|     65|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 65]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  498|     65|}

sc_get_eoi_driver:
  566|  3.69k|{
  567|  3.69k|	eoi_ops = *sc_get_iso7816_driver()->ops;
  568|       |
  569|  3.69k|	eoi_ops.match_card = eoi_match_card;
  570|  3.69k|	eoi_ops.init = eoi_init;
  571|  3.69k|	eoi_ops.finish = eoi_finish;
  572|  3.69k|	eoi_ops.select_file = eoi_select_file;
  573|  3.69k|	eoi_ops.logout = eoi_logout;
  574|  3.69k|	eoi_ops.pin_cmd = eoi_pin_cmd;
  575|  3.69k|	eoi_ops.card_ctl = eoi_card_ctl;
  576|  3.69k|	eoi_ops.set_security_env = eoi_set_security_env;
  577|  3.69k|	eoi_ops.compute_signature = eoi_compute_signature;
  578|       |
  579|  3.69k|	return &eoi_drv;
  580|  3.69k|}
card-eoi.c:eoi_match_card:
  236|    142|static int eoi_match_card(sc_card_t* card) {
  237|    142|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    142|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    142|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    142|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    142|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  238|    142|	if (_sc_match_atr(card, eoi_atrs, &card->type) >= 0) {
  ------------------
  |  Branch (238:6): [True: 0, False: 142]
  ------------------
  239|      0|		sc_log(card->ctx, "ATR recognized as Slovenian 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__
  |  |  ------------------
  ------------------
  240|      0|		LOG_FUNC_RETURN(card->ctx, ATR_MATCH);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  241|      0|	}
  242|    142|	LOG_FUNC_RETURN(card->ctx, !ATR_MATCH);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 142]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  243|    142|}

epass2003_refresh:
  926|    218|{
  927|    218|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    218|#define SC_SUCCESS				0
  ------------------
  928|    218|	epass2003_exdata *exdata = NULL;
  929|       |
  930|    218|	if (!card->drv_data)
  ------------------
  |  Branch (930:6): [True: 0, False: 218]
  ------------------
  931|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  932|       |
  933|    218|	exdata = (epass2003_exdata *)card->drv_data;
  934|       |
  935|    218|	if (exdata->sm) {
  ------------------
  |  Branch (935:6): [True: 185, False: 33]
  ------------------
  936|    185|		card->sm_ctx.sm_mode = 0;
  937|    185|		r = mutual_auth(card, g_init_key_enc, g_init_key_mac);
  938|    185|		card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|    185|#define SM_MODE_TRANSMIT	0x200
  ------------------
  939|    185|		LOG_TEST_RET(card->ctx, r, "mutual_auth failed");
  ------------------
  |  |  174|    185|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    185|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    185|	int _ret = (r); \
  |  |  |  |  168|    185|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 185, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    185|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    185|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    185|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    185|		return _ret; \
  |  |  |  |  172|    185|	} \
  |  |  |  |  173|    185|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  940|    185|	}
  941|       |
  942|     33|	return r;
  943|    218|}
sec_attr_to_entry:
 2226|  1.37k|{
 2227|  1.37k|	int i;
 2228|  1.37k|	int found = 0;
 2229|       |
 2230|  1.37k|	unsigned int method;
 2231|  1.37k|	unsigned long  keyref;
 2232|       |
 2233|  1.37k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.37k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.37k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.37k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.37k]
  |  |  ------------------
  ------------------
 2234|       |
 2235|  1.37k|	switch (file->sec_attr[index]) {
 2236|  1.00k|	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE):
  ------------------
  |  |  737|  1.00k|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE):
  ------------------
  |  |  732|  1.00k|#define EPASS2003_AC_EVERYONE		0x00
  ------------------
  |  Branch (2236:2): [True: 1.00k, False: 367]
  ------------------
 2237|  1.00k|		method = SC_AC_NONE;
  ------------------
  |  |  150|  1.00k|#define SC_AC_NONE			0x00000000
  ------------------
 2238|  1.00k|		keyref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  1.00k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2239|  1.00k|		break;
 2240|     16|	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER):
  ------------------
  |  |  737|     16|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              	case (EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER):
  ------------------
  |  |  733|     16|#define EPASS2003_AC_USER		0x06
  ------------------
  |  Branch (2240:2): [True: 16, False: 1.35k]
  ------------------
 2241|     16|		method = SC_AC_CHV;
  ------------------
  |  |  151|     16|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 2242|     16|		keyref = 1;
 2243|     16|		break;
 2244|    351|	default:
  ------------------
  |  Branch (2244:2): [True: 351, False: 1.02k]
  ------------------
 2245|    351|		sc_log(card->ctx, "Unknown value 0x%2.2x in file->sec_attr[%d]", file->sec_attr[index], index);
  ------------------
  |  |   71|    351|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2246|    351|		method = SC_AC_NEVER;
  ------------------
  |  |  163|    351|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 2247|    351|		keyref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|    351|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 2248|    351|		break;
 2249|  1.37k|	}
 2250|       |
 2251|  46.6k|	for (i = 0; i < (int)(sizeof(sec_attr_to_acl_entry) / sizeof(sec_attr_to_acl_entries_t)); i++) {
  ------------------
  |  Branch (2251:14): [True: 45.2k, False: 1.37k]
  ------------------
 2252|  45.2k|		const sec_attr_to_acl_entries_t *e = &sec_attr_to_acl_entry[i];
 2253|       |
 2254|  45.2k|		if (index == e->index && file->type == e->file_type
  ------------------
  |  Branch (2254:7): [True: 8.79k, False: 36.4k]
  |  Branch (2254:28): [True: 4.08k, False: 4.71k]
  ------------------
 2255|  4.08k|				&& file->ef_structure == e->file_ef_structure) {
  ------------------
  |  Branch (2255:8): [True: 60, False: 4.02k]
  ------------------
 2256|       |				/* may add multiple entries */
 2257|     60|			sc_file_add_acl_entry(file, e->op, method, keyref);
 2258|     60|			found++;
 2259|     60|		}
 2260|  45.2k|	}
 2261|  1.37k|	if (found != 1) {
  ------------------
  |  Branch (2261:6): [True: 1.37k, False: 0]
  ------------------
 2262|  1.37k|		sc_log(card->ctx,"found %d entries ", found);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2263|  1.37k|	}
 2264|       |
 2265|  1.37k|	return 0;
 2266|  1.37k|}
sc_get_epass2003_driver:
 3293|  3.69k|{
 3294|  3.69k|	return sc_get_driver();
 3295|  3.69k|}
card-epass2003.c:mutual_auth:
  896|    185|{
  897|    185|	struct sc_context *ctx = card->ctx;
  898|    185|	int r;
  899|    185|	unsigned char result[256] = {0};
  900|    185|	unsigned char ran_key[8] = {0};
  901|    185|	epass2003_exdata *exdata = NULL;
  902|       |
  903|    185|	if (!card->drv_data)
  ------------------
  |  Branch (903:6): [True: 0, False: 185]
  ------------------
  904|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  905|    185|	exdata = (epass2003_exdata *)card->drv_data;
  906|       |
  907|    185|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    185|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    185|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    185|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    185|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 185]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  908|       |
  909|    185|	r = gen_init_key(card, key_enc, key_mac, result, exdata->smtype);
  910|    185|	LOG_TEST_RET(ctx, r, "gen_init_key failed");
  ------------------
  |  |  174|    185|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    185|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    185|	int _ret = (r); \
  |  |  |  |  168|    185|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 185, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    185|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    185|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    185|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    185|		return _ret; \
  |  |  |  |  172|    185|	} \
  |  |  |  |  173|    185|} 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|    185|{
  680|    185|	int r;
  681|    185|	struct sc_apdu apdu;
  682|    185|	unsigned char data[256] = {0};
  683|    185|	unsigned char tmp_sm;
  684|    185|	unsigned char isFips;
  685|    185|	unsigned long blocksize = 0;
  686|    185|	unsigned char cryptogram[256] = {0}; /* host cryptogram */
  687|    185|	unsigned char iv[16] = {0};
  688|    185|	epass2003_exdata *exdata = NULL;
  689|       |
  690|    185|	if (!card->drv_data)
  ------------------
  |  Branch (690:6): [True: 0, False: 185]
  ------------------
  691|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  692|       |
  693|    185|	exdata = (epass2003_exdata *)card->drv_data;
  694|    185|	isFips = exdata->bFipsCertification;
  695|       |
  696|    185|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    185|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    185|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    185|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    185|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 185]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  697|       |
  698|    185|	if (1 != RAND_bytes(g_random, sizeof(g_random)))
  ------------------
  |  Branch (698:6): [True: 0, False: 185]
  ------------------
  699|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  700|       |
  701|    185|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x50, 0x00, 0x00);
  ------------------
  |  |  294|    185|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  702|    185|	apdu.cla = 0x80;
  703|    185|	apdu.lc = apdu.datalen = sizeof(g_random);
  704|    185|	apdu.data = g_random;	/* host random */
  705|    185|	if (isFips)
  ------------------
  |  Branch (705:6): [True: 0, False: 185]
  ------------------
  706|      0|		apdu.le = apdu.resplen = 29;
  707|    185|	else
  708|    185|		apdu.le = apdu.resplen = 28;
  709|       |
  710|    185|	apdu.resp = result;	/* card random is result[12~19] */
  711|       |
  712|    185|	tmp_sm = exdata->sm;
  713|    185|	exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|    185|#define SM_PLAIN				0x00
  ------------------
  714|    185|	r = epass2003_transmit_apdu(card, &apdu);
  715|    185|	exdata->sm = tmp_sm;
  716|    185|	LOG_TEST_RET(card->ctx, r, "APDU gen_init_key failed");
  ------------------
  |  |  174|    185|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    185|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    185|	int _ret = (r); \
  |  |  |  |  168|    185|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 184]
  |  |  |  |  ------------------
  |  |  |  |  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|    185|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 184]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  717|       |
  718|    184|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  719|    184|	LOG_TEST_RET(card->ctx, r, "gen_init_key failed");
  ------------------
  |  |  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: 125, False: 59]
  |  |  |  |  ------------------
  |  |  |  |  169|    125|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    125|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    125|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    125|		return _ret; \
  |  |  |  |  172|    125|	} \
  |  |  |  |  173|    184|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 59]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|       |
  721|       |	/* Step 1 - Generate Derivation data */
  722|     59|	if (isFips) {
  ------------------
  |  Branch (722:6): [True: 0, False: 59]
  ------------------
  723|      0|		memset(data, 0x00, 15);
  724|      0|		data[11] = 0x04;
  725|      0|		data[14] = 0x80;
  726|      0|		data[15] = 0x01;
  727|      0|		memcpy(&data[16], g_random, 8);
  728|      0|		memcpy(&data[24], &result[12 + 1], 8);
  729|     59|	} else {
  730|     59|		memcpy(data, &result[16], 4);
  731|     59|		memcpy(&data[4], g_random, 4);
  732|     59|		memcpy(&data[8], &result[12], 4);
  733|     59|		memcpy(&data[12], &g_random[4], 4);
  734|     59|	}
  735|       |
  736|       |	/* Step 2,3 - Create S-ENC/S-MAC Session Key */
  737|     59|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|     59|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (737:6): [True: 8, False: 51]
  ------------------
  738|      8|		if (isFips) {
  ------------------
  |  Branch (738:7): [True: 0, False: 8]
  ------------------
  739|      0|			r = aes128_encrypt_cmac(card, key_enc, 128, data, 32, exdata->sk_enc);
  740|      0|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac enc 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  741|      0|			memset(&data[11], 0x06, 1);
  742|      0|			r = aes128_encrypt_cmac(card, key_mac, 128, data, 32, exdata->sk_mac);
  743|      0|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac mac  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  744|      8|		} else {
  745|      8|			r = aes128_encrypt_ecb(card, key_enc, 16, data, 16, exdata->sk_enc);
  746|      8|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_ecb enc  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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|      8|			r = aes128_encrypt_ecb(card, key_mac, 16, data, 16, exdata->sk_mac);
  748|      8|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_ecb mac  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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  749|      8|		}
  750|     51|	} else {
  751|     51|		r = des3_encrypt_ecb(card, key_enc, 16, data, 16, exdata->sk_enc);
  752|     51|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_ecb failed");
  ------------------
  |  |  174|     51|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     51|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     51|	int _ret = (r); \
  |  |  |  |  168|     51|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 51]
  |  |  |  |  ------------------
  |  |  |  |  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|     51|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 51]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  753|     51|		r = des3_encrypt_ecb(card, key_mac, 16, data, 16, exdata->sk_mac);
  754|     51|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_ecb failed");
  ------------------
  |  |  174|     51|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     51|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     51|	int _ret = (r); \
  |  |  |  |  168|     51|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 51]
  |  |  |  |  ------------------
  |  |  |  |  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|     51|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 51]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  755|     51|	}
  756|       |
  757|     59|	if (isFips) {
  ------------------
  |  Branch (757:6): [True: 0, False: 59]
  ------------------
  758|      0|		data[11] = 0x00;
  759|      0|		data[14] = 0x40;
  760|     59|	} else {
  761|     59|		memcpy(data, g_random, 8);
  762|     59|		memcpy(&data[8], &result[12], 8);
  763|     59|		data[16] = 0x80;
  764|     59|		blocksize = (key_type == KEY_TYPE_AES ? 16 : 8);
  ------------------
  |  |   80|     59|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (764:16): [True: 8, False: 51]
  ------------------
  765|     59|		memset(&data[17], 0x00, blocksize - 1);
  766|     59|	}
  767|       |
  768|       |	/* calculate host cryptogram */
  769|     59|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|     59|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (769:6): [True: 8, False: 51]
  ------------------
  770|      8|		if (isFips) {
  ------------------
  |  Branch (770:7): [True: 0, False: 8]
  ------------------
  771|      0|			r = aes128_encrypt_cmac(card, exdata->sk_enc, 128, data, 32, cryptogram);
  772|      8|		} else {
  773|      8|			r = aes128_encrypt_cbc(card, exdata->sk_enc, 16, iv, data, 16 + blocksize, cryptogram);
  774|      8|		}
  775|     51|	} else {
  776|     51|		r = des3_encrypt_cbc(card, exdata->sk_enc, 16, iv, data, 16 + blocksize, cryptogram);
  777|     51|	}
  778|       |
  779|     59|	LOG_TEST_RET(card->ctx, r, "calculate host cryptogram failed");
  ------------------
  |  |  174|     59|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     59|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     59|	int _ret = (r); \
  |  |  |  |  168|     59|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 59]
  |  |  |  |  ------------------
  |  |  |  |  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|     59|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 59]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  780|       |
  781|       |	/* verify card cryptogram */
  782|     59|	if (isFips) {
  ------------------
  |  Branch (782:6): [True: 0, False: 59]
  ------------------
  783|      0|		if (0 != memcmp(&cryptogram[0], &result[20+1], 8))
  ------------------
  |  Branch (783:7): [True: 0, False: 0]
  ------------------
  784|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  785|     59|	} else {
  786|     59|		if (0 != memcmp(&cryptogram[16], &result[20], 8))
  ------------------
  |  Branch (786:7): [True: 59, False: 0]
  ------------------
  787|     59|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  788|     59|	}
  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:
 1616|    185|{
 1617|    185|	int r;
 1618|       |
 1619|    185|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    185|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    185|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    185|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    185|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 185]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1620|       |
 1621|    185|	r = sc_transmit_apdu_t(card, apdu);
 1622|    185|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    185|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    185|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    185|	int _ret = (r); \
  |  |  |  |  168|    185|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 184]
  |  |  |  |  ------------------
  |  |  |  |  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|    185|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 184]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1623|       |
 1624|    184|	return r;
 1625|    185|}
card-epass2003.c:sc_transmit_apdu_t:
  268|  1.96k|{
  269|  1.96k|	size_t resplen = apdu->resplen;
  270|  1.96k|	int r = sc_transmit_apdu(card, apdu);
  271|  1.96k|	if ((0x69 == apdu->sw1 && 0x85 == apdu->sw2) || (0x69 == apdu->sw1 && 0x88 == apdu->sw2)) {
  ------------------
  |  Branch (271:7): [True: 109, False: 1.85k]
  |  Branch (271:28): [True: 63, False: 46]
  |  Branch (271:51): [True: 46, False: 1.85k]
  |  Branch (271:72): [True: 34, False: 12]
  ------------------
  272|     97|		epass2003_refresh(card);
  273|       |		/* renew old resplen */
  274|     97|		apdu->resplen = resplen;
  275|     97|		r = sc_transmit_apdu(card, apdu);
  276|     97|	}
  277|  1.96k|	return r;
  278|  1.96k|}
card-epass2003.c:aes128_encrypt_ecb:
  475|     16|{
  476|     16|	unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
  477|     16|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "AES-128-ECB");
  478|     16|	int r;
  479|     16|	r = openssl_enc(alg, key, iv, input, length, output);
  480|     16|	sc_evp_cipher_free(alg);
  481|     16|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     16|#define SC_SUCCESS				0
  ------------------
  |  Branch (481:6): [True: 0, False: 16]
  ------------------
  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|     16|	return r;
  484|     16|}
card-epass2003.c:openssl_enc:
  283|    693|{
  284|    693|	int r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    693|#define SC_ERROR_INTERNAL			-1400
  ------------------
  285|    693|	EVP_CIPHER_CTX * ctx = NULL;
  286|    693|	int outl = 0;
  287|    693|	int outl_tmp = 0;
  288|    693|	unsigned char iv_tmp[EVP_MAX_IV_LENGTH] = {0};
  289|       |
  290|    693|	memcpy(iv_tmp, iv, EVP_MAX_IV_LENGTH);
  291|    693|	ctx = EVP_CIPHER_CTX_new();
  292|    693|	if (ctx == NULL)
  ------------------
  |  Branch (292:6): [True: 0, False: 693]
  ------------------
  293|      0|		goto out;
  294|       |
  295|    693|	if (!EVP_EncryptInit_ex(ctx, cipher, NULL, key, iv_tmp) || !EVP_CIPHER_CTX_set_padding(ctx, 0))
  ------------------
  |  Branch (295:6): [True: 0, False: 693]
  |  Branch (295:61): [True: 0, False: 693]
  ------------------
  296|      0|		goto out;
  297|       |
  298|    693|	if (!EVP_EncryptUpdate(ctx, output, &outl, input, (int)length))
  ------------------
  |  Branch (298:6): [True: 0, False: 693]
  ------------------
  299|      0|		goto out;
  300|       |
  301|    693|	if (!EVP_EncryptFinal_ex(ctx, output + outl, &outl_tmp))
  ------------------
  |  Branch (301:6): [True: 0, False: 693]
  ------------------
  302|      0|		goto out;
  303|       |
  304|    693|	r = SC_SUCCESS;
  ------------------
  |  |   28|    693|#define SC_SUCCESS				0
  ------------------
  305|    693|out:
  306|    693|	EVP_CIPHER_CTX_free(ctx);
  307|    693|	return r;
  308|    693|}
card-epass2003.c:des3_encrypt_ecb:
  518|    102|{
  519|    102|	unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
  520|    102|	unsigned char bKey[24] = {0};
  521|    102|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-EDE3");
  522|    102|	int r;
  523|       |
  524|    102|	if (keysize == 16) {
  ------------------
  |  Branch (524:6): [True: 102, False: 0]
  ------------------
  525|    102|		memcpy(&bKey[0], key, 16);
  526|    102|		memcpy(&bKey[16], key, 8);
  527|    102|	} else {
  528|      0|		memcpy(&bKey[0], key, 24);
  529|      0|	}
  530|       |
  531|    102|	r = openssl_enc(alg, bKey, iv, input, length, output);
  532|    102|	sc_evp_cipher_free(alg);
  533|    102|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    102|#define SC_SUCCESS				0
  ------------------
  |  Branch (533:6): [True: 0, False: 102]
  ------------------
  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|    102|	return r;
  536|    102|}
card-epass2003.c:aes128_encrypt_cbc:
  490|     61|{
  491|     61|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "AES-128-CBC");
  492|     61|	int r;
  493|     61|	r = openssl_enc(alg, key, iv, input, length, output);
  494|     61|	sc_evp_cipher_free(alg);
  495|     61|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     61|#define SC_SUCCESS				0
  ------------------
  |  Branch (495:6): [True: 0, False: 61]
  ------------------
  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|     61|	return r;
  498|     61|}
card-epass2003.c:des3_encrypt_cbc:
  542|    200|{
  543|    200|	unsigned char bKey[24] = {0};
  544|    200|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-EDE3-CBC");
  545|    200|	int r;
  546|       |
  547|    200|	if (keysize == 16) {
  ------------------
  |  Branch (547:6): [True: 200, False: 0]
  ------------------
  548|    200|		memcpy(&bKey[0], key, 16);
  549|    200|		memcpy(&bKey[16], key, 8);
  550|    200|	} else {
  551|      0|		memcpy(&bKey[0], key, 24);
  552|      0|	}
  553|       |
  554|    200|	r = openssl_enc(EVP_des_ede3_cbc(), bKey, iv, input, length, output);
  555|    200|	sc_evp_cipher_free(alg);
  556|    200|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    200|#define SC_SUCCESS				0
  ------------------
  |  Branch (556:6): [True: 0, False: 200]
  ------------------
  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|    200|	return r;
  559|    200|}
card-epass2003.c:sc_get_driver:
 3260|  3.69k|{
 3261|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3262|       |
 3263|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (3263:6): [True: 1, False: 3.69k]
  ------------------
 3264|      1|		iso_ops = iso_drv->ops;
 3265|       |
 3266|  3.69k|	epass2003_ops = *iso_ops;
 3267|       |
 3268|  3.69k|	epass2003_ops.match_card = epass2003_match_card;
 3269|  3.69k|	epass2003_ops.init = epass2003_init;
 3270|  3.69k|	epass2003_ops.finish = epass2003_finish;
 3271|  3.69k|	epass2003_ops.write_binary = NULL;
 3272|  3.69k|	epass2003_ops.write_record = NULL;
 3273|  3.69k|	epass2003_ops.select_file = epass2003_select_file;
 3274|       |	epass2003_ops.get_response = NULL;
 3275|  3.69k|	epass2003_ops.restore_security_env = epass2003_restore_security_env;
 3276|  3.69k|	epass2003_ops.set_security_env = epass2003_set_security_env;
 3277|  3.69k|	epass2003_ops.decipher = epass2003_decipher;
 3278|  3.69k|	epass2003_ops.compute_signature = epass2003_decipher;
 3279|  3.69k|	epass2003_ops.create_file = epass2003_create_file;
 3280|  3.69k|	epass2003_ops.delete_file = epass2003_delete_file;
 3281|  3.69k|	epass2003_ops.list_files = epass2003_list_files;
 3282|  3.69k|	epass2003_ops.card_ctl = epass2003_card_ctl;
 3283|  3.69k|	epass2003_ops.process_fci = epass2003_process_fci;
 3284|  3.69k|	epass2003_ops.construct_fci = epass2003_construct_fci;
 3285|  3.69k|	epass2003_ops.pin_cmd = epass2003_pin_cmd;
 3286|  3.69k|	epass2003_ops.check_sw = epass2003_check_sw;
 3287|  3.69k|	epass2003_ops.get_challenge = epass2003_get_challenge;
 3288|  3.69k|	epass2003_ops.logout = epass2003_logout;
 3289|  3.69k|	return &epass2003_drv;
 3290|  3.69k|}
card-epass2003.c:epass2003_match_card:
 1668|  2.42k|{
 1669|  2.42k|	int r;
 1670|       |
 1671|  2.42k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.42k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.42k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.42k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.42k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.42k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1672|  2.42k|	r = _sc_match_atr(card, epass2003_atrs, &card->type);
 1673|  2.42k|	if (r < 0)
  ------------------
  |  Branch (1673:6): [True: 2.30k, False: 121]
  ------------------
 1674|  2.30k|		return 0;
 1675|       |
 1676|    121|	return 1;
 1677|  2.42k|}
card-epass2003.c:epass2003_init:
 1682|    121|{
 1683|    121|	unsigned int flags;
 1684|    121|	unsigned int ext_flags;
 1685|    121|	unsigned char data[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1686|    121|	size_t datalen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    121|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 1687|    121|	epass2003_exdata *exdata = NULL;
 1688|    121|	void *old_drv_data = card->drv_data;
 1689|       |
 1690|    121|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    121|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    121|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    121|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    121|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 121]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1691|       |
 1692|    121|	card->name = "epass2003";
 1693|    121|	card->cla = 0x00;
 1694|    121|	exdata = (epass2003_exdata *)calloc(1, sizeof(epass2003_exdata));
 1695|    121|	if (!exdata)
  ------------------
  |  Branch (1695:6): [True: 0, False: 121]
  ------------------
 1696|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1697|       |
 1698|    121|	card->drv_data = exdata;
 1699|       |
 1700|    121|	exdata->sm = SM_SCP01;
  ------------------
  |  |   92|    121|#define SM_SCP01				0x01
  ------------------
 1701|       |
 1702|       |	/* decide FIPS/Non-FIPS mode */
 1703|    121|	if (SC_SUCCESS != get_data(card, 0x86, data, datalen)) {
  ------------------
  |  |   28|    121|#define SC_SUCCESS				0
  ------------------
  |  Branch (1703:6): [True: 0, False: 121]
  ------------------
 1704|      0|		free(exdata);
 1705|      0|		card->drv_data = old_drv_data;
 1706|      0|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      0|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 1707|      0|	}
 1708|       |
 1709|    121|	if (memcmp(&data[32], "\x87\x01\x01", 3) == 0 && memcmp(&data[0], "\x80\x01\x01", 3) == 0) {
  ------------------
  |  Branch (1709:6): [True: 0, False: 121]
  |  Branch (1709:51): [True: 0, False: 0]
  ------------------
 1710|      0|		exdata->bFipsCertification = 0x01;
 1711|    121|	} else {
 1712|    121|		exdata->bFipsCertification = 0x00;
 1713|    121|	}
 1714|       |
 1715|    121|	if (0x01 == data[2])
  ------------------
  |  Branch (1715:6): [True: 8, False: 113]
  ------------------
 1716|      8|		exdata->smtype = KEY_TYPE_AES;
  ------------------
  |  |   80|      8|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
 1717|    113|	else
 1718|    113|		exdata->smtype = KEY_TYPE_DES;
  ------------------
  |  |   81|    113|#define KEY_TYPE_DES	0x02	/* Non-FIPS mode */
  ------------------
 1719|       |
 1720|    121|	if (0x84 == data[14]) {
  ------------------
  |  Branch (1720:6): [True: 12, False: 109]
  ------------------
 1721|     12|		if (0x00 == data[16]) {
  ------------------
  |  Branch (1721:7): [True: 12, False: 0]
  ------------------
 1722|     12|			exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|     12|#define SM_PLAIN				0x00
  ------------------
 1723|     12|		}
 1724|     12|	}
 1725|       |
 1726|       |	/* mutual authentication */
 1727|    121|	card->max_recv_size = 0xD8;
 1728|    121|	card->max_send_size = 0xE8;
 1729|       |
 1730|    121|	card->sm_ctx.ops.open = epass2003_refresh;
 1731|    121|	card->sm_ctx.ops.get_sm_apdu = epass2003_sm_get_wrapped_apdu;
 1732|    121|	card->sm_ctx.ops.free_sm_apdu = epass2003_sm_free_wrapped_apdu;
 1733|       |
 1734|       |	/* FIXME (VT): rather then set/unset 'g_sm', better to implement filter for APDUs to be wrapped */
 1735|    121|	epass2003_refresh(card);
 1736|       |
 1737|    121|	card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|    121|#define SM_MODE_TRANSMIT	0x200
  ------------------
 1738|       |
 1739|    121|	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  102|    121|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  111|    121|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_ONBOARD_KEY_GEN | SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  142|    121|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
 1740|       |
 1741|    121|	_sc_card_add_rsa_alg(card, 512, flags, 0);
 1742|    121|	_sc_card_add_rsa_alg(card, 768, flags, 0);
 1743|    121|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
 1744|    121|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
 1745|       |
 1746|       |	//set EC Alg Flags
 1747|    121|	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;
  ------------------
  |  |  102|    121|#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;
  ------------------
  |  |  185|    121|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  143|    121|#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;
  ------------------
  |  |  187|    121|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  147|    121|#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;
  ------------------
  |  |  184|    121|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|    121|#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;
  ------------------
  |  |  183|    121|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
 1748|    121|	ext_flags = 0;
 1749|    121|	_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
 1750|       |
 1751|    121|	card->caps = SC_CARD_CAP_RNG | SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  557|    121|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps = SC_CARD_CAP_RNG | SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|    121|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
 1752|       |
 1753|    121|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    121|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    121|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    121|	int _ret = r; \
  |  |  |  |  155|    121|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 121, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    121|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 121]
  |  |  |  |  ------------------
  |  |  |  |  157|    121|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    121|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    121|	return _ret; \
  |  |  |  |  163|    121|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1754|    121|}
card-epass2003.c:get_data:
 1630|    147|{
 1631|    147|	int r;
 1632|    147|	struct sc_apdu apdu;
 1633|    147|	unsigned char resp[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1634|    147|	size_t resplen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    147|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 1635|    147|	epass2003_exdata *exdata = NULL;
 1636|       |
 1637|    147|	if (!card->drv_data)
  ------------------
  |  Branch (1637:6): [True: 0, False: 147]
  ------------------
 1638|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1639|       |
 1640|    147|	exdata = (epass2003_exdata *)card->drv_data;
 1641|       |
 1642|    147|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    147|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    147|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    147|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    147|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 147]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1643|       |
 1644|    147|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, type);
  ------------------
  |  |  292|    147|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1645|    147|	apdu.resp = resp;
 1646|    147|	apdu.le = 0;
 1647|    147|	apdu.resplen = resplen;
 1648|    147|	if (0x86 == type) {
  ------------------
  |  Branch (1648:6): [True: 121, False: 26]
  ------------------
 1649|       |		/* No SM temporarily */
 1650|    121|		unsigned char tmp_sm = exdata->sm;
 1651|    121|		exdata->sm = SM_PLAIN;
  ------------------
  |  |   91|    121|#define SM_PLAIN				0x00
  ------------------
 1652|    121|		r = sc_transmit_apdu(card, &apdu);
 1653|    121|		exdata->sm = tmp_sm;
 1654|    121|	} else {
 1655|     26|		r = sc_transmit_apdu_t(card, &apdu);
 1656|     26|	}
 1657|    147|	LOG_TEST_RET(card->ctx, r, "APDU get_data failed");
  ------------------
  |  |  174|    147|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    147|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    147|	int _ret = (r); \
  |  |  |  |  168|    147|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 135]
  |  |  |  |  ------------------
  |  |  |  |  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|    147|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 135]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1658|    135|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1659|    135|	LOG_TEST_RET(card->ctx, r, "get_data failed");
  ------------------
  |  |  174|    135|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    135|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    135|	int _ret = (r); \
  |  |  |  |  168|    135|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  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|    135|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 128]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1660|       |
 1661|    128|	memcpy(data, resp, datalen);
 1662|    128|	return r;
 1663|    135|}
card-epass2003.c:epass2003_sm_get_wrapped_apdu:
 1565|    368|{
 1566|    368|	struct sc_context *ctx = card->ctx;
 1567|    368|	struct sc_apdu *apdu = NULL;
 1568|    368|	int rv;
 1569|       |
 1570|    368|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    368|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    368|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    368|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    368|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 368]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1571|    368|	if (!plain || !sm_apdu)
  ------------------
  |  Branch (1571:6): [True: 0, False: 368]
  |  Branch (1571:16): [True: 0, False: 368]
  ------------------
 1572|    368|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1573|       |
 1574|    368|	*sm_apdu = NULL;
 1575|       |	//construct new SM apdu from original apdu
 1576|    368|	apdu = calloc(1, sizeof(struct sc_apdu));
 1577|    368|	if (!apdu) {
  ------------------
  |  Branch (1577:6): [True: 0, False: 368]
  ------------------
 1578|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1579|      0|		goto err;
 1580|      0|	}
 1581|    368|	apdu->data = calloc (1, SC_MAX_EXT_APDU_BUFFER_SIZE);
  ------------------
  |  |   37|    368|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1582|    368|	if (!apdu->data) {
  ------------------
  |  Branch (1582:6): [True: 0, False: 368]
  ------------------
 1583|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1584|      0|		goto err;
 1585|      0|	}
 1586|    368|	apdu->resp = calloc (1, SC_MAX_EXT_APDU_BUFFER_SIZE);
  ------------------
  |  |   37|    368|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1587|    368|	if (!apdu->resp) {
  ------------------
  |  Branch (1587:6): [True: 0, False: 368]
  ------------------
 1588|      0|		rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1589|      0|		goto err;
 1590|      0|	}
 1591|    368|	apdu->datalen = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|    368|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1592|    368|	apdu->resplen = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|    368|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
 1593|       |
 1594|    368|	rv = epass2003_sm_wrap_apdu(card, plain, apdu);
 1595|    368|	if (rv) {
  ------------------
  |  Branch (1595:6): [True: 0, False: 368]
  ------------------
 1596|      0|		rv = epass2003_sm_free_wrapped_apdu(card, NULL, &apdu);
 1597|      0|		if (rv < 0)
  ------------------
  |  Branch (1597:7): [True: 0, False: 0]
  ------------------
 1598|      0|			goto err;
 1599|      0|	}
 1600|       |
 1601|    368|	*sm_apdu = apdu;
 1602|    368|	apdu = NULL;
 1603|    368|err:
 1604|    368|	if (apdu) {
  ------------------
  |  Branch (1604:6): [True: 0, False: 368]
  ------------------
 1605|      0|		free((unsigned char *) apdu->data);
 1606|      0|		free(apdu->resp);
 1607|      0|		free(apdu);
 1608|      0|		apdu = NULL;
 1609|      0|	}
 1610|    368|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    368|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    368|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    368|	int _ret = r; \
  |  |  |  |  155|    368|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 368, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    368|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 368]
  |  |  |  |  ------------------
  |  |  |  |  157|    368|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    368|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    368|	return _ret; \
  |  |  |  |  163|    368|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1611|    368|}
card-epass2003.c:epass2003_sm_wrap_apdu:
 1278|    368|{
 1279|    368|	unsigned char buf[4096] = {0}; /* APDU buffer */
 1280|    368|	size_t buf_len = sizeof(buf);
 1281|    368|	epass2003_exdata *exdata = NULL;
 1282|       |
 1283|    368|	if (!card->drv_data)
  ------------------
  |  Branch (1283:6): [True: 0, False: 368]
  ------------------
 1284|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1285|       |
 1286|    368|	exdata = (epass2003_exdata *)card->drv_data;
 1287|       |
 1288|    368|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    368|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    368|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    368|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    368|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 368]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1289|       |
 1290|    368|	if (exdata->sm)
  ------------------
  |  Branch (1290:6): [True: 185, False: 183]
  ------------------
 1291|    185|		plain->cla |= 0x0C;
 1292|       |
 1293|    368|	sm->cse = plain->cse;
 1294|    368|	sm->cla = plain->cla;
 1295|    368|	sm->ins = plain->ins;
 1296|    368|	sm->p1 = plain->p1;
 1297|    368|	sm->p2 = plain->p2;
 1298|    368|	sm->lc = plain->lc;
 1299|    368|	sm->le = plain->le;
 1300|    368|	sm->control = plain->control;
 1301|    368|	sm->flags = plain->flags;
 1302|       |
 1303|    368|	switch (sm->cla & 0x0C) {
 1304|    183|	case 0x00:
  ------------------
  |  Branch (1304:2): [True: 183, False: 185]
  ------------------
 1305|    183|	case 0x04:
  ------------------
  |  Branch (1305:2): [True: 0, False: 368]
  ------------------
 1306|    183|		sm->datalen = plain->datalen;
 1307|    183|		memcpy((void *)sm->data, plain->data, plain->datalen);
 1308|    183|		sm->resplen = plain->resplen;
 1309|    183|		memcpy(sm->resp, plain->resp, plain->resplen);
 1310|    183|		break;
 1311|    185|	case 0x0C:
  ------------------
  |  Branch (1311:2): [True: 185, False: 183]
  ------------------
 1312|    185|		memset(buf, 0, sizeof(buf));
 1313|    185|		if (0 != encode_apdu(card, plain, sm, buf, &buf_len))
  ------------------
  |  Branch (1313:7): [True: 0, False: 185]
  ------------------
 1314|      0|			return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|      0|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1315|    185|		break;
 1316|    185|	default:
  ------------------
  |  Branch (1316:2): [True: 0, False: 368]
  ------------------
 1317|      0|		return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
 1318|    368|	}
 1319|       |
 1320|    368|	return SC_SUCCESS;
  ------------------
  |  |   28|    368|#define SC_SUCCESS				0
  ------------------
 1321|    368|}
card-epass2003.c:encode_apdu:
 1189|    185|{
 1190|    185|	size_t block_size = 0;
 1191|    185|	unsigned char dataTLV[4096] = {0};
 1192|    185|	size_t data_tlv_len = 0;
 1193|    185|	unsigned char le_tlv[256] = {0};
 1194|    185|	size_t le_tlv_len = 0;
 1195|    185|	size_t mac_tlv_len = 10;
 1196|    185|	size_t tmp_lc = 0;
 1197|    185|	size_t tmp_le = 0;
 1198|    185|	unsigned char mac_tlv[256] = {0};
 1199|    185|	epass2003_exdata *exdata = NULL;
 1200|       |
 1201|    185|	mac_tlv[0] = 0x8E;
 1202|    185|	mac_tlv[1] = 8;
 1203|       |	/* size_t plain_le = 0; */
 1204|    185|	if (!card->drv_data)
  ------------------
  |  Branch (1204:6): [True: 0, False: 185]
  ------------------
 1205|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1206|    185|	exdata = (epass2003_exdata*)card->drv_data;
 1207|    185|	block_size = (KEY_TYPE_DES == exdata->smtype ? 16 : 8);
  ------------------
  |  |   81|    185|#define KEY_TYPE_DES	0x02	/* Non-FIPS mode */
  ------------------
  |  Branch (1207:16): [True: 157, False: 28]
  ------------------
 1208|       |
 1209|    185|	sm->cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|    185|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1210|    185|	apdu_buf[0] = (unsigned char)plain->cla;
 1211|    185|	apdu_buf[1] = (unsigned char)plain->ins;
 1212|    185|	apdu_buf[2] = (unsigned char)plain->p1;
 1213|    185|	apdu_buf[3] = (unsigned char)plain->p2;
 1214|       |	/* plain_le = plain->le; */
 1215|       |	/* padding */
 1216|    185|	if (exdata->bFipsCertification && plain->lc == 0 && apdu_buf[1] == 0x82 && apdu_buf[2] == 0x01) {
  ------------------
  |  Branch (1216:6): [True: 0, False: 185]
  |  Branch (1216:36): [True: 0, False: 0]
  |  Branch (1216:54): [True: 0, False: 0]
  |  Branch (1216:77): [True: 0, False: 0]
  ------------------
 1217|      0|		apdu_buf[4] = 0x00;
 1218|    185|	} else {
 1219|    185|		apdu_buf[4] = 0x80;
 1220|    185|	}
 1221|    185|	memset(&apdu_buf[5], 0x00, block_size - 5);
 1222|       |
 1223|       |	/* Data -> Data' */
 1224|    185|	if (plain->lc != 0)
  ------------------
  |  Branch (1224:6): [True: 174, False: 11]
  ------------------
 1225|    174|		if (0 != construct_data_tlv(card, plain, apdu_buf, dataTLV, &data_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1225:7): [True: 0, False: 174]
  ------------------
 1226|      0|			return -1;
 1227|       |
 1228|    185|	if (plain->le != 0 || (plain->le == 0 && plain->resplen != 0))
  ------------------
  |  Branch (1228:6): [True: 15, False: 170]
  |  Branch (1228:25): [True: 170, False: 0]
  |  Branch (1228:43): [True: 170, False: 0]
  ------------------
 1229|    185|		if (0 != construct_le_tlv(plain, apdu_buf, data_tlv_len, le_tlv,
  ------------------
  |  Branch (1229:7): [True: 0, False: 185]
  ------------------
 1230|    185|				     &le_tlv_len, exdata->smtype))
 1231|      0|			return -1;
 1232|       |
 1233|    185|	if (exdata->bFipsCertification && plain->lc == 0 && apdu_buf[1] == 0x82 && apdu_buf[2] == 0x01) {
  ------------------
  |  Branch (1233:6): [True: 0, False: 185]
  |  Branch (1233:36): [True: 0, False: 0]
  |  Branch (1233:54): [True: 0, False: 0]
  |  Branch (1233:77): [True: 0, False: 0]
  ------------------
 1234|      0|		if (0 != construct_mac_tlv_case1(card, apdu_buf, data_tlv_len, le_tlv_len, mac_tlv, &mac_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1234:7): [True: 0, False: 0]
  ------------------
 1235|      0|			return -1;
 1236|    185|	} else {
 1237|    185|		if (0 != construct_mac_tlv(card, apdu_buf, data_tlv_len, le_tlv_len, mac_tlv, &mac_tlv_len, exdata->smtype))
  ------------------
  |  Branch (1237:7): [True: 0, False: 185]
  ------------------
 1238|      0|			return -1;
 1239|    185|	}
 1240|       |
 1241|    185|	memset(apdu_buf + 4, 0, *apdu_buf_len - 4);
 1242|    185|	sm->lc = sm->datalen = data_tlv_len + le_tlv_len + mac_tlv_len;
 1243|    185|	if (sm->lc > 0xFF) {
  ------------------
  |  Branch (1243:6): [True: 0, False: 185]
  ------------------
 1244|      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
  |  |  ------------------
  ------------------
 1245|      0|		apdu_buf[4] = (unsigned char)((sm->lc) / 0x10000);
 1246|      0|		apdu_buf[5] = (unsigned char)(((sm->lc) / 0x100) % 0x100);
 1247|      0|		apdu_buf[6] = (unsigned char)((sm->lc) % 0x100);
 1248|      0|		tmp_lc = 3;
 1249|    185|	} else {
 1250|    185|		apdu_buf[4] = (unsigned char)sm->lc;
 1251|    185|		tmp_lc = 1;
 1252|    185|	}
 1253|       |
 1254|    185|	memcpy(apdu_buf + 4 + tmp_lc, dataTLV, data_tlv_len);
 1255|    185|	memcpy(apdu_buf + 4 + tmp_lc + data_tlv_len, le_tlv, le_tlv_len);
 1256|    185|	memcpy(apdu_buf + 4 + tmp_lc + data_tlv_len + le_tlv_len, mac_tlv, mac_tlv_len);
 1257|    185|	memcpy((unsigned char *)sm->data, apdu_buf + 4 + tmp_lc, sm->datalen);
 1258|    185|	*apdu_buf_len = 0;
 1259|       |
 1260|    185|	if (4 == le_tlv_len) {
  ------------------
  |  Branch (1260:6): [True: 15, False: 170]
  ------------------
 1261|     15|		sm->cse = SC_APDU_CASE_4_EXT;
  ------------------
  |  |  299|     15|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|     15|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|     15|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
 1262|     15|		*(apdu_buf + 4 + tmp_lc + sm->lc) = (unsigned char)(plain->le / 0x100);
 1263|     15|		*(apdu_buf + 4 + tmp_lc + sm->lc + 1) = (unsigned char)(plain->le % 0x100);
 1264|     15|		tmp_le = 2;
 1265|    170|	} else if (3 == le_tlv_len) {
  ------------------
  |  Branch (1265:13): [True: 170, False: 0]
  ------------------
 1266|    170|		*(apdu_buf + 4 + tmp_lc + sm->lc) = (unsigned char)plain->le;
 1267|    170|		tmp_le = 1;
 1268|    170|	}
 1269|       |
 1270|    185|	*apdu_buf_len += 4 + tmp_lc + data_tlv_len + le_tlv_len + mac_tlv_len + tmp_le;
 1271|       |	/* sm->le = calc_le(plain_le); */
 1272|    185|	return 0;
 1273|    185|}
card-epass2003.c:construct_data_tlv:
  950|    174|{
  951|    174|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    174|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (951:23): [True: 25, False: 149]
  ------------------
  952|    174|	unsigned char pad[4096] = {0};
  953|    174|	size_t pad_len;
  954|    174|	size_t tlv_more;	/* increased tlv length */
  955|    174|	unsigned char iv[16] = {0};
  956|    174|	epass2003_exdata *exdata = NULL;
  957|    174|	int r = 0;
  958|       |
  959|    174|	if (!card->drv_data)
  ------------------
  |  Branch (959:6): [True: 0, False: 174]
  ------------------
  960|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  961|       |
  962|    174|	exdata = (epass2003_exdata *)card->drv_data;
  963|       |
  964|       |	/* padding */
  965|    174|	apdu_buf[block_size] = 0x87;
  966|    174|	memcpy(pad, apdu->data, apdu->lc);
  967|    174|	pad[apdu->lc] = 0x80;
  968|    174|	if ((apdu->lc + 1) % block_size)
  ------------------
  |  Branch (968:6): [True: 174, False: 0]
  ------------------
  969|    174|		pad_len = ((apdu->lc + 1) / block_size + 1) * block_size;
  970|      0|	else
  971|      0|		pad_len = apdu->lc + 1;
  972|       |
  973|       |	/* encode Lc' */
  974|    174|	if (pad_len > 0x7E) {
  ------------------
  |  Branch (974:6): [True: 0, False: 174]
  ------------------
  975|       |		/* Lc' > 0x7E, use extended APDU */
  976|      0|		apdu_buf[block_size + 1] = 0x82;
  977|      0|		apdu_buf[block_size + 2] = (unsigned char)((pad_len + 1) / 0x100);
  978|      0|		apdu_buf[block_size + 3] = (unsigned char)((pad_len + 1) % 0x100);
  979|      0|		apdu_buf[block_size + 4] = 0x01;
  980|      0|		tlv_more = 5;
  981|    174|	} else {
  982|    174|		apdu_buf[block_size + 1] = (unsigned char)pad_len + 1;
  983|    174|		apdu_buf[block_size + 2] = 0x01;
  984|    174|		tlv_more = 3;
  985|    174|	}
  986|    174|	memcpy(data_tlv, &apdu_buf[block_size], tlv_more);
  987|       |
  988|       |	/* encrypt Data */
  989|    174|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|    174|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (989:6): [True: 25, False: 149]
  ------------------
  990|     25|		r = aes128_encrypt_cbc(card, exdata->sk_enc, 16, iv, pad, pad_len, apdu_buf + block_size + tlv_more);
  991|     25|		LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cbc failed");
  ------------------
  |  |  174|     25|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     25|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     25|	int _ret = (r); \
  |  |  |  |  168|     25|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|    149|	} else {
  993|    149|		r = des3_encrypt_cbc(card, exdata->sk_enc, 16, iv, pad, pad_len, apdu_buf + block_size + tlv_more);
  994|    149|		LOG_TEST_RET(card->ctx, r, "des3_encrypt_cbc 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: 0, False: 149]
  |  |  |  |  ------------------
  |  |  |  |  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|    149|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 149]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  995|    149|	}
  996|       |
  997|    174|	memcpy(data_tlv + tlv_more, apdu_buf + block_size + tlv_more, pad_len);
  998|    174|	*data_tlv_len = tlv_more + pad_len;
  999|    174|	return 0;
 1000|    174|}
card-epass2003.c:construct_le_tlv:
 1007|    185|{
 1008|    185|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    185|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1008:23): [True: 28, False: 157]
  ------------------
 1009|       |
 1010|    185|	*(apdu_buf + block_size + data_tlv_len) = 0x97;
 1011|    185|	if (apdu->le > 0x7F) {
  ------------------
  |  Branch (1011:6): [True: 15, False: 170]
  ------------------
 1012|       |		/* Le' > 0x7E, use extended APDU */
 1013|     15|		*(apdu_buf + block_size + data_tlv_len + 1) = 2;
 1014|     15|		*(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)(apdu->le / 0x100);
 1015|     15|		*(apdu_buf + block_size + data_tlv_len + 3) = (unsigned char)(apdu->le % 0x100);
 1016|     15|		memcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 4);
 1017|     15|		*le_tlv_len = 4;
 1018|    170|	} else {
 1019|    170|		*(apdu_buf + block_size + data_tlv_len + 1) = 1;
 1020|    170|		*(apdu_buf + block_size + data_tlv_len + 2) = (unsigned char)apdu->le;
 1021|    170|		memcpy(le_tlv, apdu_buf + block_size + data_tlv_len, 3);
 1022|    170|		*le_tlv_len = 3;
 1023|    170|	}
 1024|    185|	return 0;
 1025|    185|}
card-epass2003.c:des_encrypt_cbc:
  588|    314|{
  589|    314|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-CBC");
  590|    314|	int r;
  591|       |
  592|    314|	r = openssl_enc(alg, key, iv, input, length, output);
  593|    314|	sc_evp_cipher_free(alg);
  594|    314|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    314|#define SC_SUCCESS				0
  ------------------
  |  Branch (594:6): [True: 0, False: 314]
  ------------------
  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|    314|	return r;
  597|    314|}
card-epass2003.c:des_decrypt_cbc:
  603|    157|{
  604|    157|	EVP_CIPHER *alg = sc_evp_cipher(card->ctx, "DES-CBC");
  605|    157|	int r;
  606|       |
  607|    157|	r = openssl_dec(alg, key, iv, input, length, output);
  608|    157|	sc_evp_cipher_free(alg);
  609|    157|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    157|#define SC_SUCCESS				0
  ------------------
  |  Branch (609:6): [True: 0, False: 157]
  ------------------
  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|    157|	return r;
  612|    157|}
card-epass2003.c:openssl_dec:
  313|    157|{
  314|    157|	int r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    157|#define SC_ERROR_INTERNAL			-1400
  ------------------
  315|    157|	EVP_CIPHER_CTX * ctx = NULL;
  316|    157|	int outl = 0;
  317|    157|	int outl_tmp = 0;
  318|    157|	unsigned char iv_tmp[EVP_MAX_IV_LENGTH] = {0};
  319|       |
  320|    157|	memcpy(iv_tmp, iv, EVP_MAX_IV_LENGTH);
  321|    157|	ctx = EVP_CIPHER_CTX_new();
  322|    157|	if (ctx == NULL)
  ------------------
  |  Branch (322:6): [True: 0, False: 157]
  ------------------
  323|      0|		goto out;
  324|       |
  325|    157|	if (!EVP_DecryptInit_ex(ctx, cipher, NULL, key, iv_tmp) ||
  ------------------
  |  Branch (325:6): [True: 0, False: 157]
  ------------------
  326|    157|			!EVP_CIPHER_CTX_set_padding(ctx, 0))
  ------------------
  |  Branch (326:4): [True: 0, False: 157]
  ------------------
  327|      0|		goto out;
  328|       |
  329|    157|	if (!EVP_DecryptUpdate(ctx, output, &outl, input, (int)length))
  ------------------
  |  Branch (329:6): [True: 0, False: 157]
  ------------------
  330|      0|		goto out;
  331|       |
  332|    157|	if (!EVP_DecryptFinal_ex(ctx, output + outl, &outl_tmp))
  ------------------
  |  Branch (332:6): [True: 0, False: 157]
  ------------------
  333|      0|		goto out;
  334|       |
  335|    157|	r = SC_SUCCESS;
  ------------------
  |  |   28|    157|#define SC_SUCCESS				0
  ------------------
  336|    157|out:
  337|    157|	EVP_CIPHER_CTX_free(ctx);
  338|    157|	return r;
  339|    157|}
card-epass2003.c:construct_mac_tlv:
 1032|    185|{
 1033|    185|	size_t block_size = (KEY_TYPE_AES == key_type ? 16 : 8);
  ------------------
  |  |   80|    185|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1033:23): [True: 28, False: 157]
  ------------------
 1034|    185|	unsigned char mac[4096] = {0};
 1035|    185|	size_t mac_len;
 1036|    185|	unsigned char icv[16] = {0};
 1037|    185|	int r ;
 1038|    185|	int i = (KEY_TYPE_AES == key_type ? 15 : 7);
  ------------------
  |  |   80|    185|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1038:11): [True: 28, False: 157]
  ------------------
 1039|    185|	epass2003_exdata *exdata = NULL;
 1040|       |
 1041|    185|	if (!card->drv_data)
  ------------------
  |  Branch (1041:6): [True: 0, False: 185]
  ------------------
 1042|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1043|       |
 1044|    185|	exdata = (epass2003_exdata *)card->drv_data;
 1045|       |
 1046|    185|	if (0 == data_tlv_len && 0 == le_tlv_len) {
  ------------------
  |  Branch (1046:6): [True: 11, False: 174]
  |  Branch (1046:27): [True: 0, False: 11]
  ------------------
 1047|      0|		mac_len = block_size;
 1048|    185|	} else {
 1049|       |		/* padding */
 1050|    185|		*(apdu_buf + block_size + data_tlv_len + le_tlv_len) = 0x80;
 1051|    185|		if ((data_tlv_len + le_tlv_len + 1) % block_size) {
  ------------------
  |  Branch (1051:7): [True: 179, False: 6]
  ------------------
 1052|    179|			mac_len = (((data_tlv_len + le_tlv_len + 1) / block_size) +
 1053|    179|					1) * block_size + block_size;
 1054|    179|		} else {
 1055|      6|			mac_len = data_tlv_len + le_tlv_len + 1 + block_size;
 1056|      6|		}
 1057|    185|		memset((apdu_buf + block_size + data_tlv_len + le_tlv_len + 1),
 1058|    185|		       0, (mac_len - (data_tlv_len + le_tlv_len + 1)));
 1059|    185|	}
 1060|       |
 1061|       |	/* increase icv */
 1062|    185|	for (; i >= 0; i--) {
  ------------------
  |  Branch (1062:9): [True: 185, False: 0]
  ------------------
 1063|    185|		if (exdata->icv_mac[i] == 0xff) {
  ------------------
  |  Branch (1063:7): [True: 0, False: 185]
  ------------------
 1064|      0|			exdata->icv_mac[i] = 0;
 1065|    185|		} else {
 1066|    185|			exdata->icv_mac[i]++;
 1067|    185|			break;
 1068|    185|		}
 1069|    185|	}
 1070|       |
 1071|       |	/* calculate MAC */
 1072|    185|	memset(icv, 0, sizeof(icv));
 1073|    185|	memcpy(icv, exdata->icv_mac, 16);
 1074|    185|	if (KEY_TYPE_AES == key_type) {
  ------------------
  |  |   80|    185|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1074:6): [True: 28, False: 157]
  ------------------
 1075|     28|		if (exdata->bFipsCertification) {
  ------------------
  |  Branch (1075:7): [True: 0, False: 28]
  ------------------
 1076|      0|			for (int i = 0; i < 16; i++) {
  ------------------
  |  Branch (1076:20): [True: 0, False: 0]
  ------------------
 1077|      0|				apdu_buf[i] = apdu_buf[i] ^ icv[i];
 1078|      0|			}
 1079|      0|			r = aes128_encrypt_cmac(card, exdata->sk_mac, 128, apdu_buf, data_tlv_len + le_tlv_len + block_size, mac);
 1080|      0|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cmac 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1081|      0|			memcpy(mac_tlv + 2, &mac[0 /*ulmacLen-16*/], 8);
 1082|      0|			for (int j = 0; j < 4; j++) {
  ------------------
  |  Branch (1082:20): [True: 0, False: 0]
  ------------------
 1083|      0|				apdu_buf[j] = apdu_buf[j] ^ icv[j];
 1084|      0|			}
 1085|     28|		} else {
 1086|     28|			r = aes128_encrypt_cbc(card, exdata->sk_mac, 16, icv, apdu_buf, mac_len, mac);
 1087|     28|			LOG_TEST_RET(card->ctx, r, "aes128_encrypt_cbc 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: 0, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  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|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1088|     28|			memcpy(mac_tlv + 2, &mac[mac_len - 16], 8);
 1089|     28|		}
 1090|    157|	} else {
 1091|    157|		unsigned char iv[EVP_MAX_IV_LENGTH] = {0};
 1092|    157|		unsigned char tmp[8] = {0};
 1093|    157|		r = des_encrypt_cbc(card, exdata->sk_mac, 8, icv, apdu_buf, mac_len, mac);
 1094|    157|		LOG_TEST_RET(card->ctx, r, "des_encrypt_cbc 1 failed");
  ------------------
  |  |  174|    157|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    157|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    157|	int _ret = (r); \
  |  |  |  |  168|    157|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 157]
  |  |  |  |  ------------------
  |  |  |  |  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|    157|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 157]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1095|    157|		r = des_decrypt_cbc(card, &exdata->sk_mac[8], 8, iv, &mac[mac_len - 8], 8, tmp);
 1096|    157|		LOG_TEST_RET(card->ctx, r, "des_decrypt_cbc failed");
  ------------------
  |  |  174|    157|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    157|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    157|	int _ret = (r); \
  |  |  |  |  168|    157|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 157]
  |  |  |  |  ------------------
  |  |  |  |  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|    157|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 157]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1097|    157|		memset(iv, 0x00, sizeof iv);
 1098|    157|		r = des_encrypt_cbc(card, exdata->sk_mac, 8, iv, tmp, 8, mac_tlv + 2);
 1099|    157|		LOG_TEST_RET(card->ctx, r, "des_encrypt_cbc 2 failed");
  ------------------
  |  |  174|    157|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    157|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    157|	int _ret = (r); \
  |  |  |  |  168|    157|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 157]
  |  |  |  |  ------------------
  |  |  |  |  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|    157|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 157]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|    157|	}
 1101|       |
 1102|    185|	*mac_tlv_len = 2 + 8;
 1103|    185|	return 0;
 1104|    185|}
card-epass2003.c:epass2003_sm_free_wrapped_apdu:
 1533|    368|{
 1534|    368|	struct sc_context *ctx = card->ctx;
 1535|    368|	int rv = SC_SUCCESS;
  ------------------
  |  |   28|    368|#define SC_SUCCESS				0
  ------------------
 1536|       |
 1537|    368|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    368|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    368|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    368|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    368|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 368]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1538|    368|	if (!sm_apdu)
  ------------------
  |  Branch (1538:6): [True: 0, False: 368]
  ------------------
 1539|    368|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1540|    368|	if (!(*sm_apdu))
  ------------------
  |  Branch (1540:6): [True: 0, False: 368]
  ------------------
 1541|    368|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1542|       |
 1543|       |
 1544|    368|	if (plain)
  ------------------
  |  Branch (1544:6): [True: 368, False: 0]
  ------------------
 1545|    368|		rv = epass2003_sm_unwrap_apdu(card, *sm_apdu, plain);
 1546|       |
 1547|    368|	if ((*sm_apdu)->data) {
  ------------------
  |  Branch (1547:6): [True: 368, False: 0]
  ------------------
 1548|    368|		unsigned char * p = (unsigned char *)((*sm_apdu)->data);
 1549|    368|		free(p);
 1550|    368|	}
 1551|    368|	if ((*sm_apdu)->resp) {
  ------------------
  |  Branch (1551:6): [True: 368, False: 0]
  ------------------
 1552|    368|		free((*sm_apdu)->resp);
 1553|    368|	}
 1554|       |
 1555|    368|	free(*sm_apdu);
 1556|    368|	*sm_apdu = NULL;
 1557|       |
 1558|    368|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    368|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    368|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    368|	int _ret = r; \
  |  |  |  |  155|    368|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 368, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    368|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    185|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 185, False: 183]
  |  |  |  |  ------------------
  |  |  |  |  157|    368|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    368|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    368|	return _ret; \
  |  |  |  |  163|    368|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1559|    368|}
card-epass2003.c:epass2003_sm_unwrap_apdu:
 1488|    368|{
 1489|    368|	int r;
 1490|    368|	size_t len = 0;
 1491|    368|	epass2003_exdata *exdata = NULL;
 1492|       |
 1493|    368|	if (!card->drv_data)
  ------------------
  |  Branch (1493:6): [True: 0, False: 368]
  ------------------
 1494|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1495|       |
 1496|    368|	exdata = (epass2003_exdata *)card->drv_data;
 1497|       |
 1498|    368|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    368|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    368|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    368|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    368|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 368]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1499|       |
 1500|       |	/* verify MAC, and check if SW1,2 match SW1,2 encapsulated in SM */
 1501|    368|	if (exdata->sm) {
  ------------------
  |  Branch (1501:6): [True: 185, False: 183]
  ------------------
 1502|    185|		if (epass2003_check_response_mac_and_sw(card, sm)) {
  ------------------
  |  Branch (1502:7): [True: 185, False: 0]
  ------------------
 1503|    185|			sc_log(card->ctx, "MAC or SW incorrect");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1504|    185|			return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|    185|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1505|    185|		}
 1506|    185|	}
 1507|    183|	r = sc_check_sw(card, sm->sw1, sm->sw2);
 1508|    183|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    183|#define SC_SUCCESS				0
  ------------------
  |  Branch (1508:6): [True: 116, False: 67]
  ------------------
 1509|    116|		if (exdata->sm) {
  ------------------
  |  Branch (1509:7): [True: 0, False: 116]
  ------------------
 1510|      0|			len = plain->resplen;
 1511|      0|			if (0 != decrypt_response(card, sm->resp, sm->resplen, plain->resp, &len))
  ------------------
  |  Branch (1511:8): [True: 0, False: 0]
  ------------------
 1512|      0|				return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|      0|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 1513|    116|		} else {
 1514|    116|			memcpy(plain->resp, sm->resp, sm->resplen);
 1515|    116|			len = sm->resplen;
 1516|    116|		}
 1517|    116|	}
 1518|       |
 1519|    183|	plain->resplen = len;
 1520|    183|	plain->sw1 = sm->sw1;
 1521|    183|	plain->sw2 = sm->sw2;
 1522|       |
 1523|    183|	sc_log(card->ctx,
  ------------------
  |  |   71|    183|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1524|    183|	       "unwrapped APDU: resplen %"SC_FORMAT_LEN_SIZE_T"u, SW %02X%02X",
 1525|    183|	       plain->resplen, plain->sw1, plain->sw2);
 1526|    183|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 183]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1527|    183|}
card-epass2003.c:epass2003_check_response_mac_and_sw:
 1325|    185|{
 1326|    185|	unsigned char iv[16];
 1327|    185|	unsigned char *data = NULL, *mac = NULL;
 1328|    185|	size_t blocksize, mac_len;
 1329|    185|	int ret = -1;
 1330|    185|	size_t taglen;
 1331|    185|	const u8 *tag;
 1332|    185|	epass2003_exdata *exdata;
 1333|    185|	unsigned char *in = sm->resp;
 1334|    185|	unsigned char *alt_in;
 1335|    185|	size_t inlen = sm->resplen;
 1336|    185|	size_t len_correction;
 1337|       |
 1338|       |	/* card/ctx/drv_data is already checked by caller */
 1339|    185|	exdata = (epass2003_exdata *)card->drv_data;
 1340|       |
 1341|       |	/* The SM must contain at least TLV encoded SW and MAC fields. */
 1342|    185|	if (inlen < 14 )
  ------------------
  |  Branch (1342:6): [True: 89, False: 96]
  ------------------
 1343|     89|		return ret;
 1344|       |
 1345|       |	/* compare BER-TLV encoded SW (TAG 0x99) and raw SW */
 1346|     96|	alt_in = in;
 1347|     96|	tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x99, &taglen);
 1348|     96|	if (tag == NULL || taglen != 2) {
  ------------------
  |  Branch (1348:6): [True: 96, False: 0]
  |  Branch (1348:21): [True: 0, False: 0]
  ------------------
 1349|       |		/*
 1350|       |		 * It seems that the EPASS2003 firmware has some problem with BER-TLV encoding.
 1351|       |		 * Instead of (correct) TLV 87 81 81 [01 .. ..] incorrect TLV 87 81 [01 .. ..]
 1352|       |		 * is returned. There seems to be some proprietary fix for the faulty encoding
 1353|       |		 * in the decrypt_response() function, similar fix here:
 1354|       |		 */
 1355|     96|		if (0x01 == in[2] && 0x82 != in[1]) {
  ------------------
  |  Branch (1355:7): [True: 44, False: 52]
  |  Branch (1355:24): [True: 35, False: 9]
  ------------------
 1356|     35|			sc_log(card->ctx, "Workaround, wrong BER-TLV ?");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1357|     35|			len_correction = in[1] + 2;
 1358|     35|			if (inlen < len_correction)
  ------------------
  |  Branch (1358:8): [True: 7, False: 28]
  ------------------
 1359|      7|				return ret;
 1360|     28|			inlen -= len_correction;
 1361|     28|			alt_in += len_correction;
 1362|     28|			tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x99, &taglen);
 1363|     28|			if (tag == NULL || taglen != 2)
  ------------------
  |  Branch (1363:8): [True: 25, False: 3]
  |  Branch (1363:23): [True: 3, False: 0]
  ------------------
 1364|     28|				return ret;
 1365|     61|		} else {
 1366|     61|			return ret;
 1367|     61|		}
 1368|     96|	}
 1369|      0|	if (sm->sw1 != tag[0] || sm->sw2 != tag[1])
  ------------------
  |  Branch (1369:6): [True: 0, False: 0]
  |  Branch (1369:27): [True: 0, False: 0]
  ------------------
 1370|      0|		return ret;
 1371|       |
 1372|       |	/* no documentation/real hardware to test, the response is accepted without MAC check */
 1373|      0|	if (exdata->bFipsCertification) {
  ------------------
  |  Branch (1373:6): [True: 0, False: 0]
  ------------------
 1374|      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__
  |  |  ------------------
  ------------------
 1375|      0|		return 0;
 1376|      0|	}
 1377|      0|	tag = sc_asn1_find_tag(card->ctx, alt_in, inlen, 0x8e, &taglen);
 1378|      0|	if (tag == NULL || taglen != 8)
  ------------------
  |  Branch (1378:6): [True: 0, False: 0]
  |  Branch (1378:21): [True: 0, False: 0]
  ------------------
 1379|      0|		return ret;
 1380|       |
 1381|      0|	if (KEY_TYPE_AES == exdata->smtype)
  ------------------
  |  |   80|      0|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1381:6): [True: 0, False: 0]
  ------------------
 1382|      0|		blocksize = 16;
 1383|      0|	else
 1384|      0|		blocksize = 8;
 1385|       |
 1386|      0|	mac_len = tag - in - 2;
 1387|      0|	if (NULL == (data = calloc(1, mac_len + blocksize)))
  ------------------
  |  Branch (1387:6): [True: 0, False: 0]
  ------------------
 1388|      0|		goto end;
 1389|      0|	if (NULL == (mac = malloc(mac_len + blocksize)))
  ------------------
  |  Branch (1389:6): [True: 0, False: 0]
  ------------------
 1390|      0|		goto end;
 1391|       |
 1392|       |	/* copy response to buffer and append padding */
 1393|      0|	memcpy(data, in, mac_len);
 1394|      0|	data[mac_len++] = 0x80;
 1395|       |
 1396|      0|	if (mac_len % blocksize)
  ------------------
  |  Branch (1396:6): [True: 0, False: 0]
  ------------------
 1397|      0|		mac_len += (blocksize - (mac_len % blocksize));
 1398|       |
 1399|       |	/* calculate MAC */
 1400|      0|	memcpy(iv, exdata->icv_mac, blocksize);
 1401|       |
 1402|      0|	if (KEY_TYPE_AES == exdata->smtype) {
  ------------------
  |  |   80|      0|#define KEY_TYPE_AES	0x01	/* FIPS mode */
  ------------------
  |  Branch (1402:6): [True: 0, False: 0]
  ------------------
 1403|      0|		if (aes128_encrypt_cbc(card, exdata->sk_mac, 16, iv, data, mac_len, mac))
  ------------------
  |  Branch (1403:7): [True: 0, False: 0]
  ------------------
 1404|      0|			goto end;
 1405|      0|	} else {
 1406|      0|		uint8_t tmp[8];
 1407|      0|		uint8_t iv0[EVP_MAX_IV_LENGTH];
 1408|      0|		if (des_encrypt_cbc(card, exdata->sk_mac, 8, iv, data, mac_len, mac))
  ------------------
  |  Branch (1408:7): [True: 0, False: 0]
  ------------------
 1409|      0|			goto end;
 1410|      0|		memset(iv0, 0, EVP_MAX_IV_LENGTH);
 1411|      0|		if (des_decrypt_cbc(card, &exdata->sk_mac[8], 8, iv0, &mac[mac_len - 8], 8, tmp))
  ------------------
  |  Branch (1411:7): [True: 0, False: 0]
  ------------------
 1412|      0|			goto end;
 1413|      0|		memset(iv0, 0, EVP_MAX_IV_LENGTH);
 1414|      0|		if (des_encrypt_cbc(card, exdata->sk_mac, 8, iv0, tmp, 8, &mac[mac_len - 8]))
  ------------------
  |  Branch (1414:7): [True: 0, False: 0]
  ------------------
 1415|      0|			goto end;
 1416|      0|	}
 1417|       |	/* compare MAC */
 1418|      0|	if (!memcmp(tag, mac + mac_len - blocksize, 8))
  ------------------
  |  Branch (1418:6): [True: 0, False: 0]
  ------------------
 1419|      0|		ret = 0;
 1420|      0|end:
 1421|      0|	if (data)
  ------------------
  |  Branch (1421:6): [True: 0, False: 0]
  ------------------
 1422|      0|		free(data);
 1423|      0|	if (mac)
  ------------------
  |  Branch (1423:6): [True: 0, False: 0]
  ------------------
 1424|      0|		free(mac);
 1425|      0|	return ret;
 1426|      0|}
card-epass2003.c:epass2003_finish:
 1758|    121|{
 1759|    121|	epass2003_exdata *exdata = (epass2003_exdata *)card->drv_data;
 1760|       |
 1761|    121|	if (exdata)
  ------------------
  |  Branch (1761:6): [True: 121, False: 0]
  ------------------
 1762|    121|		free(exdata);
 1763|    121|	return SC_SUCCESS;
  ------------------
  |  |   28|    121|#define SC_SUCCESS				0
  ------------------
 1764|    121|}
card-epass2003.c:epass2003_select_file:
 2004|  1.44k|{
 2005|  1.44k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.44k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.44k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.44k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.44k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.44k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2006|       |
 2007|  1.44k|	switch (in_path->type) {
 2008|     62|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|     62|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (2008:2): [True: 62, False: 1.38k]
  ------------------
 2009|     62|		if (in_path->len != 2)
  ------------------
  |  Branch (2009:7): [True: 12, False: 50]
  ------------------
 2010|     62|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2011|     50|		return epass2003_select_fid(card, in_path->value[0], in_path->value[1], file_out);
 2012|    249|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|    249|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (2012:2): [True: 249, False: 1.19k]
  ------------------
 2013|    249|		return epass2003_select_aid(card, in_path, file_out);
 2014|  1.13k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  1.13k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (2014:2): [True: 1.13k, False: 311]
  ------------------
 2015|  1.13k|		return epass2003_select_path(card, in_path->value, in_path->len, file_out);
 2016|      0|	default:
  ------------------
  |  Branch (2016:2): [True: 0, False: 1.44k]
  ------------------
 2017|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2018|  1.44k|	}
 2019|  1.44k|}
card-epass2003.c:epass2003_select_fid:
 1917|  1.90k|{
 1918|  1.90k|	int r;
 1919|  1.90k|	sc_file_t *file = NULL;
 1920|  1.90k|	sc_path_t path;
 1921|       |
 1922|  1.90k|	memset(&path, 0, sizeof(path));
 1923|  1.90k|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  1.90k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1924|  1.90k|	path.value[0] = id_hi;
 1925|  1.90k|	path.value[1] = id_lo;
 1926|  1.90k|	path.len = 2;
 1927|       |
 1928|  1.90k|	r = epass2003_select_fid_(card, &path, &file);
 1929|  1.90k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.90k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.90k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.90k|	int _ret = (r); \
  |  |  |  |  168|  1.90k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 648, False: 1.25k]
  |  |  |  |  ------------------
  |  |  |  |  169|    648|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    648|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    648|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    648|		return _ret; \
  |  |  |  |  172|    648|	} \
  |  |  |  |  173|  1.90k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.25k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1930|       |
 1931|  1.25k|	if (file_out) {
  ------------------
  |  Branch (1931:6): [True: 367, False: 887]
  ------------------
 1932|    367|		*file_out = file;
 1933|    887|	} else {
 1934|    887|		sc_file_free(file);
 1935|    887|	}
 1936|       |
 1937|  1.25k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.25k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.25k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.25k|	int _ret = r; \
  |  |  |  |  155|  1.25k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.25k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.25k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.25k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.25k|	return _ret; \
  |  |  |  |  163|  1.25k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1938|  1.25k|}
card-epass2003.c:epass2003_select_fid_:
 1822|  1.90k|{
 1823|  1.90k|	struct sc_apdu apdu;
 1824|  1.90k|	u8 buf[SC_MAX_APDU_BUFFER_SIZE] = {0};
 1825|  1.90k|	u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
 1826|  1.90k|	int r;
 1827|  1.90k|	size_t pathlen;
 1828|  1.90k|	sc_file_t *file = NULL;
 1829|       |
 1830|  1.90k|	r = epass2003_hook_path(in_path, 1);
 1831|  1.90k|	LOG_TEST_RET(card->ctx, r, "Can not hook path");
  ------------------
  |  |  174|  1.90k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.90k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.90k|	int _ret = (r); \
  |  |  |  |  168|  1.90k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.90k]
  |  |  |  |  ------------------
  |  |  |  |  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.90k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.90k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1832|       |
 1833|  1.90k|	memcpy(path, in_path->value, in_path->len);
 1834|  1.90k|	pathlen = in_path->len;
 1835|       |
 1836|  1.90k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  1.90k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1837|       |
 1838|  1.90k|	switch (in_path->type) {
 1839|  1.90k|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|  1.90k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1839:2): [True: 1.90k, False: 0]
  ------------------
 1840|  1.90k|		apdu.p1 = 0;
 1841|  1.90k|		if (pathlen != 2)
  ------------------
  |  Branch (1841:7): [True: 0, False: 1.90k]
  ------------------
 1842|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1843|  1.90k|		break;
 1844|  1.90k|	default:
  ------------------
  |  Branch (1844:2): [True: 0, False: 1.90k]
  ------------------
 1845|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1846|  1.90k|	}
 1847|  1.90k|	apdu.p2 = 0;		/* first record, return FCI */
 1848|  1.90k|	apdu.lc = pathlen;
 1849|  1.90k|	apdu.data = path;
 1850|  1.90k|	apdu.datalen = pathlen;
 1851|       |
 1852|  1.90k|	if (file_out != NULL) {
  ------------------
  |  Branch (1852:6): [True: 1.90k, False: 0]
  ------------------
 1853|  1.90k|		apdu.resp = buf;
 1854|  1.90k|		apdu.resplen = sizeof(buf);
 1855|  1.90k|		apdu.le = 0;
 1856|  1.90k|	} else {
 1857|      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 (1857:14): [True: 0, False: 0]
  ------------------
 1858|      0|	}
 1859|       |
 1860|  1.90k|	if (path[0] == 0x29) {	/* TODO:0x29 accords with FID prefix in profile  */
  ------------------
  |  Branch (1860:6): [True: 330, False: 1.57k]
  ------------------
 1861|       |		/* Not allowed to select private key file, so fake fci. */
 1862|       |		/* 62 16 82 02 11 00 83 02 29 00 85 02 08 00 86 08 FF 90 90 90 FF FF FF FF */
 1863|    330|		apdu.resplen = 0x18;
 1864|    330|		memcpy(apdu.resp,
 1865|    330|		       "\x6f\x16\x82\x02\x11\x00\x83\x02\x29\x00\x85\x02\x08\x00\x86\x08\xff\x90\x90\x90\xff\xff\xff\xff",
 1866|    330|		       apdu.resplen);
 1867|    330|		apdu.resp[9] = path[1];
 1868|    330|		apdu.sw1 = 0x90;
 1869|    330|		apdu.sw2 = 0x00;
 1870|    330|	}
 1871|  1.57k|	else {
 1872|  1.57k|		r = sc_transmit_apdu_t(card, &apdu);
 1873|  1.57k|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.57k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.57k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.57k|	int _ret = (r); \
  |  |  |  |  168|  1.57k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 174, False: 1.39k]
  |  |  |  |  ------------------
  |  |  |  |  169|    174|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    174|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    174|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    174|		return _ret; \
  |  |  |  |  172|    174|	} \
  |  |  |  |  173|  1.57k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.39k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1874|  1.57k|	}
 1875|       |
 1876|  1.72k|	if (file_out == NULL) {
  ------------------
  |  Branch (1876:6): [True: 0, False: 1.72k]
  ------------------
 1877|      0|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (1877:7): [True: 0, False: 0]
  ------------------
 1878|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1879|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1880|      0|	}
 1881|       |
 1882|  1.72k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1883|  1.72k|	if (r)
  ------------------
  |  Branch (1883:6): [True: 369, False: 1.35k]
  ------------------
 1884|  1.72k|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    369|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    369|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    369|	int _ret = r; \
  |  |  |  |  155|    369|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 369, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    369|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    369|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 369, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    369|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    369|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    369|	return _ret; \
  |  |  |  |  163|    369|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1885|  1.35k|	if (apdu.resplen < 2)
  ------------------
  |  Branch (1885:6): [True: 81, False: 1.27k]
  ------------------
 1886|  1.35k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|     81|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (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|     81|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1887|       |
 1888|  1.27k|	switch (apdu.resp[0]) {
 1889|  1.25k|	case 0x6F:
  ------------------
  |  Branch (1889:2): [True: 1.25k, False: 24]
  ------------------
 1890|  1.25k|		file = sc_file_new();
 1891|  1.25k|		if (file == NULL)
  ------------------
  |  Branch (1891:7): [True: 0, False: 1.25k]
  ------------------
 1892|  1.25k|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1893|  1.25k|		file->path = *in_path;
 1894|  1.25k|		if (card->ops->process_fci == NULL) {
  ------------------
  |  Branch (1894:7): [True: 0, False: 1.25k]
  ------------------
 1895|      0|			sc_file_free(file);
 1896|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1897|      0|		}
 1898|       |
 1899|  1.25k|		if ((size_t) apdu.resp[1] + 2 <= apdu.resplen)
  ------------------
  |  Branch (1899:7): [True: 1.18k, False: 74]
  ------------------
 1900|  1.18k|			card->ops->process_fci(card, file, apdu.resp + 2, apdu.resp[1]);
 1901|  1.25k|		epass2003_hook_file(file, 0);
 1902|  1.25k|		*file_out = file;
 1903|  1.25k|		break;
 1904|      2|	case 0x00:		/* proprietary coding */
  ------------------
  |  Branch (1904:2): [True: 2, False: 1.27k]
  ------------------
 1905|      2|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1906|      0|		break;
 1907|     22|	default:
  ------------------
  |  Branch (1907:2): [True: 22, False: 1.25k]
  ------------------
 1908|     22|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1909|  1.27k|	}
 1910|  1.25k|	return 0;
 1911|  1.27k|}
card-epass2003.c:epass2003_hook_path:
 1770|  3.39k|{
 1771|  3.39k|	u8 fid_h = 0;
 1772|  3.39k|	u8 fid_l = 0;
 1773|       |
 1774|  3.39k|	if (!path || path->len < 2)
  ------------------
  |  Branch (1774:6): [True: 0, False: 3.39k]
  |  Branch (1774:15): [True: 0, False: 3.39k]
  ------------------
 1775|      0|		return -1;
 1776|  3.39k|	fid_h = path->value[path->len - 2];
 1777|  3.39k|	fid_l = path->value[path->len - 1];
 1778|       |
 1779|  3.39k|	switch (fid_h) {
 1780|    781|	case 0x29:
  ------------------
  |  Branch (1780:2): [True: 781, False: 2.61k]
  ------------------
 1781|    834|	case 0x30:
  ------------------
  |  Branch (1781:2): [True: 53, False: 3.34k]
  ------------------
 1782|  1.04k|	case 0x31:
  ------------------
  |  Branch (1782:2): [True: 208, False: 3.18k]
  ------------------
 1783|  1.14k|	case 0x32:
  ------------------
  |  Branch (1783:2): [True: 103, False: 3.29k]
  ------------------
 1784|  1.17k|	case 0x33:
  ------------------
  |  Branch (1784:2): [True: 32, False: 3.36k]
  ------------------
 1785|  1.22k|	case 0x34:
  ------------------
  |  Branch (1785:2): [True: 51, False: 3.34k]
  ------------------
 1786|  1.22k|		if (inc)
  ------------------
  |  Branch (1786:7): [True: 659, False: 569]
  ------------------
 1787|    659|			fid_l = fid_l * FID_STEP;
  ------------------
  |  |  741|    659|#define FID_STEP 0x20
  ------------------
 1788|    569|		else
 1789|    569|			fid_l = fid_l / FID_STEP;
  ------------------
  |  |  741|    569|#define FID_STEP 0x20
  ------------------
 1790|  1.22k|		path->value[path->len - 1] = fid_l;
 1791|  1.22k|		return 1;
 1792|  2.16k|	default:
  ------------------
  |  Branch (1792:2): [True: 2.16k, False: 1.22k]
  ------------------
 1793|  2.16k|		break;
 1794|  3.39k|	}
 1795|  2.16k|	return 0;
 1796|  3.39k|}
card-epass2003.c:epass2003_hook_file:
 1801|  1.41k|{
 1802|  1.41k|	int fidl = file->id & 0xff;
 1803|  1.41k|	int fidh = file->id & 0xff00;
 1804|  1.41k|	int rv = 0;
 1805|       |
 1806|  1.41k|	rv = epass2003_hook_path(&file->path, inc);
 1807|       |
 1808|  1.41k|	if (rv > 0) {
  ------------------
  |  Branch (1808:6): [True: 617, False: 801]
  ------------------
 1809|    617|		if (inc)
  ------------------
  |  Branch (1809:7): [True: 48, False: 569]
  ------------------
 1810|     48|			file->id = fidh + fidl * FID_STEP;
  ------------------
  |  |  741|     48|#define FID_STEP 0x20
  ------------------
 1811|    569|		else
 1812|    569|			file->id = fidh + fidl / FID_STEP;
  ------------------
  |  |  741|    569|#define FID_STEP 0x20
  ------------------
 1813|    617|	}
 1814|  1.41k|	if (rv < 0)
  ------------------
  |  Branch (1814:6): [True: 0, False: 1.41k]
  ------------------
 1815|      0|		return rv;
 1816|  1.41k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.41k|#define SC_SUCCESS				0
  ------------------
 1817|  1.41k|}
card-epass2003.c:epass2003_select_aid:
 1943|    249|{
 1944|    249|	int r = 0;
 1945|       |
 1946|    249|	r = iso_ops->select_file(card, in_path, file_out);
 1947|    249|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    249|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    249|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    249|	int _ret = (r); \
  |  |  |  |  168|    249|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 184, False: 65]
  |  |  |  |  ------------------
  |  |  |  |  169|    184|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    184|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    184|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    184|		return _ret; \
  |  |  |  |  172|    184|	} \
  |  |  |  |  173|    249|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1948|       |
 1949|     65|	if (file_out) {
  ------------------
  |  Branch (1949:6): [True: 3, False: 62]
  ------------------
 1950|      3|		sc_file_t *file = *file_out;
 1951|       |
 1952|      3|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      3|#define SC_FILE_TYPE_DF			0x04
  ------------------
 1953|      3|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      3|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
 1954|      3|		file->path.len = 0;
 1955|      3|		file->size = 0;
 1956|       |		/* AID */
 1957|      3|		memcpy(file->name, in_path->value, in_path->len);
 1958|      3|		file->namelen = in_path->len;
 1959|      3|		file->id = 0x0000;
 1960|      3|	}
 1961|       |
 1962|     65|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 65]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1963|     65|}
card-epass2003.c:epass2003_select_path:
 1969|  1.13k|{
 1970|  1.13k|	u8 n_pathbuf[SC_MAX_PATH_SIZE];
 1971|  1.13k|	const u8 *path = pathbuf;
 1972|  1.13k|	size_t pathlen = len;
 1973|  1.13k|	unsigned int i;
 1974|  1.13k|	int r;
 1975|       |
 1976|  1.13k|	if (pathlen % 2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (1976:6): [True: 0, False: 1.13k]
  |  Branch (1976:26): [True: 0, False: 1.13k]
  |  Branch (1976:41): [True: 3, False: 1.12k]
  ------------------
 1977|  1.13k|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1978|       |
 1979|       |	/* if pathlen == 6 then the first FID must be MF (== 3F00) */
 1980|  1.12k|	if (pathlen == 6 && (path[0] != 0x3f || path[1] != 0x00))
  ------------------
  |  Branch (1980:6): [True: 175, False: 953]
  |  Branch (1980:23): [True: 19, False: 156]
  |  Branch (1980:42): [True: 4, False: 152]
  ------------------
 1981|  1.12k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1982|       |
 1983|       |	/* unify path (the first FID should be MF) */
 1984|  1.10k|	if (path[0] != 0x3f || path[1] != 0x00) {
  ------------------
  |  Branch (1984:6): [True: 450, False: 655]
  |  Branch (1984:25): [True: 32, False: 623]
  ------------------
 1985|    482|		n_pathbuf[0] = 0x3f;
 1986|    482|		n_pathbuf[1] = 0x00;
 1987|    482|		memcpy(n_pathbuf + 2, path, pathlen);
 1988|    482|		path = n_pathbuf;
 1989|    482|		pathlen += 2;
 1990|    482|	}
 1991|       |
 1992|  1.85k|	for (i = 0; i < pathlen - 2; i += 2) {
  ------------------
  |  Branch (1992:14): [True: 1.27k, False: 574]
  ------------------
 1993|  1.27k|		r = epass2003_select_fid(card, path[i], path[i + 1], NULL);
 1994|  1.27k|		LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|  1.27k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.27k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.27k|	int _ret = (r); \
  |  |  |  |  168|  1.27k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 531, False: 747]
  |  |  |  |  ------------------
  |  |  |  |  169|    531|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    531|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    531|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    531|		return _ret; \
  |  |  |  |  172|    531|	} \
  |  |  |  |  173|  1.27k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 747]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1995|  1.27k|	}
 1996|       |
 1997|    574|	return epass2003_select_fid(card, path[pathlen - 2], path[pathlen - 1], file_out);
 1998|  1.10k|}
card-epass2003.c:epass2003_create_file:
 2565|     89|{
 2566|     89|	int r;
 2567|     89|	size_t len;
 2568|     89|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE] = {0};
 2569|     89|	struct sc_apdu apdu;
 2570|       |
 2571|     89|	len = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|     89|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 2572|       |
 2573|     89|	epass2003_hook_file(file, 1);
 2574|       |
 2575|     89|	if (card->ops->construct_fci == NULL)
  ------------------
  |  Branch (2575:6): [True: 0, False: 89]
  ------------------
 2576|     89|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2577|       |
 2578|     89|	r = epass2003_construct_fci(card, file, sbuf, &len);
 2579|     89|	LOG_TEST_RET(card->ctx, r, "construct_fci() 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: 4, False: 85]
  |  |  |  |  ------------------
  |  |  |  |  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|     89|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 85]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2580|       |
 2581|     85|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|     85|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2582|     85|	apdu.lc = len;
 2583|     85|	apdu.datalen = len;
 2584|     85|	apdu.data = sbuf;
 2585|       |
 2586|     85|	r = sc_transmit_apdu_t(card, &apdu);
 2587|     85|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     85|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     85|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     85|	int _ret = (r); \
  |  |  |  |  168|     85|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 85]
  |  |  |  |  ------------------
  |  |  |  |  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|     85|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 85]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2588|     85|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2589|     85|	LOG_TEST_RET(card->ctx, r, "APDU sw1/2 wrong");
  ------------------
  |  |  174|     85|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     85|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     85|	int _ret = (r); \
  |  |  |  |  168|     85|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 75]
  |  |  |  |  ------------------
  |  |  |  |  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|     85|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 75]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2590|       |
 2591|     75|	epass2003_hook_file(file, 0);
 2592|     75|	return r;
 2593|     85|}
card-epass2003.c:epass2003_delete_file:
 2598|    131|{
 2599|    131|	int r;
 2600|    131|	u8 sbuf[2];
 2601|    131|	struct sc_apdu apdu;
 2602|       |
 2603|    131|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    131|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    131|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    131|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    131|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 131]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2604|       |
 2605|    131|	r = sc_select_file(card, path, NULL);
 2606|    131|	LOG_TEST_RET(card->ctx, r, "Can not select file");
  ------------------
  |  |  174|    131|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    131|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    131|	int _ret = (r); \
  |  |  |  |  168|    131|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 56, False: 75]
  |  |  |  |  ------------------
  |  |  |  |  169|     56|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     56|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     56|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     56|		return _ret; \
  |  |  |  |  172|     56|	} \
  |  |  |  |  173|    131|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 75]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2607|     75|	r = epass2003_hook_path((struct sc_path *)path, 1);
 2608|     75|	LOG_TEST_RET(card->ctx, r, "Can not hook path");
  ------------------
  |  |  174|     75|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     75|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     75|	int _ret = (r); \
  |  |  |  |  168|     75|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 75]
  |  |  |  |  ------------------
  |  |  |  |  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|     75|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 75]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2609|       |
 2610|     75|	sbuf[0] = path->value[path->len - 2];
 2611|     75|	sbuf[1] = path->value[path->len - 1];
 2612|     75|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
  ------------------
  |  |  293|     75|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2613|     75|	apdu.lc = 2;
 2614|     75|	apdu.datalen = 2;
 2615|     75|	apdu.data = sbuf;
 2616|       |
 2617|     75|	r = sc_transmit_apdu_t(card, &apdu);
 2618|     75|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     75|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     75|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     75|	int _ret = (r); \
  |  |  |  |  168|     75|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 75]
  |  |  |  |  ------------------
  |  |  |  |  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|     75|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 75]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2619|     75|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2620|     75|	LOG_TEST_RET(card->ctx, r, "Delete file failed");
  ------------------
  |  |  174|     75|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     75|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     75|	int _ret = (r); \
  |  |  |  |  168|     75|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 13, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  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|     75|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2621|       |
 2622|     62|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2623|     62|}
card-epass2003.c:epass2003_card_ctl:
 3009|    250|{
 3010|    250|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    250|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    250|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    250|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    250|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 250]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3011|       |
 3012|    250|	sc_log(card->ctx, "cmd is %0lx", cmd);
  ------------------
  |  |   71|    250|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3013|    250|	switch (cmd) {
 3014|      0|	case SC_CARDCTL_ENTERSAFE_WRITE_KEY:
  ------------------
  |  Branch (3014:2): [True: 0, False: 250]
  ------------------
 3015|      0|		return epass2003_write_key(card, (sc_epass2003_wkey_data *) ptr);
 3016|      9|	case SC_CARDCTL_ENTERSAFE_GENERATE_KEY:
  ------------------
  |  Branch (3016:2): [True: 9, False: 241]
  ------------------
 3017|      9|		return epass2003_gen_key(card, (sc_epass2003_gen_key_data *) ptr);
 3018|      6|	case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (3018:2): [True: 6, False: 244]
  ------------------
 3019|      6|		return epass2003_erase_card(card);
 3020|     26|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (3020:2): [True: 26, False: 224]
  ------------------
 3021|     26|		return epass2003_get_serialnr(card, (sc_serial_number_t *) ptr);
 3022|    209|	default:
  ------------------
  |  Branch (3022:2): [True: 209, False: 41]
  ------------------
 3023|    209|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    209|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 3024|    250|	}
 3025|    250|}
card-epass2003.c:epass2003_gen_key:
 2839|      9|{
 2840|      9|	int r;
 2841|      9|	size_t len = data->key_length;
 2842|      9|	struct sc_apdu apdu;
 2843|      9|	u8 rbuf[SC_MAX_EXT_APDU_BUFFER_SIZE] = {0};
 2844|      9|	u8 sbuf[SC_MAX_EXT_APDU_BUFFER_SIZE] = {0};
 2845|       |
 2846|      9|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|      9|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|      9|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|      9|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|      9|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2847|       |
 2848|      9|	if (len == 256) {
  ------------------
  |  Branch (2848:6): [True: 4, False: 5]
  ------------------
 2849|      4|		sbuf[0] = 0x02;
 2850|      5|	} else {
 2851|      5|		sbuf[0] = 0x01;
 2852|      5|	}
 2853|      9|	sbuf[1] = (u8) ((len >> 8) & 0xff);
 2854|      9|	sbuf[2] = (u8) (len & 0xff);
 2855|      9|	sbuf[3] = (u8) ((data->prkey_id >> 8) & 0xFF);
 2856|      9|	sbuf[4] = (u8) ((data->prkey_id) & 0xFF);
 2857|      9|	sbuf[5] = (u8) ((data->pukey_id >> 8) & 0xFF);
 2858|      9|	sbuf[6] = (u8) ((data->pukey_id) & 0xFF);
 2859|       |
 2860|       |	/* generate key */
 2861|      9|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x46, 0x00, 0x00);
  ------------------
  |  |  293|      9|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2862|      9|	apdu.lc = apdu.datalen = 7;
 2863|      9|	apdu.data = sbuf;
 2864|       |
 2865|      9|	r = sc_transmit_apdu_t(card, &apdu);
 2866|      9|	LOG_TEST_RET(card->ctx, r, "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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2867|      9|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2868|      9|	LOG_TEST_RET(card->ctx, r, "generate key pair 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2869|       |
 2870|       |	/* read public key */
 2871|      9|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xb4, 0x02, 0x00);
  ------------------
  |  |  293|      9|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 2872|      9|	if (len == 256) {
  ------------------
  |  Branch (2872:6): [True: 4, False: 5]
  ------------------
 2873|      4|		apdu.p1 = 0x00;
 2874|      4|	}
 2875|       |
 2876|      9|	apdu.cla = 0x80;
 2877|      9|	apdu.lc = apdu.datalen = 2;
 2878|      9|	apdu.data = &sbuf[5];
 2879|      9|	apdu.resp = rbuf;
 2880|      9|	apdu.resplen = sizeof(rbuf);
 2881|      9|	apdu.le = 0x00;
 2882|       |
 2883|      9|	r = sc_transmit_apdu_t(card, &apdu);
 2884|      9|	LOG_TEST_RET(card->ctx, r, "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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2885|      9|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2886|      9|	LOG_TEST_RET(card->ctx, r, "get pukey 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2887|       |
 2888|      8|	if (len < apdu.resplen)
  ------------------
  |  Branch (2888:6): [True: 3, False: 5]
  ------------------
 2889|      8|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2890|       |
 2891|      5|	if (256 == len) { /* ECC 256 bit */
  ------------------
  |  Branch (2891:6): [True: 1, False: 4]
  ------------------
 2892|      1|		size_t xCoordinateLen = rbuf[1];
 2893|      1|		size_t yCoordinateLen;
 2894|      1|		unsigned char *tmp;
 2895|       |
 2896|      1|		if (2 + xCoordinateLen + 1 > apdu.resplen) {
  ------------------
  |  Branch (2896:7): [True: 0, False: 1]
  ------------------
 2897|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2898|      0|		}
 2899|      1|		yCoordinateLen = rbuf[2 + xCoordinateLen + 1];
 2900|      1|		if (2 + xCoordinateLen + 2 + yCoordinateLen > apdu.resplen) {
  ------------------
  |  Branch (2900:7): [True: 1, False: 0]
  ------------------
 2901|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2902|      1|		}
 2903|      0|		data->modulus_len = xCoordinateLen + yCoordinateLen;
 2904|      0|		tmp = (u8 *)malloc(data->modulus_len);
 2905|      0|		if (!tmp) {
  ------------------
  |  Branch (2905:7): [True: 0, False: 0]
  ------------------
 2906|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2907|      0|		}
 2908|       |
 2909|      0|		if (0x58 == rbuf[0]) {
  ------------------
  |  Branch (2909:7): [True: 0, False: 0]
  ------------------
 2910|      0|			memcpy(tmp, &rbuf[2], xCoordinateLen);
 2911|      0|		} else {
 2912|      0|			free(tmp);
 2913|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2914|      0|		}
 2915|      0|		if (0x59 == rbuf[2 + xCoordinateLen]) {
  ------------------
  |  Branch (2915:7): [True: 0, False: 0]
  ------------------
 2916|      0|			memcpy(tmp + xCoordinateLen, &rbuf[2+xCoordinateLen+2], yCoordinateLen);
 2917|      0|		} else {
 2918|      0|			free(tmp);
 2919|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2920|      0|		}
 2921|       |
 2922|      0|		data->modulus = tmp;
 2923|      4|	} else {
 2924|      4|		data->modulus = (u8 *) malloc(len);
 2925|      4|		if (!data->modulus) {
  ------------------
  |  Branch (2925:7): [True: 0, False: 4]
  ------------------
 2926|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2927|      4|		} else {
 2928|      4|			memcpy(data->modulus, rbuf, len);
 2929|      4|		}
 2930|      4|	}
 2931|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2932|      4|}
card-epass2003.c:epass2003_erase_card:
 2937|      6|{
 2938|      6|	static const unsigned char install_magic_pin[26] = {
 2939|       |		/* compare install_secret_key */
 2940|      6|			0x06, 0x01, 0x10, 0x16, 0x16, 0x16, 0x00, 0x0f, 0xff, 0x66,
 2941|      6|			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
 2942|      6|			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
 2943|      6|	};
 2944|      6|	static const unsigned char magic_pin[16] = {
 2945|      6|			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
 2946|      6|			0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38,
 2947|      6|	};
 2948|      6|	static const unsigned char mf_path[2] = { 0x3f, 0x00 };
 2949|      6|	sc_apdu_t apdu;
 2950|      6|	int r;
 2951|       |
 2952|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2953|       |
 2954|       |	/* install magic pin */
 2955|      6|	sc_format_apdu(card, &apdu, 0x03, 0xe3, 0x00, 0x00);
 2956|      6|	apdu.cla = 0x80;
 2957|      6|	apdu.data = install_magic_pin;
 2958|      6|	apdu.datalen = apdu.lc = sizeof(install_magic_pin);
 2959|      6|	r = sc_transmit_apdu(card, &apdu);
 2960|      6|	LOG_TEST_RET(card->ctx, r, "APDU install magic pin 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2961|      6|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2962|      6|	LOG_TEST_RET(card->ctx, r, "install magic pin 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: 3, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|      6|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2963|       |
 2964|       |	/* verify magic pin */
 2965|      3|	sc_format_apdu(card, &apdu, 0x03, 0x20, 0x00, 0x01);
 2966|      3|	apdu.cla = 0;
 2967|      3|	apdu.data = magic_pin;
 2968|      3|	apdu.datalen = apdu.lc = sizeof(magic_pin);
 2969|      3|	r = sc_transmit_apdu(card, &apdu);
 2970|      3|	LOG_TEST_RET(card->ctx, r, "APDU verify magic pin 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: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2971|      3|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2972|      3|	LOG_TEST_RET(card->ctx, r, "verify magic pin 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2973|       |
 2974|       |	/* delete MF */
 2975|      2|	sc_format_apdu(card, &apdu, 0x03, 0xe4, 0x00, 0x00);
 2976|      2|	apdu.cla = 0;
 2977|      2|	apdu.data = mf_path;
 2978|      2|	apdu.datalen = apdu.lc = sizeof(mf_path);
 2979|      2|	r = sc_transmit_apdu(card, &apdu);
 2980|      2|	LOG_TEST_RET(card->ctx, r, "APDU delete MF 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2981|      2|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2982|      2|	LOG_TEST_RET(card->ctx, r, "delete MF 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2983|       |
 2984|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2985|      1|}
card-epass2003.c:epass2003_get_serialnr:
 2990|     26|{
 2991|     26|	u8 rbuf[8];
 2992|     26|	size_t rbuf_len = sizeof(rbuf);
 2993|       |
 2994|     26|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     26|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     26|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     26|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2995|       |
 2996|     26|	if (SC_SUCCESS != get_data(card, 0x80, rbuf, rbuf_len))
  ------------------
  |  |   28|     26|#define SC_SUCCESS				0
  ------------------
  |  Branch (2996:6): [True: 19, False: 7]
  ------------------
 2997|     19|		return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|     19|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
 2998|       |
 2999|      7|	card->serialnr.len = serial->len = 8;
 3000|      7|	memcpy(card->serialnr.value, rbuf, 8);
 3001|      7|	memcpy(serial->value, rbuf, 8);
 3002|       |
 3003|      7|	LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3004|      7|}
card-epass2003.c:epass2003_process_fci:
 2270|  1.18k|{
 2271|  1.18k|	sc_context_t *ctx = card->ctx;
 2272|  1.18k|	size_t taglen, len = buflen;
 2273|  1.18k|	const u8 *tag = NULL, *p = buf;
 2274|       |
 2275|  1.18k|	sc_log(ctx, "processing FCI bytes");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2276|  1.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
 2277|  1.18k|	if (tag != NULL && taglen == 2) {
  ------------------
  |  Branch (2277:6): [True: 350, False: 830]
  |  Branch (2277:21): [True: 337, False: 13]
  ------------------
 2278|    337|		file->id = (tag[0] << 8) | tag[1];
 2279|    337|		sc_log(ctx, "  file identifier: 0x%02X%02X", tag[0], tag[1]);
  ------------------
  |  |   71|    337|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2280|    337|	}
 2281|       |
 2282|  1.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
 2283|  1.18k|	if (tag != NULL && taglen > 0 && taglen < 3) {
  ------------------
  |  Branch (2283:6): [True: 34, False: 1.14k]
  |  Branch (2283:21): [True: 34, False: 0]
  |  Branch (2283:35): [True: 33, False: 1]
  ------------------
 2284|     33|		file->size = tag[0];
 2285|     33|		if (taglen == 2)
  ------------------
  |  Branch (2285:7): [True: 33, False: 0]
  ------------------
 2286|     33|			file->size = (file->size << 8) + tag[1];
 2287|     33|		sc_log(ctx, "  bytes in file: %"SC_FORMAT_LEN_SIZE_T"u",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2288|     33|			   file->size);
 2289|     33|	}
 2290|       |
 2291|  1.18k|	if (tag == NULL) {
  ------------------
  |  Branch (2291:6): [True: 1.14k, False: 34]
  ------------------
 2292|  1.14k|		tag = sc_asn1_find_tag(ctx, p, len, 0x81, &taglen);
 2293|  1.14k|		if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (2293:7): [True: 23, False: 1.12k]
  |  Branch (2293:22): [True: 21, False: 2]
  ------------------
 2294|     21|			int bytes = (tag[0] << 8) + tag[1];
 2295|       |
 2296|     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__
  |  |  ------------------
  ------------------
 2297|     21|			file->size = bytes;
 2298|     21|		}
 2299|  1.14k|	}
 2300|       |
 2301|  1.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
 2302|  1.18k|	if (tag != NULL) {
  ------------------
  |  Branch (2302:6): [True: 393, False: 787]
  ------------------
 2303|    393|		if (taglen > 0) {
  ------------------
  |  Branch (2303:7): [True: 393, False: 0]
  ------------------
 2304|    393|			unsigned char byte = tag[0];
 2305|    393|			const char *type;
 2306|       |
 2307|    393|			if (byte == 0x38) {
  ------------------
  |  Branch (2307:8): [True: 0, False: 393]
  ------------------
 2308|      0|				type = "DF";
 2309|      0|				file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
 2310|    393|			} else if (0x01 <= byte && byte <= 0x07) {
  ------------------
  |  Branch (2310:15): [True: 393, False: 0]
  |  Branch (2310:31): [True: 31, False: 362]
  ------------------
 2311|     31|				type = "working EF";
 2312|     31|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     31|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 2313|     31|				switch (byte) {
 2314|     15|				case 0x01:
  ------------------
  |  Branch (2314:5): [True: 15, False: 16]
  ------------------
 2315|     15|					file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     15|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 2316|     15|					break;
 2317|      4|				case 0x02:
  ------------------
  |  Branch (2317:5): [True: 4, False: 27]
  ------------------
 2318|      4|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|      4|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
 2319|      4|					break;
 2320|      0|				case 0x04:
  ------------------
  |  Branch (2320:5): [True: 0, False: 31]
  ------------------
 2321|      0|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
 2322|      0|					break;
 2323|     12|				default:
  ------------------
  |  Branch (2323:5): [True: 12, False: 19]
  ------------------
 2324|     12|					break;
 2325|     31|				}
 2326|       |
 2327|    362|			} else if (0x10 == byte) {
  ------------------
  |  Branch (2327:15): [True: 0, False: 362]
  ------------------
 2328|      0|				type = "BSO";
 2329|      0|				file->type = SC_FILE_TYPE_BSO;
  ------------------
  |  |  217|      0|#define SC_FILE_TYPE_BSO		0x10
  ------------------
 2330|    362|			} else if (0x11 <= byte) {
  ------------------
  |  Branch (2330:15): [True: 362, False: 0]
  ------------------
 2331|    362|				type = "internal EF";
 2332|    362|				file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|    362|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
 2333|    362|				switch (byte) {
 2334|    330|				case 0x11:
  ------------------
  |  Branch (2334:5): [True: 330, False: 32]
  ------------------
 2335|    330|					break;
 2336|      2|				case 0x12:
  ------------------
  |  Branch (2336:5): [True: 2, False: 360]
  ------------------
 2337|      2|					break;
 2338|     30|				default:
  ------------------
  |  Branch (2338:5): [True: 30, False: 332]
  ------------------
 2339|     30|					break;
 2340|    362|				}
 2341|    362|			} else {
 2342|      0|				type = "unknown";
 2343|      0|				file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|      0|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
 2344|      0|			}
 2345|    393|			sc_log(ctx, "type %s, EF structure %d", type, byte);
  ------------------
  |  |   71|    393|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2346|    393|		}
 2347|    393|	}
 2348|       |
 2349|  1.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x84, &taglen);
 2350|  1.18k|	if (tag != NULL && taglen > 0 && taglen <= 16) {
  ------------------
  |  Branch (2350:6): [True: 1, False: 1.17k]
  |  Branch (2350:21): [True: 1, False: 0]
  |  Branch (2350:35): [True: 1, False: 0]
  ------------------
 2351|      1|		memcpy(file->name, tag, taglen);
 2352|      1|		file->namelen = taglen;
 2353|       |
 2354|      1|		sc_log_hex(ctx, "File name", file->name, file->namelen);
  ------------------
  |  |  129|      1|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|      1|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2355|      1|		if (!file->type)
  ------------------
  |  Branch (2355:7): [True: 1, False: 0]
  ------------------
 2356|      1|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      1|#define SC_FILE_TYPE_DF			0x04
  ------------------
 2357|      1|	}
 2358|       |
 2359|  1.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x85, &taglen);
 2360|  1.18k|	if (tag != NULL && taglen)
  ------------------
  |  Branch (2360:6): [True: 351, False: 829]
  |  Branch (2360:21): [True: 351, False: 0]
  ------------------
 2361|    351|		sc_file_set_prop_attr(file, tag, taglen);
 2362|    829|	else
 2363|    829|		file->prop_attr_len = 0;
 2364|       |
 2365|  1.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0xA5, &taglen);
 2366|  1.18k|	if (tag != NULL && taglen)
  ------------------
  |  Branch (2366:6): [True: 4, False: 1.17k]
  |  Branch (2366:21): [True: 4, False: 0]
  ------------------
 2367|      4|		sc_file_set_prop_attr(file, tag, taglen);
 2368|       |
 2369|  1.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x86, &taglen);
 2370|  1.18k|	if (tag != NULL && taglen) {
  ------------------
  |  Branch (2370:6): [True: 359, False: 821]
  |  Branch (2370:21): [True: 359, False: 0]
  ------------------
 2371|    359|		unsigned int i;
 2372|    359|		sc_file_set_sec_attr(file, tag, taglen);
 2373|  3.56k|		for (i = 0; i< taglen; i++)
  ------------------
  |  Branch (2373:15): [True: 3.20k, False: 359]
  ------------------
 2374|  3.20k|			if (tag[i] != 0xff) /* skip unused entries */
  ------------------
  |  Branch (2374:8): [True: 1.37k, False: 1.83k]
  ------------------
 2375|  1.37k|				sec_attr_to_entry(card, file, i);
 2376|    359|	}
 2377|       |
 2378|  1.18k|	tag = sc_asn1_find_tag(ctx, p, len, 0x8A, &taglen);
 2379|  1.18k|	if (tag != NULL && taglen == 1) {
  ------------------
  |  Branch (2379:6): [True: 21, False: 1.15k]
  |  Branch (2379:21): [True: 21, False: 0]
  ------------------
 2380|     21|		if (tag[0] == 0x01)
  ------------------
  |  Branch (2380:7): [True: 13, False: 8]
  ------------------
 2381|     13|			file->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|     13|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
 2382|      8|		else if (tag[0] == 0x07 || tag[0] == 0x05)
  ------------------
  |  Branch (2382:12): [True: 0, False: 8]
  |  Branch (2382:30): [True: 0, False: 8]
  ------------------
 2383|      0|			file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      0|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
 2384|      8|		else if (tag[0] == 0x06 || tag[0] == 0x04)
  ------------------
  |  Branch (2384:12): [True: 0, False: 8]
  |  Branch (2384:30): [True: 0, False: 8]
  ------------------
 2385|      0|			file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|      0|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
 2386|     21|	}
 2387|  1.18k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|  1.18k|#define SC_FILE_MAGIC			0x14426950
  ------------------
 2388|       |
 2389|  1.18k|	return 0;
 2390|  1.18k|}
card-epass2003.c:epass2003_construct_fci:
 2396|     89|{
 2397|     89|	u8 *p = out;
 2398|     89|	u8 buf[64];
 2399|     89|	unsigned char ops[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
 2400|     89|	int rv;
 2401|     89|	unsigned ii;
 2402|       |
 2403|     89|	if (*outlen < 2)
  ------------------
  |  Branch (2403:6): [True: 0, False: 89]
  ------------------
 2404|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 2405|       |
 2406|     89|	*p++ = 0x62;
 2407|     89|	p++;
 2408|     89|	if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|     89|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (2408:6): [True: 0, False: 89]
  ------------------
 2409|      0|		if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (2409:7): [True: 0, False: 0]
  ------------------
 2410|      0|			buf[0] = (file->size >> 8) & 0xFF;
 2411|      0|			buf[1] = file->size & 0xFF;
 2412|      0|			sc_asn1_put_tag(0x80, buf, 2, p, *outlen - (p - out), &p);
 2413|      0|		}
 2414|      0|	}
 2415|     89|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     89|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2415:6): [True: 12, False: 77]
  ------------------
 2416|     12|		buf[0] = 0x38;
 2417|     12|		buf[1] = 0x00;
 2418|     12|		sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
 2419|     12|	}
 2420|     77|	else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|     77|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (2420:11): [True: 0, False: 77]
  ------------------
 2421|      0|		buf[0] = file->ef_structure & 7;
 2422|      0|		if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (2422:7): [True: 0, False: 0]
  ------------------
 2423|      0|			buf[1] = 0x00;
 2424|      0|			sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
 2425|      0|		} else if (file->ef_structure == SC_FILE_EF_LINEAR_FIXED ||
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (2425:14): [True: 0, False: 0]
  ------------------
 2426|      0|				file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2426:5): [True: 0, False: 0]
  ------------------
 2427|      0|			buf[1] = 0x00;
 2428|      0|			buf[2] = 0x00;
 2429|      0|			buf[3] = 0x40;	/* record length */
 2430|      0|			buf[4] = 0x00;	/* record count */
 2431|      0|			sc_asn1_put_tag(0x82, buf, 5, p, *outlen - (p - out), &p);
 2432|      0|		} else {
 2433|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2434|      0|		}
 2435|       |
 2436|      0|	}
 2437|     77|	else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|     77|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (2437:11): [True: 77, False: 0]
  ------------------
 2438|     77|		if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT ||
  ------------------
  |  Branch (2438:7): [True: 38, False: 39]
  ------------------
 2439|     66|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT) {
  ------------------
  |  Branch (2439:5): [True: 28, False: 11]
  ------------------
 2440|     66|			buf[0] = 0x11;
 2441|     66|			buf[1] = 0x00;
 2442|     66|		} else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC ||
  ------------------
  |  Branch (2442:14): [True: 5, False: 6]
  ------------------
 2443|     11|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) {
  ------------------
  |  Branch (2443:5): [True: 6, False: 0]
  ------------------
 2444|     11|			buf[0] = 0x12;
 2445|     11|			buf[1] = 0x00;
 2446|     11|		} else {
 2447|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2448|      0|		}
 2449|     77|		sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
 2450|     77|	} else if (file->type == SC_FILE_TYPE_BSO) {
  ------------------
  |  |  217|      0|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (2450:13): [True: 0, False: 0]
  ------------------
 2451|      0|		buf[0] = 0x10;
 2452|      0|		buf[1] = 0x00;
 2453|      0|		sc_asn1_put_tag(0x82, buf, 2, p, *outlen - (p - out), &p);
 2454|      0|	}
 2455|       |
 2456|     89|	buf[0] = (file->id >> 8) & 0xFF;
 2457|     89|	buf[1] = file->id & 0xFF;
 2458|     89|	sc_asn1_put_tag(0x83, buf, 2, p, *outlen - (p - out), &p);
 2459|     89|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     89|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2459:6): [True: 12, False: 77]
  ------------------
 2460|     12|		if (file->namelen != 0) {
  ------------------
  |  Branch (2460:7): [True: 8, False: 4]
  ------------------
 2461|      8|			sc_asn1_put_tag(0x84, file->name, file->namelen, p, *outlen - (p - out), &p);
 2462|      8|		} else {
 2463|      4|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      4|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2464|      4|		}
 2465|     12|	}
 2466|     85|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     85|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2466:6): [True: 8, False: 77]
  ------------------
 2467|      8|		unsigned char data[2] = {0x00, 0x7F};
 2468|       |		/* 127 files at most */
 2469|      8|		sc_asn1_put_tag(0x85, data, sizeof(data), p, *outlen - (p - out), &p);
 2470|     77|	} else if (file->type == SC_FILE_TYPE_BSO) {
  ------------------
  |  |  217|     77|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (2470:13): [True: 0, False: 77]
  ------------------
 2471|      0|		buf[0] = file->size & 0xff;
 2472|      0|		sc_asn1_put_tag(0x85, buf, 1, p, *outlen - (p - out), &p);
 2473|     77|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|     77|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (2473:13): [True: 77, False: 0]
  ------------------
 2474|     77|		if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT ||
  ------------------
  |  Branch (2474:7): [True: 38, False: 39]
  ------------------
 2475|     39|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC ||
  ------------------
  |  Branch (2475:5): [True: 5, False: 34]
  ------------------
 2476|     34|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT ||
  ------------------
  |  Branch (2476:5): [True: 28, False: 6]
  ------------------
 2477|     77|				file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) {
  ------------------
  |  Branch (2477:5): [True: 6, False: 0]
  ------------------
 2478|     77|			buf[0] = (file->size >> 8) & 0xFF;
 2479|     77|			buf[1] = file->size & 0xFF;
 2480|     77|			sc_asn1_put_tag(0x85, buf, 2, p, *outlen - (p - out), &p);
 2481|     77|		}
 2482|     77|	}
 2483|     85|	if (file->sec_attr_len) {
  ------------------
  |  Branch (2483:6): [True: 0, False: 85]
  ------------------
 2484|      0|		memcpy(buf, file->sec_attr, file->sec_attr_len);
 2485|      0|		sc_asn1_put_tag(0x86, buf, file->sec_attr_len, p, *outlen - (p - out), &p);
 2486|       |
 2487|     85|	} else {
 2488|     85|		sc_log(card->ctx, "SC_FILE_ACL");
  ------------------
  |  |   71|     85|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2489|     85|		if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     85|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (2489:7): [True: 8, False: 77]
  ------------------
 2490|      8|			ops[0] = SC_AC_OP_LIST_FILES;
  ------------------
  |  |  172|      8|#define SC_AC_OP_LIST_FILES		6
  ------------------
 2491|      8|			ops[1] = SC_AC_OP_CREATE;
  ------------------
  |  |  169|      8|#define SC_AC_OP_CREATE			3
  ------------------
 2492|      8|			ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|      8|#define SC_AC_OP_DELETE			2
  ------------------
 2493|     77|		} else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|     77|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (2493:14): [True: 0, False: 77]
  ------------------
 2494|      0|			if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (2494:8): [True: 0, False: 0]
  ------------------
 2495|      0|				ops[0] = SC_AC_OP_READ;
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
 2496|      0|				ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
 2497|      0|				ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
 2498|      0|			} else if (file->ef_structure == SC_FILE_EF_LINEAR_FIXED ||
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (2498:15): [True: 0, False: 0]
  ------------------
 2499|      0|					file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2499:6): [True: 0, False: 0]
  ------------------
 2500|      0|				ops[0] = SC_AC_OP_READ;
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
 2501|      0|				ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
 2502|      0|				ops[2] = SC_AC_OP_WRITE;
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
 2503|      0|				ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
 2504|      0|			} else {
 2505|      0|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2506|      0|			}
 2507|     77|		} else if (file->type == SC_FILE_TYPE_BSO) {
  ------------------
  |  |  217|     77|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (2507:14): [True: 0, False: 77]
  ------------------
 2508|      0|			ops[0] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
 2509|      0|			ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
 2510|     77|		} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|     77|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (2510:14): [True: 77, False: 0]
  ------------------
 2511|     77|			if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT ||
  ------------------
  |  Branch (2511:8): [True: 38, False: 39]
  ------------------
 2512|     66|					file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_CRT) {
  ------------------
  |  Branch (2512:6): [True: 28, False: 11]
  ------------------
 2513|     66|				ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|     66|#define SC_AC_OP_UPDATE			23
  ------------------
 2514|     66|				ops[2] = SC_AC_OP_CRYPTO;
  ------------------
  |  |  173|     66|#define SC_AC_OP_CRYPTO			7
  ------------------
 2515|     66|				ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|     66|#define SC_AC_OP_DELETE			2
  ------------------
 2516|     66|			} else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC ||
  ------------------
  |  Branch (2516:15): [True: 5, False: 6]
  ------------------
 2517|     11|					file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) {
  ------------------
  |  Branch (2517:6): [True: 6, False: 0]
  ------------------
 2518|     11|				ops[0] = SC_AC_OP_READ;
  ------------------
  |  |  188|     11|#define SC_AC_OP_READ			22
  ------------------
 2519|     11|				ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|     11|#define SC_AC_OP_UPDATE			23
  ------------------
 2520|     11|				ops[2] = SC_AC_OP_CRYPTO;
  ------------------
  |  |  173|     11|#define SC_AC_OP_CRYPTO			7
  ------------------
 2521|     11|				ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|     11|#define SC_AC_OP_DELETE			2
  ------------------
 2522|     11|			}
 2523|     77|		} else {
 2524|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2525|      0|		}
 2526|       |
 2527|    765|		for (ii = 0; ii < sizeof(ops); ii++) {
  ------------------
  |  Branch (2527:16): [True: 680, False: 85]
  ------------------
 2528|    680|			const struct sc_acl_entry *entry;
 2529|       |
 2530|    680|			buf[ii] = 0xFF;
 2531|    680|			if (ops[ii] == 0xFF)
  ------------------
  |  Branch (2531:8): [True: 414, False: 266]
  ------------------
 2532|    414|				continue;
 2533|    266|			entry = sc_file_get_acl_entry(file, ops[ii]);
 2534|       |
 2535|    266|			rv = acl_to_ac_byte(card, entry);
 2536|    266|			LOG_TEST_RET(card->ctx, rv, "Invalid ACL");
  ------------------
  |  |  174|    266|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    266|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    266|	int _ret = (r); \
  |  |  |  |  168|    266|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 266]
  |  |  |  |  ------------------
  |  |  |  |  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|    266|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 266]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2537|       |
 2538|    266|			buf[ii] = rv;
 2539|    266|		}
 2540|     85|		sc_asn1_put_tag(0x86, buf, sizeof(ops), p, *outlen - (p - out), &p);
 2541|     85|		if (file->size == 256) {
  ------------------
  |  Branch (2541:7): [True: 36, False: 49]
  ------------------
 2542|     36|			out[4]= 0x13;
 2543|     36|		}
 2544|     85|	}
 2545|       |
 2546|       |	/* VT ??? */
 2547|     85|	if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC ||
  ------------------
  |  Branch (2547:6): [True: 5, False: 80]
  ------------------
 2548|     80|			file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC) {
  ------------------
  |  Branch (2548:4): [True: 6, False: 74]
  ------------------
 2549|     11|		unsigned char data[2] = {0x00, 0x66};
 2550|     11|		sc_asn1_put_tag(0x87, data, sizeof(data), p, *outlen - (p - out), &p);
 2551|     11|		if (file->size == 256) {
  ------------------
  |  Branch (2551:7): [True: 6, False: 5]
  ------------------
 2552|      6|			out[4] = 0x14;
 2553|      6|		}
 2554|     11|	}
 2555|       |
 2556|     85|	out[1] = p - out - 2;
 2557|       |
 2558|     85|	*outlen = p - out;
 2559|     85|	return 0;
 2560|     85|}
card-epass2003.c:acl_to_ac_byte:
 2207|    266|{
 2208|    266|	if (e == NULL)
  ------------------
  |  Branch (2208:6): [True: 0, False: 266]
  ------------------
 2209|      0|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 2210|       |
 2211|    266|	switch (e->method) {
 2212|    264|	case SC_AC_NONE:
  ------------------
  |  |  150|    264|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (2212:2): [True: 264, False: 2]
  ------------------
 2213|    264|		LOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE);
  ------------------
  |  |  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: 0, False: 264]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    264|	} else { \
  |  |  |  |  159|    264|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    264|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    264|	} \
  |  |  |  |  162|    264|	return _ret; \
  |  |  |  |  163|    264|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2214|      0|	case SC_AC_NEVER:
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (2214:2): [True: 0, False: 266]
  ------------------
 2215|      0|		LOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_NOONE);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2216|      2|	default:
  ------------------
  |  Branch (2216:2): [True: 2, False: 264]
  ------------------
 2217|      2|		LOG_FUNC_RETURN(card->ctx, EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER);
  ------------------
  |  |  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: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2218|    266|	}
 2219|       |
 2220|      0|	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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2221|      0|}
card-epass2003.c:epass2003_pin_cmd:
 3182|     26|{
 3183|     26|	int r;
 3184|     26|	u8 kid;
 3185|     26|	u8 retries = 0;
 3186|     26|	u8 pin_low = 3;
 3187|     26|	unsigned char maxtries = 0;
 3188|       |
 3189|     26|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     26|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     26|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     26|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3190|       |
 3191|     26|	internal_sanitize_pin_info(&data->pin1, 0);
 3192|     26|	internal_sanitize_pin_info(&data->pin2, 1);
 3193|     26|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  429|     26|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 3194|     26|	kid = data->pin_reference;
 3195|       |
 3196|     26|	if (NULL == (unsigned char *)data->pin1.data || 0 == data->pin1.len)
  ------------------
  |  Branch (3196:6): [True: 26, False: 0]
  |  Branch (3196:50): [True: 0, False: 0]
  ------------------
 3197|     26|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_PIN_CODE_INCORRECT);
  ------------------
  |  |  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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3198|       |
 3199|       |	/* get pin retries */
 3200|      0|	if (data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  425|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (3200:6): [True: 0, False: 0]
  ------------------
 3201|       |
 3202|      0|		r = get_external_key_retries(card, 0x80 | kid, &retries);
 3203|      0|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (3203:7): [True: 0, False: 0]
  ------------------
 3204|      0|			data->pin1.tries_left = retries;
 3205|       |
 3206|      0|			r = get_external_key_maxtries(card, &maxtries);
 3207|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3208|       |
 3209|      0|			data->pin1.max_tries = maxtries;
 3210|      0|		}
 3211|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3212|      0|	} else if (data->cmd == SC_PIN_CMD_UNBLOCK) { /* verify */
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (3212:13): [True: 0, False: 0]
  ------------------
 3213|      0|		r = external_key_auth(card, (kid + 1), (unsigned char *)data->pin1.data,
 3214|      0|				data->pin1.len);
 3215|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3216|      0|	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) { /* change */
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
              	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) { /* change */
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (3216:13): [True: 0, False: 0]
  |  Branch (3216:47): [True: 0, False: 0]
  ------------------
 3217|      0|		r = external_key_auth(card, kid, (unsigned char *)data->pin1.data,
 3218|      0|				data->pin1.len);
 3219|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3220|       |
 3221|      0|		r = update_secret_key(card, 0x04, kid, data->pin2.data,
 3222|      0|				(unsigned long)data->pin2.len);
 3223|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3224|      0|	} else {
 3225|      0|		r = external_key_auth(card, kid, (unsigned char *)data->pin1.data,
 3226|      0|				data->pin1.len);
 3227|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3228|       |
 3229|      0|		r = get_external_key_retries(card, 0x80 | kid, &retries);
 3230|      0|		if (retries < pin_low)
  ------------------
  |  Branch (3230:7): [True: 0, False: 0]
  ------------------
 3231|      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__
  |  |  ------------------
  ------------------
 3232|       |
 3233|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3234|      0|	}
 3235|       |
 3236|      0|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (3236:6): [True: 0, False: 0]
  ------------------
 3237|      0|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  439|      0|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 3238|      0|	}
 3239|      0|	return r;
 3240|      0|}
card-epass2003.c:internal_sanitize_pin_info:
 3030|     52|{
 3031|     52|	pin->encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  432|     52|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 3032|     52|	pin->min_length = 4;
 3033|     52|	pin->max_length = 16;
 3034|     52|	pin->pad_length = 16;
 3035|     52|	pin->offset = 5 + num * 16;
 3036|     52|	pin->pad_char = 0x00;
 3037|     52|}
card-epass2003.c:epass2003_check_sw:
  245|  2.71k|{
  246|  2.71k|	const int err_count = sizeof(epass2003_errors)/sizeof(epass2003_errors[0]);
  247|  2.71k|	int i;
  248|       |
  249|       |	/* Handle special cases here */
  250|  2.71k|	if (sw1 == 0x6C) {
  ------------------
  |  Branch (250:6): [True: 25, False: 2.68k]
  ------------------
  251|     25|		sc_log(card->ctx, "Wrong length; correct length is %d", sw2);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  252|     25|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|     25|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  253|     25|	}
  254|       |
  255|   127k|	for (i = 0; i < err_count; i++) {
  ------------------
  |  Branch (255:14): [True: 126k, False: 200]
  ------------------
  256|   126k|		if (epass2003_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (256:7): [True: 2.48k, False: 124k]
  ------------------
  257|  2.48k|			sc_log(card->ctx, "%s", epass2003_errors[i].errorstr);
  ------------------
  |  |   71|  2.48k|#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|  2.48k|			return epass2003_errors[i].errorno;
  259|  2.48k|		}
  260|   126k|	}
  261|       |
  262|    200|	sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X", sw1, sw2);
  ------------------
  |  |   71|    200|#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|    200|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|    200|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  264|  2.68k|}

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

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

sc_get_cryptoflex_driver:
 1216|  3.69k|{
 1217|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1217:6): [True: 0, False: 3.69k]
  ------------------
 1218|      0|		iso_ops = sc_get_iso7816_driver()->ops;
 1219|       |
 1220|  3.69k|	cryptoflex_ops = *iso_ops;
 1221|  3.69k|	cryptoflex_ops.match_card = cryptoflex_match_card;
 1222|  3.69k|	cryptoflex_ops.init = flex_init;
 1223|  3.69k|	cryptoflex_ops.finish = flex_finish;
 1224|  3.69k|	cryptoflex_ops.process_fci = cryptoflex_process_file_attrs;
 1225|  3.69k|	cryptoflex_ops.construct_fci = cryptoflex_construct_file_attrs;
 1226|  3.69k|	cryptoflex_ops.select_file = flex_select_file;
 1227|  3.69k|	cryptoflex_ops.list_files = cryptoflex_list_files;
 1228|  3.69k|	cryptoflex_ops.delete_file = flex_delete_file;
 1229|  3.69k|	cryptoflex_ops.create_file = flex_create_file;
 1230|  3.69k|	cryptoflex_ops.card_ctl = flex_card_ctl;
 1231|  3.69k|	cryptoflex_ops.set_security_env = flex_set_security_env;
 1232|  3.69k|	cryptoflex_ops.restore_security_env = flex_restore_security_env;
 1233|  3.69k|	cryptoflex_ops.compute_signature = cryptoflex_compute_signature;
 1234|  3.69k|	cryptoflex_ops.decipher = flex_decipher;
 1235|  3.69k|	cryptoflex_ops.pin_cmd = flex_pin_cmd;
 1236|  3.69k|	cryptoflex_ops.logout = flex_logout;
 1237|  3.69k|	return &cryptoflex_drv;
 1238|  3.69k|}
sc_get_cyberflex_driver:
 1241|  3.69k|{
 1242|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1242:6): [True: 1, False: 3.69k]
  ------------------
 1243|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1244|       |
 1245|  3.69k|	cyberflex_ops = *iso_ops;
 1246|  3.69k|	cyberflex_ops.match_card = cyberflex_match_card;
 1247|  3.69k|	cyberflex_ops.init = flex_init;
 1248|  3.69k|	cyberflex_ops.finish = flex_finish;
 1249|  3.69k|	cyberflex_ops.process_fci = cyberflex_process_file_attrs;
 1250|  3.69k|	cyberflex_ops.construct_fci = cyberflex_construct_file_attrs;
 1251|  3.69k|	cyberflex_ops.select_file = flex_select_file;
 1252|  3.69k|	cyberflex_ops.list_files = cyberflex_list_files;
 1253|  3.69k|	cyberflex_ops.delete_file = flex_delete_file;
 1254|  3.69k|	cyberflex_ops.create_file = flex_create_file;
 1255|  3.69k|	cyberflex_ops.card_ctl = flex_card_ctl;
 1256|  3.69k|	cyberflex_ops.set_security_env = flex_set_security_env;
 1257|  3.69k|	cyberflex_ops.restore_security_env = flex_restore_security_env;
 1258|  3.69k|	cyberflex_ops.compute_signature = cyberflex_compute_signature;
 1259|  3.69k|	cyberflex_ops.decipher = flex_decipher;
 1260|  3.69k|	cyberflex_ops.pin_cmd = flex_pin_cmd;
 1261|  3.69k|	cyberflex_ops.logout = flex_logout;
 1262|  3.69k|	return &cyberflex_drv;
 1263|  3.69k|}
card-flex.c:cryptoflex_match_card:
  134|  3.67k|{
  135|  3.67k|	int i;
  136|       |
  137|  3.67k|	i = _sc_match_atr(card, flex_atrs, NULL);
  138|  3.67k|	if (i < 0)
  ------------------
  |  Branch (138:6): [True: 3.65k, False: 28]
  ------------------
  139|  3.65k|		return 0;
  140|     28|	switch (flex_atrs[i].type) {
  ------------------
  |  Branch (140:10): [True: 28, False: 0]
  ------------------
  141|     28|	case SC_CARD_TYPE_FLEX_CRYPTO:
  ------------------
  |  Branch (141:2): [True: 28, False: 0]
  ------------------
  142|     28|	case SC_CARD_TYPE_FLEX_MULTI:
  ------------------
  |  Branch (142:2): [True: 0, False: 28]
  ------------------
  143|     28|		card->name = flex_atrs[i].name;
  144|     28|		card->type = flex_atrs[i].type;
  145|     28|		card->flags = flex_atrs[i].flags;
  146|     28|		return 1;
  147|     28|	}
  148|      0|	return 0;
  149|     28|}
card-flex.c:flex_init:
  169|     44|{
  170|     44|	struct flex_private_data *data;
  171|       |
  172|     44|	if (!(data = malloc(sizeof(*data))))
  ------------------
  |  Branch (172:6): [True: 0, False: 44]
  ------------------
  173|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  174|     44|	card->drv_data = data;
  175|       |
  176|     44|	card->cla = 0xC0;
  177|     44|	data->aak_key_ref = 1;
  178|       |
  179|       |	/* Override Cryptoflex defaults for specific card types */
  180|     44|	switch (card->type) {
  ------------------
  |  Branch (180:10): [True: 16, False: 28]
  ------------------
  181|     16|	case SC_CARD_TYPE_FLEX_CYBER:
  ------------------
  |  Branch (181:2): [True: 16, False: 28]
  ------------------
  182|     16|		card->cla = 0x00;
  183|     16|		data->aak_key_ref = 0;
  184|     16|		break;
  185|     44|	}
  186|       |
  187|       |	/* FIXME: Card type detection */
  188|     44|	if (1) {
  ------------------
  |  Branch (188:6): [True: 44, Folded]
  ------------------
  189|     44|		unsigned long flags;
  190|       |
  191|     44|		flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  111|     44|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  192|     44|		flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  142|     44|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  193|     44|		if (card->flags & FLAG_KEYGEN)
  ------------------
  |  |   31|     44|#define FLAG_KEYGEN		0x80000000
  ------------------
  |  Branch (193:7): [True: 28, False: 16]
  ------------------
  194|     28|			flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|     28|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  195|       |
  196|     44|		_sc_card_add_rsa_alg(card, 512, flags, 0);
  197|     44|		_sc_card_add_rsa_alg(card, 768, flags, 0);
  198|     44|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  199|     44|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  200|     44|	}
  201|       |
  202|       |	/* SCardTransmit failed: 8010002f
  203|       |	 * this can be solved with a small delay. */
  204|     44|	msleep(100);
  ------------------
  |  |   60|     44|#define msleep(t)	usleep((t) * 1000)
  ------------------
  205|       |
  206|       |	/* State that we have an RNG */
  207|     44|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|     44|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  208|       |
  209|     44|	return 0;
  210|     44|}
card-flex.c:flex_finish:
  128|     44|{
  129|     44|	free(card->drv_data);
  130|     44|	return 0;
  131|     44|}
card-flex.c:cryptoflex_process_file_attrs:
  270|     89|{
  271|     89|	sc_context_t *ctx = card->ctx;
  272|     89|	const u8 *p = buf + 2;
  273|     89|	u8 b1, b2;
  274|     89|	int is_mf = 0;
  275|       |
  276|     89|	if (buflen < 14)
  ------------------
  |  Branch (276:6): [True: 0, False: 89]
  ------------------
  277|      0|		return -1;
  278|     89|	b1 = *p++;
  279|     89|	b2 = *p++;
  280|     89|	file->size = (b1 << 8) + b2;
  281|     89|	b1 = *p++;
  282|     89|	b2 = *p++;
  283|     89|	file->id = (b1 << 8) + b2;
  284|     89|	if (file->id == 0x3F00)
  ------------------
  |  Branch (284:6): [True: 0, False: 89]
  ------------------
  285|      0|		is_mf = 1;
  286|     89|	switch (*p) {
  287|      2|	case 0x01:
  ------------------
  |  Branch (287:2): [True: 2, False: 87]
  ------------------
  288|      2|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      2|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  289|      2|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      2|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  290|      2|		break;
  291|     59|	case 0x02:
  ------------------
  |  Branch (291:2): [True: 59, False: 30]
  ------------------
  292|     59|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     59|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  293|     59|		file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|     59|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  294|     59|		break;
  295|      4|	case 0x04:
  ------------------
  |  Branch (295:2): [True: 4, False: 85]
  ------------------
  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|     12|	case 0x06:
  ------------------
  |  Branch (299:2): [True: 12, False: 77]
  ------------------
  300|     12|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     12|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  301|     12|		file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|     12|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  302|     12|		break;
  303|      0|	case 0x38:
  ------------------
  |  Branch (303:2): [True: 0, False: 89]
  ------------------
  304|      0|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  305|      0|		break;
  306|     12|	default:
  ------------------
  |  Branch (306:2): [True: 12, False: 77]
  ------------------
  307|     12|		sc_log(ctx,  "invalid file type: 0x%02X\n", *p);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  308|     12|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     12|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  309|     89|	}
  310|     77|	p += 2;
  311|     77|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     77|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (311:6): [True: 0, False: 77]
  ------------------
  312|      0|		add_acl_entry(card, file, SC_AC_OP_LIST_FILES, (u8)(p[0] >> 4));
  ------------------
  |  |  172|      0|#define SC_AC_OP_LIST_FILES		6
  ------------------
  313|      0|		add_acl_entry(card, file, SC_AC_OP_DELETE, (u8)(p[1] >> 4));
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
  314|      0|		add_acl_entry(card, file, SC_AC_OP_CREATE, (u8)(p[1] & 0x0F));
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
  315|     77|	} else { /* EF */
  316|     77|		add_acl_entry(card, file, SC_AC_OP_READ, (u8)(p[0] >> 4));
  ------------------
  |  |  188|     77|#define SC_AC_OP_READ			22
  ------------------
  317|     77|		switch (file->ef_structure) {
  ------------------
  |  Branch (317:11): [True: 77, False: 0]
  ------------------
  318|      2|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|      2|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (318:3): [True: 2, False: 75]
  ------------------
  319|      2|			add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(p[0] & 0x0F));
  ------------------
  |  |  189|      2|#define SC_AC_OP_UPDATE			23
  ------------------
  320|      2|			break;
  321|     59|		case SC_FILE_EF_LINEAR_FIXED:
  ------------------
  |  |  222|     59|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (321:3): [True: 59, False: 18]
  ------------------
  322|     63|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|     63|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (322:3): [True: 4, False: 73]
  ------------------
  323|     63|			add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(p[0] & 0x0F));
  ------------------
  |  |  189|     63|#define SC_AC_OP_UPDATE			23
  ------------------
  324|     63|			break;
  325|     12|		case SC_FILE_EF_CYCLIC:
  ------------------
  |  |  226|     12|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (325:3): [True: 12, False: 65]
  ------------------
  326|     12|			break;
  327|     77|		}
  328|     77|	}
  329|     77|	if (file->type != SC_FILE_TYPE_DF || is_mf) {
  ------------------
  |  |  214|    154|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (329:6): [True: 77, False: 0]
  |  Branch (329:39): [True: 0, False: 0]
  ------------------
  330|     77|		add_acl_entry(card, file, SC_AC_OP_REHABILITATE, (u8)(p[2] >> 4));
  ------------------
  |  |  170|     77|#define SC_AC_OP_REHABILITATE		4
  ------------------
  331|     77|		add_acl_entry(card, file, SC_AC_OP_INVALIDATE, (u8)(p[2] & 0x0F));
  ------------------
  |  |  171|     77|#define SC_AC_OP_INVALIDATE		5
  ------------------
  332|     77|	}
  333|     77|	p += 3;
  334|     77|	if (*p)
  ------------------
  |  Branch (334:6): [True: 73, False: 4]
  ------------------
  335|     73|		file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|     73|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  336|      4|	else
  337|      4|		file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|      4|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  338|       |
  339|     77|	return cryptoflex_get_ac_keys(card, file);
  340|     77|}
card-flex.c:add_acl_entry:
  214|    317|{
  215|    317|	struct flex_private_data *prv = DRV_DATA(card);
  ------------------
  |  |  109|    317|#define DRV_DATA(card)	((struct flex_private_data *) (card)->drv_data)
  ------------------
  216|       |
  217|    317|	switch (nibble) {
  218|    145|	case 0:
  ------------------
  |  Branch (218:2): [True: 145, False: 172]
  ------------------
  219|    145|		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|    145|#define SC_AC_NONE			0x00000000
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    145|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  220|    145|		break;
  221|      0|	case 1:
  ------------------
  |  Branch (221:2): [True: 0, False: 317]
  ------------------
  222|      0|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 1);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  223|      0|		break;
  224|     60|	case 2:
  ------------------
  |  Branch (224:2): [True: 60, False: 257]
  ------------------
  225|     60|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 2);
  ------------------
  |  |  151|     60|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  226|     60|		break;
  227|      3|	case 3:
  ------------------
  |  Branch (227:2): [True: 3, False: 314]
  ------------------
  228|      3|		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  153|      3|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|      3|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  229|      3|		break;
  230|     14|	case 4:
  ------------------
  |  Branch (230:2): [True: 14, False: 303]
  ------------------
  231|       |		/* Assume the key is the AAK */
  232|     14|		sc_file_add_acl_entry(file, op, SC_AC_AUT, prv->aak_key_ref);
  ------------------
  |  |  154|     14|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  233|     14|		break;
  234|      2|	case 6:
  ------------------
  |  Branch (234:2): [True: 2, False: 315]
  ------------------
  235|      2|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 1);
  ------------------
  |  |  151|      2|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  236|      2|		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  153|      2|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|      2|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  237|      2|		break;
  238|      2|	case 7:
  ------------------
  |  Branch (238:2): [True: 2, False: 315]
  ------------------
  239|      2|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 2);
  ------------------
  |  |  151|      2|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  240|      2|		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  153|      2|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_PRO, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|      2|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  241|      2|		break;
  242|      1|	case 8:
  ------------------
  |  Branch (242:2): [True: 1, False: 316]
  ------------------
  243|      1|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 1);
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  244|       |		/* Assume the key is the AAK */
  245|      1|		sc_file_add_acl_entry(file, op, SC_AC_AUT, prv->aak_key_ref);
  ------------------
  |  |  154|      1|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  246|      1|		break;
  247|     61|	case 9:
  ------------------
  |  Branch (247:2): [True: 61, False: 256]
  ------------------
  248|     61|		sc_file_add_acl_entry(file, op, SC_AC_CHV, 2);
  ------------------
  |  |  151|     61|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  249|       |		/* Assume the key is the AAK */
  250|     61|		sc_file_add_acl_entry(file, op, SC_AC_AUT, prv->aak_key_ref);
  ------------------
  |  |  154|     61|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  251|     61|		break;
  252|     23|	case 15:
  ------------------
  |  Branch (252:2): [True: 23, False: 294]
  ------------------
  253|     23|		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  163|     23|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     23|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  254|     23|		break;
  255|      6|	default:
  ------------------
  |  Branch (255:2): [True: 6, False: 311]
  ------------------
  256|      6|		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  162|      6|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|      6|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  257|      6|		break;
  258|    317|	}
  259|    317|}
card-flex.c:cryptoflex_get_ac_keys:
  263|     77|{
  264|     77|	return 0;
  265|     77|}
card-flex.c:cryptoflex_construct_file_attrs:
  674|      4|{
  675|      4|	u8 *p = buf;
  676|      4|	int r, i;
  677|      4|	int ops[6];
  678|       |
  679|      4|	p[0] = 0xFF;
  680|      4|	p[1] = 0xFF;
  681|      4|	p[2] = file->size >> 8;
  682|      4|	p[3] = file->size & 0xFF;
  683|      4|	p[4] = file->id >> 8;
  684|      4|	p[5] = file->id & 0xFF;
  685|      4|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|      4|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (685:6): [True: 2, False: 2]
  ------------------
  686|      2|		p[6] = 0x38;
  687|      2|	else
  688|      2|		switch (file->ef_structure) {
  689|      2|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|      2|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (689:3): [True: 2, False: 0]
  ------------------
  690|      2|			p[6] = 0x01;
  691|      2|			break;
  692|      0|		case SC_FILE_EF_LINEAR_FIXED:
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (692:3): [True: 0, False: 2]
  ------------------
  693|      0|			p[6] = 0x02;
  694|      0|			break;
  695|      0|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (695:3): [True: 0, False: 2]
  ------------------
  696|      0|			p[6] = 0x04;
  697|      0|			break;
  698|      0|		case SC_FILE_EF_CYCLIC:
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (698:3): [True: 0, False: 2]
  ------------------
  699|      0|			p[6] = 0x06;
  700|      0|			break;
  701|      0|		default:
  ------------------
  |  Branch (701:3): [True: 0, False: 2]
  ------------------
  702|      0|			sc_log(card->ctx,  "Invalid EF structure\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__
  |  |  ------------------
  ------------------
  703|      0|			return -1;
  704|      2|		}
  705|      4|	p[7] = 0xFF;	/* allow Decrease and Increase */
  706|     28|	for (i = 0; i < 6; i++)
  ------------------
  |  Branch (706:14): [True: 24, False: 4]
  ------------------
  707|     24|		ops[i] = -1;
  708|      4|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|      4|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (708:6): [True: 2, False: 2]
  ------------------
  709|      2|		ops[0] = SC_AC_OP_LIST_FILES;
  ------------------
  |  |  172|      2|#define SC_AC_OP_LIST_FILES		6
  ------------------
  710|      2|		ops[2] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|      2|#define SC_AC_OP_DELETE			2
  ------------------
  711|      2|		ops[3] = SC_AC_OP_CREATE;
  ------------------
  |  |  169|      2|#define SC_AC_OP_CREATE			3
  ------------------
  712|      2|	} else {
  713|      2|		ops[0] = SC_AC_OP_READ;
  ------------------
  |  |  188|      2|#define SC_AC_OP_READ			22
  ------------------
  714|      2|		ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      2|#define SC_AC_OP_UPDATE			23
  ------------------
  715|      2|		ops[2] = SC_AC_OP_READ;
  ------------------
  |  |  188|      2|#define SC_AC_OP_READ			22
  ------------------
  716|      2|		ops[3] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      2|#define SC_AC_OP_UPDATE			23
  ------------------
  717|      2|		ops[4] = SC_AC_OP_REHABILITATE;
  ------------------
  |  |  170|      2|#define SC_AC_OP_REHABILITATE		4
  ------------------
  718|      2|		ops[5] = SC_AC_OP_INVALIDATE;
  ------------------
  |  |  171|      2|#define SC_AC_OP_INVALIDATE		5
  ------------------
  719|      2|	}
  720|      4|	p[8] = p[9] = p[10] = 0;
  721|      4|	p[13] = p[14] = p[15] = 0; /* Key numbers */
  722|     28|	for (i = 0; i < 6; i++) {
  ------------------
  |  Branch (722:14): [True: 24, False: 4]
  ------------------
  723|     24|		const sc_acl_entry_t *entry;
  724|     24|		if (ops[i] == -1)
  ------------------
  |  Branch (724:7): [True: 6, False: 18]
  ------------------
  725|      6|			continue;
  726|     18|		entry = sc_file_get_acl_entry(file, ops[i]);
  727|     18|		r = acl_to_ac_nibble(entry);
  728|     18|		LOG_TEST_RET(card->ctx, r, "Invalid ACL value");
  ------------------
  |  |  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: 0, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|       |		/* Do some magic to get the nibbles right */
  730|     18|		p[8 + i/2] |= (r & 0x0F) << (((i+1) % 2) * 4);
  731|     18|		r = acl_to_keynum_nibble(entry);
  732|     18|		p[13 + i/2] |= (r & 0x0F) << (((i+1) % 2) * 4);
  733|     18|	}
  734|      4|	p[11] = (file->status == SC_FILE_STATUS_INVALIDATED) ? 0x00 : 0x01;
  ------------------
  |  |  237|      4|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  |  Branch (734:10): [True: 0, False: 4]
  ------------------
  735|      4|	if (file->type != SC_FILE_TYPE_DF &&
  ------------------
  |  |  214|      8|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (735:6): [True: 2, False: 2]
  ------------------
  736|      2|	    (file->ef_structure == SC_FILE_EF_LINEAR_FIXED ||
  ------------------
  |  |  222|      4|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (736:7): [True: 0, False: 2]
  ------------------
  737|      2|	    file->ef_structure == SC_FILE_EF_CYCLIC))
  ------------------
  |  |  226|      2|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (737:6): [True: 0, False: 2]
  ------------------
  738|      0|		p[12] = 0x04;
  739|      4|	else
  740|      4|		p[12] = 0x03;
  741|      4|	if (p[12] == 0x04) {
  ------------------
  |  Branch (741:6): [True: 0, False: 4]
  ------------------
  742|      0|		p[16] = file->record_length;
  743|      0|		*buflen = 17;
  744|      0|	} else
  745|      4|		*buflen = 16;
  746|       |
  747|      4|	return 0;
  748|      4|}
card-flex.c:acl_to_ac_nibble:
  633|     18|{
  634|     18|	if (e == NULL)
  ------------------
  |  Branch (634:6): [True: 0, False: 18]
  ------------------
  635|      0|		return -1;
  636|     18|	if (e->next != NULL)	/* FIXME */
  ------------------
  |  Branch (636:6): [True: 0, False: 18]
  ------------------
  637|      0|		return -1;
  638|     18|	switch (e->method) {
  ------------------
  |  Branch (638:10): [True: 18, False: 0]
  ------------------
  639|     11|	case SC_AC_NONE:
  ------------------
  |  |  150|     11|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (639:2): [True: 11, False: 7]
  ------------------
  640|     11|		return 0x00;
  641|      0|	case SC_AC_CHV:
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (641:2): [True: 0, False: 18]
  ------------------
  642|      0|		switch (e->key_ref) {
  ------------------
  |  Branch (642:11): [True: 0, False: 0]
  ------------------
  643|      0|		case 1:
  ------------------
  |  Branch (643:3): [True: 0, False: 0]
  ------------------
  644|      0|			return 0x01;
  645|      0|			break;
  646|      0|		case 2:
  ------------------
  |  Branch (646:3): [True: 0, False: 0]
  ------------------
  647|      0|			return 0x02;
  648|      0|			break;
  649|      0|		}
  650|      0|		return -1;
  651|      0|	case SC_AC_PRO:
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (651:2): [True: 0, False: 18]
  ------------------
  652|      0|		return 0x03;
  653|      0|	case SC_AC_AUT:
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (653:2): [True: 0, False: 18]
  ------------------
  654|      0|		return 0x04;
  655|      7|	case SC_AC_NEVER:
  ------------------
  |  |  163|      7|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (655:2): [True: 7, False: 11]
  ------------------
  656|      7|		return 0x0f;
  657|     18|	}
  658|      0|	return -1;
  659|     18|}
card-flex.c:acl_to_keynum_nibble:
  662|     18|{
  663|     36|	while (e != NULL && e->method != SC_AC_AUT)
  ------------------
  |  |  154|     18|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (663:9): [True: 18, False: 18]
  |  Branch (663:22): [True: 18, False: 0]
  ------------------
  664|     18|		e = e->next;
  665|     18|	if (e == NULL || e->key_ref == SC_AC_KEY_REF_NONE)
  ------------------
  |  |  204|      0|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (665:6): [True: 18, False: 0]
  |  Branch (665:19): [True: 0, False: 0]
  ------------------
  666|     18|		return 0;
  667|       |
  668|      0|	return e->key_ref & 0x0F;
  669|     18|}
card-flex.c:flex_select_file:
  491|    406|{
  492|    406|	int r;
  493|    406|	const u8 *pathptr = path->value;
  494|    406|	size_t pathlen = path->len;
  495|    406|	int locked = 0;
  496|    406|	u8 p1 = 0;
  497|       |
  498|    406|	switch (path->type) {
  ------------------
  |  Branch (498:10): [True: 406, False: 0]
  ------------------
  499|    314|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|    314|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (499:2): [True: 314, False: 92]
  ------------------
  500|    314|		if ((pathlen & 1) != 0) /* not divisible by 2 */
  ------------------
  |  Branch (500:7): [True: 0, False: 314]
  ------------------
  501|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  502|    314|		if (pathlen == 0)
  ------------------
  |  Branch (502:7): [True: 0, False: 314]
  ------------------
  503|      0|			return 0;
  504|    314|		if (pathlen != 2 || memcmp(pathptr, "\x3F\x00", 2) != 0) {
  ------------------
  |  Branch (504:7): [True: 276, False: 38]
  |  Branch (504:23): [True: 23, False: 15]
  ------------------
  505|    299|			locked = 1;
  506|    299|			r = sc_lock(card);
  507|    299|			LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|    299|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    299|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    299|	int _ret = (r); \
  |  |  |  |  168|    299|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 299]
  |  |  |  |  ------------------
  |  |  |  |  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|    299|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 299]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  508|    299|			if (memcmp(pathptr, "\x3F\x00", 2) != 0) {
  ------------------
  |  Branch (508:8): [True: 54, False: 245]
  ------------------
  509|     54|				r = select_file_id(card, (const u8 *) "\x3F\x00", 2, 0, NULL);
  510|     54|				if (r)
  ------------------
  |  Branch (510:9): [True: 14, False: 40]
  ------------------
  511|     14|					sc_unlock(card);
  512|     54|				LOG_TEST_RET(card->ctx, r, "Unable to select Master File (MF)");
  ------------------
  |  |  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: 14, False: 40]
  |  |  |  |  ------------------
  |  |  |  |  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|     54|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 40]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  513|     54|			}
  514|    560|			while (pathlen > 2) {
  ------------------
  |  Branch (514:11): [True: 418, False: 142]
  ------------------
  515|    418|				r = select_file_id(card, pathptr, 2, 0, NULL);
  516|    418|				if (r)
  ------------------
  |  Branch (516:9): [True: 143, False: 275]
  ------------------
  517|    143|					sc_unlock(card);
  518|    418|				LOG_TEST_RET(card->ctx, r, "Unable to select DF");
  ------------------
  |  |  174|    418|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    418|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    418|	int _ret = (r); \
  |  |  |  |  168|    418|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 143, False: 275]
  |  |  |  |  ------------------
  |  |  |  |  169|    143|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    143|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    143|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    143|		return _ret; \
  |  |  |  |  172|    143|	} \
  |  |  |  |  173|    418|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 275]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|    275|				pathptr += 2;
  520|    275|				pathlen -= 2;
  521|    275|			}
  522|    285|		}
  523|    157|		break;
  524|    157|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|     77|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (524:2): [True: 77, False: 329]
  ------------------
  525|     77|		p1 = 0x04;
  526|     77|		break;
  527|     15|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|     15|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (527:2): [True: 15, False: 391]
  ------------------
  528|     15|		if (pathlen != 2)
  ------------------
  |  Branch (528:7): [True: 6, False: 9]
  ------------------
  529|      6|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      6|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  530|      9|		break;
  531|    406|	}
  532|    243|	r = select_file_id(card, pathptr, pathlen, p1, file_out);
  533|    243|	if (locked)
  ------------------
  |  Branch (533:6): [True: 142, False: 101]
  ------------------
  534|    142|		sc_unlock(card);
  535|    243|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    243|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    243|	int _ret = r; \
  |  |  155|    243|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 243, False: 0]
  |  |  ------------------
  |  |  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|    115|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 115, False: 128]
  |  |  ------------------
  |  |  157|    243|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    243|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    243|	return _ret; \
  |  |  163|    243|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  536|    243|}
card-flex.c:select_file_id:
  438|    715|{
  439|    715|	int r;
  440|    715|	sc_apdu_t apdu;
  441|    715|        u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  442|    715|        sc_file_t *file;
  443|       |
  444|    715|	sc_log(card->ctx,  "called, p1=%u\n", p1);
  ------------------
  |  |   71|    715|#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|    715|	sc_log_hex(card->ctx, "path", buf, buflen);
  ------------------
  |  |  129|    715|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    715|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|       |
  447|    715|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, p1, 0);
  ------------------
  |  |  294|    715|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  448|    715|	apdu.resp = rbuf;
  449|    715|	apdu.resplen = sizeof(rbuf);
  450|    715|	apdu.datalen = buflen;
  451|    715|	apdu.data = buf;
  452|    715|	apdu.lc = buflen;
  453|    715|	apdu.le = 252;
  454|       |
  455|       |	/* No need to get file information, if file is NULL. */
  456|    715|	if (file_out == NULL) {
  ------------------
  |  Branch (456:6): [True: 574, False: 141]
  ------------------
  457|    574|		apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|    574|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  458|    574|		apdu.le = 0;
  459|    574|	}
  460|    715|	r = sc_transmit_apdu(card, &apdu);
  461|    715|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    715|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    715|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    715|	int _ret = (r); \
  |  |  |  |  168|    715|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 712]
  |  |  |  |  ------------------
  |  |  |  |  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|    715|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 712]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  462|    712|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  463|    712|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    712|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    712|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    712|	int _ret = (r); \
  |  |  |  |  168|    712|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 240, False: 472]
  |  |  |  |  ------------------
  |  |  |  |  169|    240|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    240|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    240|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    240|		return _ret; \
  |  |  |  |  172|    240|	} \
  |  |  |  |  173|    712|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 472]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|       |
  465|    472|	if (file_out == NULL)
  ------------------
  |  Branch (465:6): [True: 361, False: 111]
  ------------------
  466|    361|		return 0;
  467|       |
  468|    111|	if (apdu.resplen < 14)
  ------------------
  |  Branch (468:6): [True: 8, False: 103]
  ------------------
  469|      8|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      8|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  470|    103|	if (apdu.resp[0] == 0x6F) {
  ------------------
  |  Branch (470:6): [True: 4, False: 99]
  ------------------
  471|      4|		sc_log(card->ctx,  "unsupported: card returned FCI\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__
  |  |  ------------------
  ------------------
  472|      4|		return SC_ERROR_UNKNOWN_DATA_RECEIVED; /* FIXME */
  ------------------
  |  |   63|      4|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  473|      4|	}
  474|     99|	file = sc_file_new();
  475|     99|	if (file == NULL)
  ------------------
  |  Branch (475:6): [True: 0, False: 99]
  ------------------
  476|     99|		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|     99|	r = card->ops->process_fci(card, file, apdu.resp, apdu.resplen);
  480|     99|	if (r) {
  ------------------
  |  Branch (480:6): [True: 17, False: 82]
  ------------------
  481|     17|		sc_file_free(file);
  482|     17|		return r;
  483|     17|	}
  484|       |
  485|     82|	*file_out = file;
  486|     82|	return 0;
  487|     99|}
card-flex.c:flex_delete_file:
  611|     11|{
  612|     11|	sc_apdu_t apdu;
  613|     11|	int r;
  614|       |
  615|     11|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     11|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     11|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     11|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 11]
  |  |  ------------------
  ------------------
  616|     11|	if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2) {
  ------------------
  |  |  117|     22|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (616:6): [True: 0, False: 11]
  |  Branch (616:44): [True: 0, False: 0]
  ------------------
  617|      0|		sc_log(card->ctx,  "File type has to be SC_PATH_TYPE_FILE_ID\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__
  |  |  ------------------
  ------------------
  618|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  619|      0|	}
  620|     11|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
  ------------------
  |  |  293|     11|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  621|     11|	if (!IS_CYBERFLEX(card))
  ------------------
  |  |   32|     11|#define IS_CYBERFLEX(card)	(card->type == SC_CARD_TYPE_FLEX_CYBER)
  ------------------
  |  Branch (621:6): [True: 11, False: 0]
  ------------------
  622|     11|		apdu.cla = 0xF0;	/* Override CLA byte */
  623|     11|	apdu.data = path->value;
  624|     11|	apdu.lc = 2;
  625|     11|	apdu.datalen = 2;
  626|       |
  627|     11|	r = sc_transmit_apdu(card, &apdu);
  628|     11|	LOG_TEST_RET(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  629|     10|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
  630|     11|}
card-flex.c:flex_create_file:
  811|      5|{
  812|      5|	u8 sbuf[18];
  813|      5|	size_t sendlen;
  814|      5|	int r, rec_nr;
  815|      5|	sc_apdu_t apdu;
  816|       |
  817|       |	/* Build the file attrs. These are not the real FCI bytes
  818|       |	 * in the standard sense, but its a convenient way of
  819|       |	 * abstracting the Cryptoflex/Cyberflex differences */
  820|      5|	r = card->ops->construct_fci(card, file, sbuf, &sendlen);
  821|      5|	if (r) {
  ------------------
  |  Branch (821:6): [True: 1, False: 4]
  ------------------
  822|      1|		sc_log(card->ctx,  "File structure encoding failed.\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  823|      1|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  824|      1|	}
  825|      4|	if (file->type != SC_FILE_TYPE_DF && file->ef_structure != SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  214|      8|#define SC_FILE_TYPE_DF			0x04
  ------------------
              	if (file->type != SC_FILE_TYPE_DF && file->ef_structure != SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  221|      2|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (825:6): [True: 2, False: 2]
  |  Branch (825:39): [True: 0, False: 2]
  ------------------
  826|      0|		rec_nr = (int)file->record_count;
  827|      4|	else
  828|      4|		rec_nr = 0;
  829|      4|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, rec_nr);
  ------------------
  |  |  293|      4|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  830|      4|	if (!IS_CYBERFLEX(card))
  ------------------
  |  |   32|      4|#define IS_CYBERFLEX(card)	(card->type == SC_CARD_TYPE_FLEX_CYBER)
  ------------------
  |  Branch (830:6): [True: 4, False: 0]
  ------------------
  831|      4|		apdu.cla = 0xF0;
  832|      4|	apdu.data = sbuf;
  833|      4|	apdu.datalen = sendlen;
  834|      4|	apdu.lc = sendlen;
  835|       |
  836|      4|	r = sc_transmit_apdu(card, &apdu);
  837|      4|	LOG_TEST_RET(card->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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  838|      4|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  839|      4|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  840|      1|	return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  841|      4|}
card-flex.c:flex_card_ctl:
 1102|     59|{
 1103|     59|	switch (cmd) {
  ------------------
  |  Branch (1103:10): [True: 10, False: 49]
  ------------------
 1104|      1|	case SC_CARDCTL_GET_DEFAULT_KEY:
  ------------------
  |  Branch (1104:2): [True: 1, False: 58]
  ------------------
 1105|      1|		return flex_get_default_key(card,
 1106|      1|				(struct sc_cardctl_default_key *) ptr);
 1107|      0|	case SC_CARDCTL_CRYPTOFLEX_GENERATE_KEY:
  ------------------
  |  Branch (1107:2): [True: 0, False: 59]
  ------------------
 1108|      0|		return flex_generate_key(card,
 1109|      0|				(struct sc_cardctl_cryptoflex_genkey_info *) ptr);
 1110|      9|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1110:2): [True: 9, False: 50]
  ------------------
 1111|      9|		return flex_get_serialnr(card, (sc_serial_number_t *) ptr);
 1112|     59|	}
 1113|       |
 1114|     49|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     49|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1115|     59|}
card-flex.c:flex_get_default_key:
  999|      1|{
 1000|      1|	struct flex_private_data *prv = DRV_DATA(card);
  ------------------
  |  |  109|      1|#define DRV_DATA(card)	((struct flex_private_data *) (card)->drv_data)
  ------------------
 1001|      1|	const char *key;
 1002|       |
 1003|      1|	if (data->method != SC_AC_AUT || data->key_ref != prv->aak_key_ref)
  ------------------
  |  |  154|      2|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (1003:6): [True: 0, False: 1]
  |  Branch (1003:35): [True: 0, False: 1]
  ------------------
 1004|      0|		return SC_ERROR_NO_DEFAULT_KEY;
  ------------------
  |  |  106|      0|#define SC_ERROR_NO_DEFAULT_KEY			-1504
  ------------------
 1005|       |
 1006|       |	/* These seem to be the default AAKs used by Schlumberger */
 1007|      1|	switch (card->type) {
 1008|      0|	case SC_CARD_TYPE_FLEX_CRYPTO:
  ------------------
  |  Branch (1008:2): [True: 0, False: 1]
  ------------------
 1009|      0|		key = "2c:15:e5:26:e9:3e:8a:19";
 1010|      0|		break;
 1011|      1|	case SC_CARD_TYPE_FLEX_CYBER:
  ------------------
  |  Branch (1011:2): [True: 1, False: 0]
  ------------------
 1012|      1|		key = "ad:9f:61:fe:fa:20:ce:63";
 1013|      1|		break;
 1014|      0|	default:
  ------------------
  |  Branch (1014:2): [True: 0, False: 1]
  ------------------
 1015|      0|		return SC_ERROR_NO_DEFAULT_KEY;
  ------------------
  |  |  106|      0|#define SC_ERROR_NO_DEFAULT_KEY			-1504
  ------------------
 1016|      1|	}
 1017|       |
 1018|      1|	return sc_hex_to_bin(key, data->key_data, &data->len);
 1019|      1|}
card-flex.c:flex_get_serialnr:
 1064|      9|{
 1065|      9|	int       r;
 1066|      9|	u8        buf[16];
 1067|      9|	size_t    len;
 1068|      9|	sc_path_t tpath;
 1069|      9|	sc_file_t *tfile = NULL;
 1070|       |
 1071|      9|	if (!serial)
  ------------------
  |  Branch (1071:6): [True: 0, False: 9]
  ------------------
 1072|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1073|       |	/* see if we have cached serial number */
 1074|      9|	if (card->serialnr.len) {
  ------------------
  |  Branch (1074:6): [True: 0, False: 9]
  ------------------
 1075|      0|		memcpy(serial, &card->serialnr, sizeof(*serial));
 1076|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1077|      0|	}
 1078|       |	/* read EF_ICCSN */
 1079|      9|	sc_format_path("3F000002", &tpath);
 1080|      9|	r = sc_select_file(card, &tpath, &tfile);
 1081|      9|	if (r < 0)
  ------------------
  |  Branch (1081:6): [True: 9, False: 0]
  ------------------
 1082|      9|		return r;
 1083|      0|	len = tfile->size;
 1084|      0|	sc_file_free(tfile);
 1085|      0|	if (len != 8) {
  ------------------
  |  Branch (1085:6): [True: 0, False: 0]
  ------------------
 1086|      0|		sc_log(card->ctx,  "unexpected file length of EF_ICCSN (%lu)\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__
  |  |  ------------------
  ------------------
 1087|      0|			(unsigned long) len);
 1088|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1089|      0|	}
 1090|      0|	r = sc_read_binary(card, 0, buf, len, 0);
 1091|      0|	if (r < 0)
  ------------------
  |  Branch (1091:6): [True: 0, False: 0]
  ------------------
 1092|      0|		return r;
 1093|      0|	card->serialnr.len = len;
 1094|      0|	memcpy(card->serialnr.value, buf, len);
 1095|       |
 1096|      0|	memcpy(serial, &card->serialnr, sizeof(*serial));
 1097|       |
 1098|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1099|      0|}
card-flex.c:flex_pin_cmd:
 1164|     12|{
 1165|     12|	sc_apdu_t apdu;
 1166|     12|	int r;
 1167|     12|	int old_cla = -1;
 1168|       |
 1169|       |	/* Fix pin data */
 1170|     12|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  429|     12|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1171|     12|	flex_init_pin_info(&data->pin1, 0);
 1172|     12|	flex_init_pin_info(&data->pin2, 1);
 1173|       |
 1174|     12|	if (data->cmd == SC_PIN_CMD_VERIFY) {
  ------------------
  |  |  422|     12|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1174:6): [True: 3, False: 9]
  ------------------
 1175|      3|		r = flex_build_verify_apdu(card, &apdu, data);
 1176|      3|		if (r < 0)
  ------------------
  |  Branch (1176:7): [True: 0, False: 3]
  ------------------
 1177|      0|			return r;
 1178|      3|		data->apdu = &apdu;
 1179|      9|	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  423|     18|#define SC_PIN_CMD_CHANGE	1
  ------------------
              	} else if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  424|      9|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1179:13): [True: 0, False: 9]
  |  Branch (1179:47): [True: 0, False: 9]
  ------------------
 1180|      0|		if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1180:7): [True: 0, False: 0]
  ------------------
 1181|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1182|      0|		old_cla = card->cla;
 1183|      0|		if (!IS_CYBERFLEX(card))
  ------------------
  |  |   32|      0|#define IS_CYBERFLEX(card)	(card->type == SC_CARD_TYPE_FLEX_CYBER)
  ------------------
  |  Branch (1183:7): [True: 0, False: 0]
  ------------------
 1184|      0|			card->cla = 0xF0;
 1185|      0|	}
 1186|       |
 1187|       |	/* According to the Cryptoflex documentation, the card
 1188|       |	 * does not return the number of attempts left using
 1189|       |	 * the 63C0xx convention */
 1190|     12|	r = iso_ops->pin_cmd(card, data);
 1191|     12|	if (old_cla != -1)
  ------------------
  |  Branch (1191:6): [True: 0, False: 12]
  ------------------
 1192|      0|		card->cla = old_cla;
 1193|       |	data->apdu = NULL;
 1194|     12|	return r;
 1195|     12|}
card-flex.c:flex_init_pin_info:
 1155|     24|{
 1156|     24|	pin->encoding   = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  432|     24|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1157|     24|	pin->min_length = 4;
 1158|     24|	pin->max_length = 8;
 1159|     24|	pin->pad_length = 8;
 1160|     24|	pin->offset     = 5 + num * 8;
 1161|     24|}
card-flex.c:flex_build_verify_apdu:
 1119|      3|{
 1120|      3|	static u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1121|      3|	int r, len;
 1122|      3|	int cla = card->cla, ins;
 1123|       |
 1124|      3|	switch (data->pin_type) {
 1125|      2|	case SC_AC_CHV:
  ------------------
  |  |  151|      2|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1125:2): [True: 2, False: 1]
  ------------------
 1126|      2|		ins = 0x20;
 1127|      2|		break;
 1128|      1|	case SC_AC_AUT:
  ------------------
  |  |  154|      1|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (1128:2): [True: 1, False: 2]
  ------------------
 1129|       |		/* AUT keys cannot be entered through terminal */
 1130|      1|		if (data->flags & SC_PIN_CMD_USE_PINPAD)
  ------------------
  |  |  428|      1|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (1130:7): [True: 0, False: 1]
  ------------------
 1131|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1132|       |		/* Override CLA byte */
 1133|      1|		if (!IS_CYBERFLEX(card))
  ------------------
  |  |   32|      1|#define IS_CYBERFLEX(card)	(card->type == SC_CARD_TYPE_FLEX_CYBER)
  ------------------
  |  Branch (1133:7): [True: 0, False: 1]
  ------------------
 1134|      0|			cla = 0xF0;
 1135|      1|		ins = 0x2A;
 1136|      1|		break;
 1137|      0|	default:
  ------------------
  |  Branch (1137:2): [True: 0, False: 3]
  ------------------
 1138|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1139|      3|	}
 1140|       |	/* Copy the PIN, with padding */
 1141|      3|	if ((r = sc_build_pin(sbuf, sizeof(sbuf), &data->pin1, 1)) < 0)
  ------------------
  |  Branch (1141:6): [True: 0, False: 3]
  ------------------
 1142|      0|		return r;
 1143|      3|	len = r;
 1144|       |
 1145|      3|	sc_format_apdu(card, apdu, SC_APDU_CASE_3_SHORT, ins, 0, data->pin_reference);
  ------------------
  |  |  293|      3|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1146|      3|	apdu->cla = cla;
 1147|      3|	apdu->data = sbuf;
 1148|      3|	apdu->datalen = len;
 1149|      3|	apdu->lc = len;
 1150|       |
 1151|      3|	return 0;
 1152|      3|}
card-flex.c:cyberflex_match_card:
  152|  3.69k|{
  153|  3.69k|	int i;
  154|       |
  155|  3.69k|	i = _sc_match_atr(card, flex_atrs, NULL);
  156|  3.69k|	if (i < 0)
  ------------------
  |  Branch (156:6): [True: 3.65k, False: 44]
  ------------------
  157|  3.65k|		return 0;
  158|     44|	switch (flex_atrs[i].type) {
  ------------------
  |  Branch (158:10): [True: 16, False: 28]
  ------------------
  159|     16|	case SC_CARD_TYPE_FLEX_CYBER:
  ------------------
  |  Branch (159:2): [True: 16, False: 28]
  ------------------
  160|     16|		card->name = flex_atrs[i].name;
  161|     16|		card->type = flex_atrs[i].type;
  162|     16|		card->flags = flex_atrs[i].flags;
  163|     16|		return 1;
  164|     44|	}
  165|     28|	return 0;
  166|     44|}
card-flex.c:cyberflex_process_file_attrs:
  345|     10|{
  346|     10|	sc_context_t *ctx = card->ctx;
  347|     10|	const u8 *p = buf + 2;
  348|     10|	const u8 *pos;
  349|     10|	u8 b1, b2;
  350|     10|	int is_mf = 0;
  351|       |
  352|     10|	if (buflen < 14)
  ------------------
  |  Branch (352:6): [True: 0, False: 10]
  ------------------
  353|      0|		return -1;
  354|     10|	b1 = *p++;
  355|     10|	b2 = *p++;
  356|     10|	file->size = (b1 << 8) + b2;
  357|     10|	b1 = *p++;
  358|     10|	b2 = *p++;
  359|     10|	file->id = (b1 << 8) + b2;
  360|     10|	switch (*p) {
  361|      1|	case 0x01:
  ------------------
  |  Branch (361:2): [True: 1, False: 9]
  ------------------
  362|      1|		is_mf = 1;
  363|      1|		break;
  364|      5|	case 0x02:
  ------------------
  |  Branch (364:2): [True: 5, False: 5]
  ------------------
  365|      5|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      5|#define SC_FILE_TYPE_DF			0x04
  ------------------
  366|      5|		break;
  367|      0|	case 0x04:
  ------------------
  |  Branch (367:2): [True: 0, False: 10]
  ------------------
  368|      0|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  369|      0|		break;
  370|      4|	default:
  ------------------
  |  Branch (370:2): [True: 4, False: 6]
  ------------------
  371|      4|		sc_log(ctx,  "invalid file type: 0x%02X\n", *p);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  372|      4|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      4|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  373|     10|	}
  374|       |
  375|      6|	if (is_mf) {
  ------------------
  |  Branch (375:6): [True: 1, False: 5]
  ------------------
  376|      1|		sc_file_add_acl_entry(file, SC_AC_OP_LIST_FILES, SC_AC_AUT, 0);
  ------------------
  |  |  172|      1|#define SC_AC_OP_LIST_FILES		6
  ------------------
              		sc_file_add_acl_entry(file, SC_AC_OP_LIST_FILES, SC_AC_AUT, 0);
  ------------------
  |  |  154|      1|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  377|      1|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, SC_AC_AUT, 0);
  ------------------
  |  |  168|      1|#define SC_AC_OP_DELETE			2
  ------------------
              		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, SC_AC_AUT, 0);
  ------------------
  |  |  154|      1|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  378|      1|		sc_file_add_acl_entry(file, SC_AC_OP_CREATE, SC_AC_AUT, 0);
  ------------------
  |  |  169|      1|#define SC_AC_OP_CREATE			3
  ------------------
              		sc_file_add_acl_entry(file, SC_AC_OP_CREATE, SC_AC_AUT, 0);
  ------------------
  |  |  154|      1|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  379|      5|	} else {
  380|      5|		p += 2;
  381|      5|		if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|      5|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (381:7): [True: 5, False: 0]
  ------------------
  382|      5|			add_acl_entry(card, file, SC_AC_OP_LIST_FILES, (u8)(p[0] >> 4));
  ------------------
  |  |  172|      5|#define SC_AC_OP_LIST_FILES		6
  ------------------
  383|      5|			add_acl_entry(card, file, SC_AC_OP_DELETE, (u8)(p[1] >> 4));
  ------------------
  |  |  168|      5|#define SC_AC_OP_DELETE			2
  ------------------
  384|      5|			add_acl_entry(card, file, SC_AC_OP_CREATE, (u8)(p[1] & 0x0F));
  ------------------
  |  |  169|      5|#define SC_AC_OP_CREATE			3
  ------------------
  385|      5|		} else { /* EF */
  386|      0|			add_acl_entry(card, file, SC_AC_OP_READ, (u8)(p[0] >> 4));
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
  387|      0|		}
  388|      5|	}
  389|      6|	if (file->type != SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|      6|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (389:6): [True: 1, False: 5]
  ------------------
  390|      1|		add_acl_entry(card, file, SC_AC_OP_REHABILITATE, (u8)(p[2] >> 4));
  ------------------
  |  |  170|      1|#define SC_AC_OP_REHABILITATE		4
  ------------------
  391|      1|		add_acl_entry(card, file, SC_AC_OP_INVALIDATE, (u8)(p[2] & 0x0F));
  ------------------
  |  |  171|      1|#define SC_AC_OP_INVALIDATE		5
  ------------------
  392|      1|	}
  393|      6|	pos = p;
  394|      6|	p += 3;
  395|      6|	if (*p++)
  ------------------
  |  Branch (395:6): [True: 2, False: 4]
  ------------------
  396|      2|		file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      2|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  397|      4|	else
  398|      4|		file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|      4|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  399|      6|	p++;
  400|      6|	if (0 == is_mf) {
  ------------------
  |  Branch (400:6): [True: 5, False: 1]
  ------------------
  401|      5|		p++;
  402|      5|		switch (*p) {
  403|      3|		case  0x00:
  ------------------
  |  Branch (403:3): [True: 3, False: 2]
  ------------------
  404|      3|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      3|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  405|      3|			break;
  406|      0|		case  0x01:
  ------------------
  |  Branch (406:3): [True: 0, False: 5]
  ------------------
  407|      0|			file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  408|      0|			break;
  409|      1|		case  0x02:
  ------------------
  |  Branch (409:3): [True: 1, False: 4]
  ------------------
  410|      1|			file->ef_structure = SC_FILE_EF_LINEAR_VARIABLE;
  ------------------
  |  |  224|      1|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  411|      1|			break;
  412|      0|		case  0x03:
  ------------------
  |  Branch (412:3): [True: 0, False: 5]
  ------------------
  413|      0|			file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  414|      0|			break;
  415|      0|		case  0x04:
  ------------------
  |  Branch (415:3): [True: 0, False: 5]
  ------------------
  416|      0|			break;
  417|      1|		default:
  ------------------
  |  Branch (417:3): [True: 1, False: 4]
  ------------------
  418|      1|			sc_log(ctx,  "invalid file type: 0x%02X\n", *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__
  |  |  ------------------
  ------------------
  419|      1|			return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      1|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  420|      5|		}
  421|      4|		switch (file->ef_structure) {
  ------------------
  |  Branch (421:11): [True: 4, False: 0]
  ------------------
  422|      3|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|      3|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (422:3): [True: 3, False: 1]
  ------------------
  423|      3|			add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(pos[0] & 0x0F));
  ------------------
  |  |  189|      3|#define SC_AC_OP_UPDATE			23
  ------------------
  424|      3|			break;
  425|      0|		case SC_FILE_EF_LINEAR_FIXED:
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (425:3): [True: 0, False: 4]
  ------------------
  426|      1|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      1|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (426:3): [True: 1, False: 3]
  ------------------
  427|      1|			add_acl_entry(card, file, SC_AC_OP_UPDATE, (u8)(pos[0] & 0x0F));
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
  428|      1|			break;
  429|      0|		case SC_FILE_EF_CYCLIC:
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (429:3): [True: 0, False: 4]
  ------------------
  430|      0|			break;
  431|      4|		}
  432|      4|	}
  433|      5|	return 0;
  434|      6|}
card-flex.c:cyberflex_construct_file_attrs:
  753|      1|{
  754|      1|	u8 *p = buf;
  755|      1|	size_t size = file->size;
  756|       |
  757|       |	/* cyberflex wants input parameters length added */
  758|      1|	switch (file->type) {
  759|      0|	case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (759:2): [True: 0, False: 1]
  ------------------
  760|      0|		size += 24;
  761|      0|		break;
  762|      0|	case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (762:2): [True: 0, False: 1]
  ------------------
  763|      1|	default:
  ------------------
  |  Branch (763:2): [True: 1, False: 0]
  ------------------
  764|      1|		size += 16;
  765|      1|		break;
  766|      1|	}
  767|       |
  768|      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__
  |  |  ------------------
  ------------------
  769|      1|		 "Creating %02x:%02x, size %"SC_FORMAT_LEN_SIZE_T"u %02"SC_FORMAT_LEN_SIZE_T"x:%02"SC_FORMAT_LEN_SIZE_T"x\n",
  770|      1|		 file->id >> 8,
  771|      1|		 file->id & 0xFF,
  772|      1|		 size,
  773|      1|		 size >> 8,
  774|      1|		 size & 0xFF);
  775|       |
  776|      1|	p[0] = size >> 8;
  777|      1|	p[1] = size & 0xFF;
  778|      1|	p[2] = file->id >> 8;
  779|      1|	p[3] = file->id & 0xFF;
  780|      1|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|      1|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (780:6): [True: 0, False: 1]
  ------------------
  781|      0|		p[4] = 0x20;
  782|      1|	else
  783|      1|		switch (file->ef_structure) {
  784|      0|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (784:3): [True: 0, False: 1]
  ------------------
  785|      0|			p[4] = 0x02;
  786|      0|			break;
  787|      0|		case SC_FILE_EF_LINEAR_FIXED:
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (787:3): [True: 0, False: 1]
  ------------------
  788|      0|			p[4] = 0x0C;
  789|      0|			break;
  790|      0|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (790:3): [True: 0, False: 1]
  ------------------
  791|      0|			p[4] = 0x19;
  792|      0|			break;
  793|      0|		case SC_FILE_EF_CYCLIC:
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (793:3): [True: 0, False: 1]
  ------------------
  794|      0|			p[4] = 0x1D;
  795|      0|			break;
  796|      1|		default:
  ------------------
  |  Branch (796:3): [True: 1, False: 0]
  ------------------
  797|      1|			sc_log(card->ctx,  "Invalid EF structure\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  798|      1|			return -1;
  799|      1|		}
  800|      0|	p[5] = 0x01;	/* status?? */
  801|      0|	p[6] = p[7] = 0;
  802|       |
  803|      0|	*buflen = 16;
  804|       |
  805|      0|	p[8] = p[9] = p[11] = 0xFF;
  806|      0|	p[10] = p[12] = p[13] = p[14] = p[15] = 0x00;
  807|      0|	return 0;
  808|      1|}

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

sc_get_gids_driver:
 2196|  3.69k|{
 2197|  3.69k|	return sc_get_driver();
 2198|  3.69k|}
card-gids.c:sc_get_driver:
 2151|  3.69k|{
 2152|       |
 2153|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2153:6): [True: 1, False: 3.69k]
  ------------------
 2154|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 2155|       |
 2156|  3.69k|	gids_ops.match_card = gids_match_card;
 2157|  3.69k|	gids_ops.init = gids_init;
 2158|  3.69k|	gids_ops.finish = gids_finish;
 2159|  3.69k|	gids_ops.read_binary = gids_read_binary;
 2160|  3.69k|	gids_ops.write_binary = NULL;
 2161|  3.69k|	gids_ops.update_binary = NULL;
 2162|  3.69k|	gids_ops.erase_binary = NULL;
 2163|  3.69k|	gids_ops.read_record = NULL;
 2164|  3.69k|	gids_ops.write_record = NULL;
 2165|  3.69k|	gids_ops.append_record = NULL;
 2166|  3.69k|	gids_ops.update_record = NULL;
 2167|  3.69k|	gids_ops.select_file = gids_select_file;
 2168|  3.69k|	gids_ops.get_response = iso_ops->get_response;
 2169|  3.69k|	gids_ops.get_challenge = NULL;
 2170|  3.69k|	gids_ops.verify = NULL; // see pin_cmd
 2171|  3.69k|	gids_ops.logout = gids_logout;
 2172|  3.69k|	gids_ops.restore_security_env = NULL;
 2173|  3.69k|	gids_ops.set_security_env = gids_set_security_env;
 2174|  3.69k|	gids_ops.decipher = gids_decipher;
 2175|  3.69k|	gids_ops.compute_signature = iso_ops->compute_signature;
 2176|  3.69k|	gids_ops.change_reference_data = NULL; // see pin_cmd
 2177|  3.69k|	gids_ops.reset_retry_counter = NULL; // see pin_cmd
 2178|  3.69k|	gids_ops.create_file = iso_ops->create_file;
 2179|  3.69k|	gids_ops.delete_file = NULL;
 2180|  3.69k|	gids_ops.list_files = NULL;
 2181|  3.69k|	gids_ops.check_sw = iso_ops->check_sw;
 2182|  3.69k|	gids_ops.card_ctl = gids_card_ctl;
 2183|  3.69k|	gids_ops.process_fci = iso_ops->process_fci;
 2184|  3.69k|	gids_ops.construct_fci = iso_ops->construct_fci;
 2185|  3.69k|	gids_ops.pin_cmd = gids_pin_cmd;
 2186|  3.69k|	gids_ops.get_data = NULL;
 2187|  3.69k|	gids_ops.put_data = NULL;
 2188|  3.69k|	gids_ops.delete_record = NULL;
 2189|  3.69k|	gids_ops.read_public_key = gids_read_public_key;
 2190|  3.69k|	gids_ops.card_reader_lock_obtained = gids_card_reader_lock_obtained;
 2191|       |
 2192|  3.69k|	return &gids_drv;
 2193|  3.69k|}
card-gids.c:gids_match_card:
  567|    502|{
  568|    502|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  569|    502|	int r,i;
  570|    502|	size_t resplen = sizeof(rbuf);
  571|    502|	const u8 *tag;
  572|    502|	size_t taglen;
  573|    502|	const u8 *aid;
  574|    502|	size_t aidlen;
  575|       |
  576|    502|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    502|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    502|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    502|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 502]
  |  |  ------------------
  ------------------
  577|       |
  578|       |	/* Detect by selecting applet */
  579|    502|	r = gids_select_aid(card, gids_aid.value, gids_aid.len, rbuf, &resplen);
  580|    502|	if (r<0) return 0;
  ------------------
  |  Branch (580:6): [True: 475, False: 27]
  ------------------
  581|       |
  582|     27|	card->type = SC_CARD_TYPE_GIDS_GENERIC;
  583|     27|	if (resplen > 2) {
  ------------------
  |  Branch (583:6): [True: 13, False: 14]
  ------------------
  584|     13|		tag = sc_asn1_find_tag(card->ctx, rbuf, resplen, GIDS_APPLICATION_TEMPLATE_TAG, &taglen);
  ------------------
  |  |  105|     13|#define GIDS_APPLICATION_TEMPLATE_TAG 0x61
  ------------------
  585|     13|		if (tag != NULL) {
  ------------------
  |  Branch (585:7): [True: 0, False: 13]
  ------------------
  586|      0|			aid = sc_asn1_find_tag(card->ctx, tag, taglen, GIDS_APPLICATION_AID_TAG, &aidlen);
  ------------------
  |  |  106|      0|#define GIDS_APPLICATION_AID_TAG 0x4F
  ------------------
  587|      0|			if (aid != NULL ) {
  ------------------
  |  Branch (587:8): [True: 0, False: 0]
  ------------------
  588|      0|				sc_log(card->ctx, "found AID");
  ------------------
  |  |   71|      0|#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|      0|				for (i = 0; gids_aids[i].len_long != 0; i++) {
  ------------------
  |  Branch (589:17): [True: 0, False: 0]
  ------------------
  590|      0|					if ( aidlen > gids_aids[i].len_long && memcmp(aid, gids_aids[i].value,
  ------------------
  |  Branch (590:11): [True: 0, False: 0]
  |  Branch (590:45): [True: 0, False: 0]
  ------------------
  591|      0|									gids_aids[i].len_long) == 0) {
  592|      0|						card->type = gids_aids[i].enumtag;
  593|      0|						break;
  594|      0|					}
  595|      0|				}
  596|      0|			}
  597|      0|		}
  598|     13|	}
  599|       |
  600|     27|	return 1;
  601|    502|}
card-gids.c:gids_select_aid:
  283|    502|{
  284|    502|	sc_apdu_t apdu;
  285|    502|	int r;
  286|       |
  287|    502|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    502|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    502|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    502|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 502]
  |  |  ------------------
  ------------------
  288|    502|	sc_log(card->ctx,
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 502, False: 0]
  |  |  ------------------
  ------------------
  289|    502|		 "Got args: aid=%p, aidlen=%"SC_FORMAT_LEN_SIZE_T"u, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n",
  290|    502|		 aid, aidlen, response, responselen ? *responselen : 0);
  291|       |
  292|    502|	sc_format_apdu(card, &apdu,
  293|    502|		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|    502|#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|    502|#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|    502|#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|    502|#define P2_SELECT_FIRST_OR_ONLY_OCCURENCE 0x00
  ------------------
  |  Branch (293:3): [True: 0, False: 502]
  ------------------
  294|    502|	apdu.lc = aidlen;
  295|    502|	apdu.data = aid;
  296|    502|	apdu.datalen = aidlen;
  297|    502|	apdu.resp = response;
  298|    502|	apdu.resplen = responselen ? *responselen : 0;
  ------------------
  |  Branch (298:17): [True: 502, False: 0]
  ------------------
  299|    502|	apdu.le = response == NULL ? 0 : 256; /* could be 21 for fci */
  ------------------
  |  Branch (299:12): [True: 0, False: 502]
  ------------------
  300|       |
  301|    502|	r = sc_transmit_apdu(card, &apdu);
  302|    502|	if (responselen)
  ------------------
  |  Branch (302:6): [True: 502, False: 0]
  ------------------
  303|    502|		*responselen = apdu.resplen;
  304|    502|	LOG_TEST_RET(card->ctx, r, "gids select failed");
  ------------------
  |  |  174|    502|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    502|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    502|	int _ret = (r); \
  |  |  |  |  168|    502|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 500]
  |  |  |  |  ------------------
  |  |  |  |  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|    502|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 500]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  305|    500|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|    500|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    500|	int _ret = r; \
  |  |  155|    500|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 500, False: 0]
  |  |  ------------------
  |  |  156|    500|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    473|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 473, False: 27]
  |  |  ------------------
  |  |  157|    500|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    500|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    500|	return _ret; \
  |  |  163|    500|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  306|    500|}
card-gids.c:gids_init:
  635|     27|{
  636|     27|	unsigned long flags;
  637|     27|	struct gids_private_data *data;
  638|     27|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  639|       |
  640|       |	// cache some data in memory
  641|     27|	data = (struct gids_private_data*) calloc(1, sizeof(struct gids_private_data));
  642|     27|	if (!data) {
  ------------------
  |  Branch (642:6): [True: 0, False: 27]
  ------------------
  643|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  644|      0|	}
  645|     27|	memset(data, 0, sizeof(struct gids_private_data));
  646|     27|	card->drv_data = data;
  647|       |	// invalidate the master file and cmap file cache
  648|     27|	data->cmapfilesize = sizeof(data->cmapfile);
  649|     27|	data->masterfilesize = sizeof(data->masterfile);
  650|       |
  651|       |	/* supported RSA keys and how padding is done */
  652|     27|	flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  120|     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) */
  |  |  ------------------
  |  |  |  |  118|     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) */
  |  |  ------------------
  |  |  |  |  119|     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 | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  142|     27|#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;
  ------------------
  |  |  102|     27|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  653|       |
  654|       |	/* fix me: add other algorithms when the gids specification will tell how to extract the algo id from the FCP */
  655|     27|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  656|     27|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  657|     27|	_sc_card_add_rsa_alg(card, 3072, flags, 0);
  658|     27|	_sc_card_add_rsa_alg(card, 4096, flags, 0);
  659|       |
  660|     27|	return SC_SUCCESS;
  ------------------
  |  |   28|     27|#define SC_SUCCESS				0
  ------------------
  661|     27|}
card-gids.c:gids_finish:
  665|     27|{
  666|     27|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  667|       |	/* free the private data */
  668|     27|	if (card->drv_data) {
  ------------------
  |  Branch (668:6): [True: 27, False: 0]
  ------------------
  669|     27|		free(card->drv_data);
  670|       |		card->drv_data = NULL;
  671|     27|	}
  672|     27|	return 0;
  673|     27|}
card-gids.c:gids_read_binary:
 1039|      2|		unsigned char *buf, size_t count, unsigned long *flags) {
 1040|      2|	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
 1041|      2|	struct sc_context *ctx = card->ctx;
 1042|      2|	int r;
 1043|      2|	int size;
 1044|       |
 1045|      2|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1046|       |
 1047|      2|	if (! data->currentDO || ! data->currentEFID) {
  ------------------
  |  Branch (1047:6): [True: 2, False: 0]
  |  Branch (1047:27): [True: 0, False: 0]
  ------------------
 1048|      2|		LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1049|      2|	}
 1050|      0|	if (data->state != GIDS_STATE_READ_DATA_PRESENT) {
  ------------------
  |  |   58|      0|#define GIDS_STATE_READ_DATA_PRESENT 1
  ------------------
  |  Branch (1050:6): [True: 0, False: 0]
  ------------------
 1051|       |		// this function is called to read the certificate only
 1052|      0|		u8 buffer[SC_MAX_EXT_APDU_BUFFER_SIZE];
 1053|      0|		size_t buffersize = sizeof(buffer);
 1054|      0|		r = gids_get_DO(card, data->currentEFID, data->currentDO, buffer, &(buffersize));
 1055|      0|		if (r <0) return r;
  ------------------
  |  Branch (1055:7): [True: 0, False: 0]
  ------------------
 1056|      0|		if (buffersize < 4) {
  ------------------
  |  Branch (1056:7): [True: 0, False: 0]
  ------------------
 1057|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1058|      0|		}
 1059|      0|		if (buffer[0] == 1 && buffer[1] == 0) {
  ------------------
  |  Branch (1059:7): [True: 0, False: 0]
  |  Branch (1059:25): [True: 0, False: 0]
  ------------------
 1060|      0|			if (flags)
  ------------------
  |  Branch (1060:8): [True: 0, False: 0]
  ------------------
 1061|      0|				*flags |= SC_FILE_FLAG_COMPRESSED_ZLIB;
  ------------------
  |  |  231|      0|#define SC_FILE_FLAG_COMPRESSED_ZLIB		0x02
  ------------------
 1062|       |			/* compressed data are starting on position buffer + 4 */
 1063|      0|			data->buffersize = buffersize - 4;
 1064|      0|			memcpy(data->buffer, buffer + 4, buffersize - 4);
 1065|      0|		} else {
 1066|      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__
  |  |  ------------------
  ------------------
 1067|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1068|      0|		}
 1069|      0|		data->state = GIDS_STATE_READ_DATA_PRESENT;
  ------------------
  |  |   58|      0|#define GIDS_STATE_READ_DATA_PRESENT 1
  ------------------
 1070|      0|	}
 1071|      0|	if (offset >= data->buffersize) {
  ------------------
  |  Branch (1071:6): [True: 0, False: 0]
  ------------------
 1072|      0|		return 0;
 1073|      0|	}
 1074|      0|	size = (int) MIN((data->buffersize - offset), count);
  ------------------
  |  |   70|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1075|      0|	memcpy(buf, data->buffer + offset, size);
 1076|      0|	return size;
 1077|      0|}
card-gids.c:gids_get_DO:
  210|     81|static int gids_get_DO(sc_card_t* card, int fileIdentifier, int dataObjectIdentifier, u8* response, size_t *responselen) {
  211|     81|	sc_apdu_t apdu;
  212|     81|	int r;
  213|     81|	u8 data[4] = {0x5C, 0x02, (dataObjectIdentifier&0xFF00)>>8, (dataObjectIdentifier&0xFF)};
  214|     81|	size_t datasize = 0;
  215|     81|	const u8* p;
  216|     81|	u8 buffer[MAX_GIDS_FILE_SIZE];
  217|     81|	size_t buffer_len = sizeof(buffer);
  218|       |
  219|     81|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     81|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     81|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     81|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 81]
  |  |  ------------------
  ------------------
  220|     81|	sc_log(card->ctx,
  ------------------
  |  |   71|    162|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 81, False: 0]
  |  |  ------------------
  ------------------
  221|     81|		 "Got args: fileIdentifier=%x, dataObjectIdentifier=%x, response=%p, responselen=%"SC_FORMAT_LEN_SIZE_T"u\n",
  222|     81|		 fileIdentifier, dataObjectIdentifier, response,
  223|     81|		 responselen ? *responselen : 0);
  224|       |
  225|     81|	sc_format_apdu(card, &apdu,
  226|     81|		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|     81|#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|     81|#define INS_GET_DATA 0xCB
  ------------------
  |  Branch (226:3): [True: 0, False: 81]
  ------------------
  227|     81|	apdu.lc = 04;
  228|     81|	apdu.data = data;
  229|     81|	apdu.datalen = 04;
  230|     81|	apdu.resp = buffer;
  231|     81|	apdu.resplen = buffer_len;
  232|     81|	apdu.le = 256;
  233|       |
  234|     81|	r = sc_transmit_apdu(card, &apdu);
  235|     81|	LOG_TEST_RET(card->ctx, r, "gids get data failed");
  ------------------
  |  |  174|     81|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     81|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     81|	int _ret = (r); \
  |  |  |  |  168|     81|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 81]
  |  |  |  |  ------------------
  |  |  |  |  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|     81|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|     81|	LOG_TEST_RET(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2), "invalid return");
  ------------------
  |  |  174|     81|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     81|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     81|	int _ret = (r); \
  |  |  |  |  168|     81|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 47, False: 34]
  |  |  |  |  ------------------
  |  |  |  |  169|     47|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     47|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     47|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     47|		return _ret; \
  |  |  |  |  172|     47|	} \
  |  |  |  |  173|     81|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|     34|	buffer_len = apdu.resplen;
  238|       |
  239|     34|	p = sc_asn1_find_tag(card->ctx, buffer, buffer_len, dataObjectIdentifier, &datasize);
  240|     34|	if (!p) {
  ------------------
  |  Branch (240:6): [True: 17, False: 17]
  ------------------
  241|     17|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|     17|	}
  243|     17|	if (response && responselen) {
  ------------------
  |  Branch (243:6): [True: 17, False: 0]
  |  Branch (243:18): [True: 17, False: 0]
  ------------------
  244|     17|		if (datasize > *responselen) {
  ------------------
  |  Branch (244:7): [True: 0, False: 17]
  ------------------
  245|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|      0|		}
  247|     17|		memcpy(response, p, datasize);
  248|     17|		*responselen = datasize;
  249|     17|	}
  250|     17|	return SC_SUCCESS;
  ------------------
  |  |   28|     17|#define SC_SUCCESS				0
  ------------------
  251|     17|}
card-gids.c:gids_select_file:
  971|    287|			   struct sc_file **file_out) {
  972|    287|	struct sc_file *file = NULL;
  973|    287|	struct sc_context *ctx = card->ctx;
  974|    287|	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
  975|       |
  976|    287|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    287|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    287|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    287|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    287|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 287]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  977|       |
  978|    287|	data->state = GIDS_STATE_NONE;
  ------------------
  |  |   57|    287|#define GIDS_STATE_NONE 0
  ------------------
  979|    287|	data->currentDO = 0;
  980|    287|	data->currentEFID = 0;
  981|    287|	if (in_path->len == 4 && in_path->value[0] == 0xA0) {
  ------------------
  |  Branch (981:6): [True: 129, False: 158]
  |  Branch (981:27): [True: 0, False: 129]
  ------------------
  982|       |		// is it a DO pseudo file ?
  983|       |		// yes, succeed
  984|      0|		data->currentEFID = in_path->value[1] + (in_path->value[0]<<8);
  985|      0|		data->currentDO = in_path->value[3] + (in_path->value[2]<<8);
  986|       |
  987|      0|		if (file_out) {
  ------------------
  |  Branch (987:7): [True: 0, False: 0]
  ------------------
  988|      0|			file = sc_file_new();
  989|      0|			if (file == NULL)
  ------------------
  |  Branch (989:8): [True: 0, False: 0]
  ------------------
  990|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  991|      0|			file->path = *in_path;
  992|      0|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  993|      0|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  994|      0|			file->size = SC_MAX_EXT_APDU_BUFFER_SIZE;
  ------------------
  |  |   37|      0|#define SC_MAX_EXT_APDU_BUFFER_SIZE	65538
  ------------------
  995|      0|			*file_out = file;
  996|      0|		}
  997|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  998|    287|	} else if (in_path->len == 4 && in_path->value[0] == 0x3F && in_path->value[1] == 0xFF &&  in_path->type == SC_PATH_TYPE_PATH) {
  ------------------
  |  |  119|      8|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (998:13): [True: 129, False: 158]
  |  Branch (998:34): [True: 117, False: 12]
  |  Branch (998:63): [True: 8, False: 109]
  |  Branch (998:93): [True: 7, False: 1]
  ------------------
  999|       |		// GIDS does not allow a select with a path containing a DF
 1000|       |		// replace the file selection from SC_PATH_TYPE_PATH to SC_PATH_TYPE_FILE_ID
 1001|      7|		struct sc_path key_path;
 1002|      7|		memset(&key_path, 0, sizeof(key_path));
 1003|      7|		key_path.len = 2;
 1004|      7|		key_path.value[0] = in_path->value[2];
 1005|      7|		key_path.value[1] = in_path->value[3];
 1006|      7|		key_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      7|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1007|      7|		return iso_ops->select_file(card, &key_path, file_out);
 1008|    280|	} else {
 1009|    280|		return iso_ops->select_file(card, in_path, file_out);
 1010|    280|	}
 1011|    287|}
card-gids.c:gids_card_ctl:
 2100|    119|{
 2101|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2102|    119|	switch (cmd) {
 2103|     27|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (2103:3): [True: 27, False: 92]
  ------------------
 2104|     27|			return gids_get_serialnr(card, (sc_serial_number_t *) ptr);
 2105|     38|		case SC_CARDCTL_GIDS_GET_ALL_CONTAINERS:
  ------------------
  |  Branch (2105:3): [True: 38, False: 81]
  ------------------
 2106|     38|			return gids_get_all_containers(card, (size_t*) ptr);
 2107|      0|		case SC_CARDCTL_GIDS_GET_CONTAINER_DETAIL:
  ------------------
  |  Branch (2107:3): [True: 0, False: 119]
  ------------------
 2108|      0|			return gids_get_container_detail(card, (sc_cardctl_gids_get_container_t*) ptr);
 2109|     17|		case SC_CARDCTL_GIDS_SELECT_KEY_REFERENCE:
  ------------------
  |  Branch (2109:3): [True: 17, False: 102]
  ------------------
 2110|     17|			return gids_select_key_reference(card, (sc_pkcs15_prkey_info_t*) ptr);
 2111|      0|		case SC_CARDCTL_GIDS_CREATE_KEY:
  ------------------
  |  Branch (2111:3): [True: 0, False: 119]
  ------------------
 2112|      0|			return gids_create_keyfile(card, (sc_pkcs15_object_t*) ptr);
 2113|      0|		case SC_CARDCTL_GIDS_GENERATE_KEY:
  ------------------
  |  Branch (2113:3): [True: 0, False: 119]
  ------------------
 2114|      0|			return gids_generate_key(card, ((struct sc_cardctl_gids_genkey*) ptr)->object, ((struct sc_cardctl_gids_genkey*) ptr)->pubkey);
 2115|      0|		case SC_CARDCTL_GIDS_IMPORT_KEY:
  ------------------
  |  Branch (2115:3): [True: 0, False: 119]
  ------------------
 2116|      0|			return gids_import_key(card, ((struct sc_cardctl_gids_importkey*) ptr)->object, ((struct sc_cardctl_gids_importkey*) ptr)->key);
 2117|      0|		case SC_CARDCTL_GIDS_SAVE_CERT:
  ------------------
  |  Branch (2117:3): [True: 0, False: 119]
  ------------------
 2118|      0|			return gids_save_certificate(card, ((struct sc_cardctl_gids_save_cert*) ptr)->certobject,
 2119|      0|										((struct sc_cardctl_gids_save_cert*) ptr)->privkeyobject, ((struct sc_cardctl_gids_save_cert*) ptr)->path);
 2120|      0|		case SC_CARDCTL_GIDS_DELETE_CERT:
  ------------------
  |  Branch (2120:3): [True: 0, False: 119]
  ------------------
 2121|      0|			return gids_delete_cert(card, (sc_pkcs15_object_t*) ptr);
 2122|      0|		case SC_CARDCTL_GIDS_DELETE_KEY:
  ------------------
  |  Branch (2122:3): [True: 0, False: 119]
  ------------------
 2123|      0|			return gids_delete_key(card, (sc_pkcs15_object_t*) ptr);
 2124|      0|		case SC_CARDCTL_GIDS_INITIALIZE:
  ------------------
  |  Branch (2124:3): [True: 0, False: 119]
  ------------------
 2125|      0|			return gids_initialize(card, (sc_cardctl_gids_init_param_t*) ptr);
 2126|      0|		case SC_CARDCTL_GIDS_SET_ADMIN_KEY:
  ------------------
  |  Branch (2126:3): [True: 0, False: 119]
  ------------------
 2127|      0|			return gids_set_administrator_key(card, (u8*) ptr);
 2128|      0|		case SC_CARDCTL_GIDS_AUTHENTICATE_ADMIN:
  ------------------
  |  Branch (2128:3): [True: 0, False: 119]
  ------------------
 2129|      0|			return gids_authenticate_admin(card, (u8*) ptr);
 2130|     37|		default:
  ------------------
  |  Branch (2130:3): [True: 37, False: 82]
  ------------------
 2131|     37|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     37|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2132|    119|	}
 2133|    119|}
card-gids.c:gids_get_serialnr:
  606|     27|{
  607|     27|	int r;
  608|     27|	u8 buffer[SC_MAX_EXT_APDU_BUFFER_SIZE];
  609|     27|	size_t buffersize;
  610|       |
  611|     27|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  612|       |
  613|     27|	buffersize = sizeof(buffer);
  614|     27|	r = gids_read_gidsfile(card, "", "cardid", buffer, &buffersize);
  615|     27|	LOG_TEST_RET(card->ctx, r, "unable to read cardid");
  ------------------
  |  |  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: 27, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  616|       |
  617|      0|	if (SC_MAX_SERIALNR < buffersize)
  ------------------
  |  |  372|      0|#define SC_MAX_SERIALNR         32
  ------------------
  |  Branch (617:6): [True: 0, False: 0]
  ------------------
  618|      0|	{
  619|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  620|      0|	}
  621|       |
  622|       |	/* cache serial number */
  623|      0|	card->serialnr.len = buffersize;
  624|      0|	memcpy(card->serialnr.value, buffer, card->serialnr.len);
  625|       |
  626|       |	/* return cached serial number */
  627|      0|	if (serial)
  ------------------
  |  Branch (627:6): [True: 0, False: 0]
  ------------------
  628|      0|		memcpy(serial, &card->serialnr, sizeof(*serial));
  629|       |
  630|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|      0|}
card-gids.c:gids_read_gidsfile:
  389|     35|static int gids_read_gidsfile(sc_card_t* card, char *directory, char *filename, u8* response, size_t *responselen) {
  390|     35|	struct gids_private_data* privatedata = (struct gids_private_data*) card->drv_data;
  391|     35|	int r;
  392|     35|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  393|     35|	if (privatedata->masterfilesize == sizeof(privatedata->masterfile)) {
  ------------------
  |  Branch (393:6): [True: 26, False: 9]
  ------------------
  394|     26|		r = gids_read_masterfile(card);
  395|     26|		LOG_TEST_RET(card->ctx, r, "unable to get the masterfile");
  ------------------
  |  |  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: 22, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  396|     26|	}
  397|     13|	r = gids_read_gidsfile_without_cache(card, privatedata->masterfile, privatedata->masterfilesize,
  398|     13|		directory, filename, response, responselen);
  399|     13|	LOG_TEST_RET(card->ctx, r, "unable to read the file");
  ------------------
  |  |  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: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  400|      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]
  |  |  ------------------
  ------------------
  401|      0|}
card-gids.c:gids_read_masterfile:
  344|     81|static int gids_read_masterfile(sc_card_t* card) {
  345|     81|	struct gids_private_data* data = (struct gids_private_data*) card->drv_data;
  346|     81|	int r = SC_SUCCESS;
  ------------------
  |  |   28|     81|#define SC_SUCCESS				0
  ------------------
  347|       |
  348|     81|	data->masterfilesize = sizeof(data->masterfile);
  349|     81|	r = gids_get_DO(card, MF_FI, MF_DO, data->masterfile, &data->masterfilesize);
  ------------------
  |  |   66|     81|#define MF_FI UserCreateDeleteDirAc_FI
  |  |  ------------------
  |  |  |  |   63|     81|#define UserCreateDeleteDirAc_FI 0xA000
  |  |  ------------------
  ------------------
              	r = gids_get_DO(card, MF_FI, MF_DO, data->masterfile, &data->masterfilesize);
  ------------------
  |  |   67|     81|#define MF_DO 0xDF1F
  ------------------
  350|     81|	if (r<0) {
  ------------------
  |  Branch (350:6): [True: 64, False: 17]
  ------------------
  351|     64|		data->masterfilesize = sizeof(data->masterfile);
  352|     64|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|     64|	}
  354|     17|	if (data->masterfilesize < 1 || data->masterfile[0] != 1) {
  ------------------
  |  Branch (354:6): [True: 2, False: 15]
  |  Branch (354:34): [True: 3, False: 12]
  ------------------
  355|      5|		data->masterfilesize = sizeof(data->masterfile);
  356|      5|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  357|      5|	}
  358|     12|	return r;
  359|     17|}
card-gids.c:gids_read_gidsfile_without_cache:
  312|     13|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) {
  313|     13|	int r;
  314|     13|	int fileIdentifier;
  315|     13|	int dataObjectIdentifier;
  316|       |
  317|     13|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  318|     13|	r = gids_get_identifiers(card, masterfile, masterfilesize, directory, filename, &fileIdentifier, &dataObjectIdentifier);
  319|     13|	LOG_TEST_RET(card->ctx, r, "unable to get the identifier for the gids file");
  ------------------
  |  |  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: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  320|      0|	r = gids_get_DO(card, fileIdentifier, dataObjectIdentifier, response, responselen);
  321|      0|	LOG_TEST_RET(card->ctx, r, "unable to get the data from the 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  322|      0|	return r;
  323|      0|}
card-gids.c:gids_get_identifiers:
  163|     13|static int gids_get_identifiers(sc_card_t* card, u8* masterfile, size_t masterfilesize, char *directory, char *filename, int *fileIdentifier, int *dataObjectIdentifier) {
  164|     13|	gids_mf_record_t *records = (gids_mf_record_t *) (masterfile+1);
  165|     13|	size_t recordcount = ((masterfilesize-1) / sizeof(gids_mf_record_t));
  166|     13|	size_t i;
  167|     13|	if (masterfilesize < 1)
  ------------------
  |  Branch (167:6): [True: 0, False: 13]
  ------------------
  168|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  169|       |
  170|    141|	for (i = 0; i < recordcount; i++) {
  ------------------
  |  Branch (170:14): [True: 128, False: 13]
  ------------------
  171|    128|		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: 18, False: 110]
  |  Branch (171:86): [True: 0, False: 18]
  ------------------
  172|      0|			*fileIdentifier = records[i].fileIdentifier;
  173|      0|			*dataObjectIdentifier = records[i].dataObjectIdentifier;
  174|      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__
  |  |  ------------------
  ------------------
  175|      0|		"Identifiers of %s %s is fileIdentifier=%x, dataObjectIdentifier=%x\n", directory, filename, *fileIdentifier, *dataObjectIdentifier);
  176|      0|			return 0;
  177|      0|		}
  178|    128|	}
  179|     13|	sc_log(card->ctx, "file %s %s not found\n", directory, filename);
  ------------------
  |  |   71|     13|#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|     13|	return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|     13|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  181|     13|}
card-gids.c:gids_get_all_containers:
 1081|     38|gids_get_all_containers(sc_card_t* card, size_t *recordsnum) {
 1082|     38|	int r;
 1083|     38|	struct gids_private_data *privatedata = (struct gids_private_data *) card->drv_data;
 1084|     38|	r = gids_read_masterfile(card);
 1085|     38|	LOG_TEST_RET(card->ctx, r, "unable to read the masterfile");
  ------------------
  |  |  174|     38|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     38|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     38|	int _ret = (r); \
  |  |  |  |  168|     38|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 32, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|     38|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1086|      6|	r = gids_read_cmapfile(card);
 1087|      6|	LOG_TEST_RET(card->ctx, r, "unable to read the cmapfile");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1088|      0|	*recordsnum = (privatedata ->cmapfilesize / sizeof(CONTAINER_MAP_RECORD));
 1089|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1090|      6|}
card-gids.c:gids_read_cmapfile:
  431|      8|static int gids_read_cmapfile(sc_card_t* card) {
  432|      8|	struct gids_private_data* data = (struct gids_private_data*) card->drv_data;
  433|      8|	int r = SC_SUCCESS;
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  434|       |
  435|      8|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  436|      8|	data->cmapfilesize = sizeof(data->cmapfile);
  437|      8|	r = gids_read_gidsfile(card, "mscp", "cmapfile", data->cmapfile, &data->cmapfilesize);
  438|      8|	if (r<0) {
  ------------------
  |  Branch (438:6): [True: 8, False: 0]
  ------------------
  439|      8|		data->cmapfilesize = sizeof(data->cmapfile);
  440|      8|	}
  441|      8|	LOG_TEST_RET(card->ctx, r, "unable to get the cmapfile");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  442|      0|	return r;
  443|      8|}
card-gids.c:gids_select_key_reference:
 1139|     17|gids_select_key_reference(sc_card_t *card, sc_pkcs15_prkey_info_t* key_info) {
 1140|     17|	struct gids_private_data *data = (struct gids_private_data *) card->drv_data;
 1141|     17|	PCONTAINER_MAP_RECORD records = (PCONTAINER_MAP_RECORD) data->cmapfile;
 1142|     17|	size_t recordsnum;
 1143|     17|	int r;
 1144|     17|	char ch_tmp[10];
 1145|       |
 1146|     17|	SC_FUNC_CALLED(card->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]
  |  |  ------------------
  ------------------
 1147|       |
 1148|       |	// refresh the cached data in case some thing has been modified
 1149|     17|	r = gids_read_masterfile(card);
 1150|     17|	LOG_TEST_RET(card->ctx, r, "gids read masterfile 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: 15, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1151|      2|	r = gids_read_cmapfile(card);
 1152|      2|	LOG_TEST_RET(card->ctx, r, "gids read cmapfile 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1153|       |
 1154|      0|	recordsnum = (data->cmapfilesize / sizeof(CONTAINER_MAP_RECORD));
 1155|       |
 1156|      0|	if (!key_info->key_reference) {
  ------------------
  |  Branch (1156:6): [True: 0, False: 0]
  ------------------
 1157|       |		// new key
 1158|      0|		size_t i;
 1159|       |		// search for a key number not used anymore
 1160|      0|		for (i = 0; i < recordsnum; i++) {
  ------------------
  |  Branch (1160:15): [True: 0, False: 0]
  ------------------
 1161|      0|			if (!(records[i].bFlags & CONTAINER_MAP_VALID_CONTAINER)) {
  ------------------
  |  |  102|      0|#define CONTAINER_MAP_VALID_CONTAINER		1
  ------------------
  |  Branch (1161:8): [True: 0, False: 0]
  ------------------
 1162|      0|				key_info->key_reference = (int) (GIDS_FIRST_KEY_IDENTIFIER + i);
  ------------------
  |  |   98|      0|#define GIDS_FIRST_KEY_IDENTIFIER 0x81
  ------------------
 1163|      0|				return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1164|      0|			}
 1165|      0|		}
 1166|       |		// use a new key number
 1167|      0|		if (recordsnum > GIDS_MAX_CONTAINER) {
  ------------------
  |  |   98|      0|#define GIDS_MAX_CONTAINER 126
  ------------------
  |  Branch (1167:7): [True: 0, False: 0]
  ------------------
 1168|      0|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1169|      0|		}
 1170|      0|		key_info->key_reference = (int) (GIDS_FIRST_KEY_IDENTIFIER + recordsnum);
  ------------------
  |  |   98|      0|#define GIDS_FIRST_KEY_IDENTIFIER 0x81
  ------------------
 1171|      0|	} else {
 1172|       |		// key was specified. Search if the key can be used
 1173|      0|		size_t i = key_info->key_reference - GIDS_FIRST_KEY_IDENTIFIER;
  ------------------
  |  |   98|      0|#define GIDS_FIRST_KEY_IDENTIFIER 0x81
  ------------------
 1174|      0|		if (i > GIDS_MAX_CONTAINER) {
  ------------------
  |  |   98|      0|#define GIDS_MAX_CONTAINER 126
  ------------------
  |  Branch (1174:7): [True: 0, False: 0]
  ------------------
 1175|      0|			sc_log(card->ctx, "invalid key ref %d", key_info->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__
  |  |  ------------------
  ------------------
 1176|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1177|      0|		}
 1178|      0|		if (i > recordsnum) {
  ------------------
  |  Branch (1178:7): [True: 0, False: 0]
  ------------------
 1179|      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__
  |  |  ------------------
  ------------------
 1180|      0|				 "container num is not allowed %"SC_FORMAT_LEN_SIZE_T"u %"SC_FORMAT_LEN_SIZE_T"u",
 1181|      0|				 i, recordsnum);
 1182|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1183|      0|		}
 1184|      0|	}
 1185|      0|	snprintf(ch_tmp, sizeof(ch_tmp), "3FFFB0%02X", (u8) (0xFF & key_info->key_reference));
 1186|      0|	sc_format_path(ch_tmp, &(key_info->path));
 1187|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1188|      0|}
card-gids.c:gids_pin_cmd:
 1029|     15|gids_pin_cmd(struct sc_card *card, struct sc_pin_cmd_data *data) {
 1030|     15|	if (data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  425|     15|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1030:6): [True: 15, False: 0]
  ------------------
 1031|     15|		return gids_get_pin_policy(card, data);
 1032|     15|	} else {
 1033|      0|		return iso_ops->pin_cmd(card, data);
 1034|      0|	}
 1035|     15|}
card-gids.c:gids_get_pin_policy:
 1013|     15|static int gids_get_pin_policy(struct sc_card *card, struct sc_pin_cmd_data *data) {
 1014|     15|	int r;
 1015|     15|	if (data->pin_type != SC_AC_CHV) {
  ------------------
  |  |  151|     15|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1015:6): [True: 0, False: 15]
  ------------------
 1016|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1017|      0|	}
 1018|     15|	r = gids_get_pin_status(card, data->pin_reference, &(data->pin1.tries_left), &(data->pin1.max_tries));
 1019|     15|	LOG_TEST_RET(card->ctx, r, "gids_get_pin_status failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1020|      0|	data->pin1.max_length = 16;
 1021|      0|	data->pin1.min_length = 4;
 1022|      0|	data->pin1.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  432|      0|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1023|      0|	data->pin1.offset = 5;
 1024|      0|	data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  437|      0|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 1025|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1026|     15|}
card-gids.c:gids_get_pin_status:
  520|     15|static int gids_get_pin_status(sc_card_t *card, int pinreference, int *tries_left, int *max_tries) {
  521|     15|	int dataObjectIdentifier, r;
  522|     15|	u8 buffer[100];
  523|     15|	const u8* p;
  524|     15|	size_t buffersize = sizeof(buffer);
  525|     15|	size_t datasize;
  526|       |
  527|     15|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     15|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     15|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     15|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 15]
  |  |  ------------------
  ------------------
  528|     15|	if (tries_left) *tries_left = -1;
  ------------------
  |  Branch (528:6): [True: 15, False: 0]
  ------------------
  529|     15|	if (max_tries) *max_tries = -1;
  ------------------
  |  Branch (529:6): [True: 15, False: 0]
  ------------------
  530|     15|	switch(pinreference) {
  531|      0|	case GIDS_PIN_IDENTIFIER:
  ------------------
  |  |  100|      0|#define GIDS_PIN_IDENTIFIER 0x80
  ------------------
  |  Branch (531:2): [True: 0, False: 15]
  ------------------
  532|      0|		dataObjectIdentifier = GIDS_PIN_STATUS_OBJECT_IDENTIFIER;
  ------------------
  |  |   80|      0|#define GIDS_PIN_STATUS_OBJECT_IDENTIFIER 0x7F71
  ------------------
  533|      0|		break;
  534|      0|	case GIDS_PUK_IDENTIFIER:
  ------------------
  |  |  101|      0|#define GIDS_PUK_IDENTIFIER 0x81
  ------------------
  |  Branch (534:2): [True: 0, False: 15]
  ------------------
  535|      0|		dataObjectIdentifier = GIDS_PUK_STATUS_OBJECT_IDENTIFIER;
  ------------------
  |  |   81|      0|#define GIDS_PUK_STATUS_OBJECT_IDENTIFIER 0x7F73
  ------------------
  536|      0|		break;
  537|     15|	default:
  ------------------
  |  Branch (537:2): [True: 15, False: 0]
  ------------------
  538|     15|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_OBJECT_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|     15|	}
  540|      0|	r = gids_get_DO(card, GIDS_APPLET_EFID, dataObjectIdentifier, buffer, &buffersize);
  ------------------
  |  |   82|      0|#define GIDS_APPLET_EFID 0x3FFF
  ------------------
  541|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  542|       |
  543|      0|	buffersize = buffersize > sizeof(buffer) ? sizeof(buffer) : buffersize;
  ------------------
  |  Branch (543:15): [True: 0, False: 0]
  ------------------
  544|       |
  545|      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
  ------------------
  546|      0|	if (p && datasize == 1) {
  ------------------
  |  Branch (546:6): [True: 0, False: 0]
  |  Branch (546:11): [True: 0, False: 0]
  ------------------
  547|      0|		if (tries_left)
  ------------------
  |  Branch (547:7): [True: 0, False: 0]
  ------------------
  548|      0|			*tries_left = p[0];
  549|      0|	}
  550|      0|	p = sc_asn1_find_tag(card->ctx, buffer, buffersize, GIDS_TRY_COUNTER_TAG, &datasize);
  ------------------
  |  |  103|      0|#define GIDS_TRY_COUNTER_TAG 0x97
  ------------------
  551|      0|	if (p && datasize == 1) {
  ------------------
  |  Branch (551:6): [True: 0, False: 0]
  |  Branch (551:11): [True: 0, False: 0]
  ------------------
  552|      0|		if (tries_left)
  ------------------
  |  Branch (552:7): [True: 0, False: 0]
  ------------------
  553|      0|			*tries_left = p[0];
  554|      0|	}
  555|      0|	p = sc_asn1_find_tag(card->ctx, buffer, buffersize , GIDS_TRY_LIMIT_TAG, &datasize);
  ------------------
  |  |  104|      0|#define GIDS_TRY_LIMIT_TAG 0x93
  ------------------
  556|      0|	if (p && datasize == 1) {
  ------------------
  |  Branch (556:6): [True: 0, False: 0]
  |  Branch (556:11): [True: 0, False: 0]
  ------------------
  557|      0|		if (max_tries)
  ------------------
  |  Branch (557:7): [True: 0, False: 0]
  ------------------
  558|      0|			*max_tries = p[0];
  559|      0|	}
  560|       |
  561|      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]
  |  |  ------------------
  ------------------
  562|      0|		"Pin information for PIN 0x%x: triesleft=%d trieslimit=%d\n", pinreference, (tries_left?*tries_left:-1), (max_tries?*max_tries:-1));
  563|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  564|      0|}
card-gids.c:gids_card_reader_lock_obtained:
 2136|    677|{
 2137|    677|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    677|#define SC_SUCCESS				0
  ------------------
 2138|       |
 2139|    677|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    677|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    677|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    677|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 677]
  |  |  ------------------
  ------------------
 2140|       |
 2141|    677|	if (was_reset > 0) {
  ------------------
  |  Branch (2141:6): [True: 0, False: 677]
  ------------------
 2142|      0|		u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 2143|      0|		size_t resplen = sizeof(rbuf);
 2144|      0|		r = gids_select_aid(card, gids_aid.value, gids_aid.len, rbuf, &resplen);
 2145|      0|	}
 2146|       |
 2147|    677|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    677|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    677|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    677|	int _ret = r; \
  |  |  |  |  155|    677|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 677, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    677|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 677]
  |  |  |  |  ------------------
  |  |  |  |  157|    677|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    677|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    677|	return _ret; \
  |  |  |  |  163|    677|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2148|    677|}

sc_invalidate_cache:
  164|  1.01k|{
  165|  1.01k|	if (card) {
  ------------------
  |  Branch (165:6): [True: 1.01k, False: 0]
  ------------------
  166|  1.01k|		struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  167|  1.01k|		sc_file_free(prv->cache.current_ef);
  168|  1.01k|		sc_file_free(prv->cache.current_df);
  169|  1.01k|		memset(&prv->cache, 0, sizeof(prv->cache));
  170|  1.01k|		prv->cache.valid = 0;
  171|  1.01k|	}
  172|  1.01k|}
iasecc_se_get_info:
 1633|     18|{
 1634|     18|	struct sc_context *ctx = card->ctx;
 1635|     18|	struct sc_apdu apdu;
 1636|     18|	unsigned char rbuf[0x100];
 1637|     18|	unsigned char sbuf_iasecc[10] = {
 1638|     18|		0x4D, 0x08, IASECC_SDO_TEMPLATE_TAG, 0x06,
  ------------------
  |  |   29|     18|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
 1639|     18|		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |   27|     18|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
              		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |  102|     18|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
              		IASECC_SDO_TAG_HEADER, IASECC_SDO_CLASS_SE | IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |   59|     18|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 1640|     18|		se->reference & 0x3F,
 1641|     18|		0x02, IASECC_SDO_CLASS_SE, 0x80
  ------------------
  |  |  102|     18|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
 1642|     18|	};
 1643|     18|	int rv;
 1644|       |
 1645|     18|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1646|       |
 1647|     18|	if (iasecc_is_cpx(card)) {
  ------------------
  |  Branch (1647:6): [True: 0, False: 18]
  ------------------
 1648|      0|		rv = iasecc_select_mf(card, NULL);
 1649|      0|		LOG_TEST_RET(ctx, rv, "MF invalid");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1650|      0|	}
 1651|       |
 1652|     18|	if (se->reference > IASECC_SE_REF_MAX)
  ------------------
  |  |   66|     18|#define IASECC_SE_REF_MAX	0x0F
  ------------------
  |  Branch (1652:6): [True: 0, False: 18]
  ------------------
 1653|     18|                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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1654|       |
 1655|     18|	rv = iasecc_se_get_info_from_cache(card, se);
 1656|     18|	if (rv == SC_ERROR_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   88|     18|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1656:6): [True: 18, False: 0]
  ------------------
 1657|     18|		sc_log(ctx, "No SE#%X info in cache, try to use 'GET DATA'", se->reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1658|       |
 1659|     18|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xCB, 0x3F, 0xFF);
  ------------------
  |  |  294|     18|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1660|     18|		apdu.data = sbuf_iasecc;
 1661|     18|		apdu.datalen = sizeof(sbuf_iasecc);
 1662|     18|		apdu.lc = apdu.datalen;
 1663|     18|		apdu.resp = rbuf;
 1664|     18|		apdu.resplen = sizeof(rbuf);
 1665|     18|		apdu.le = sizeof(rbuf);
 1666|       |
 1667|     18|		rv = sc_transmit_apdu(card, &apdu);
 1668|     18|		LOG_TEST_RET(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: 0, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1669|     18|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1670|     18|		LOG_TEST_RET(ctx, rv, "get SE data  error");
  ------------------
  |  |  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: 5, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1671|       |
 1672|     13|		rv = iasecc_se_parse(card, apdu.resp, apdu.resplen, se);
 1673|     13|		LOG_TEST_RET(ctx, rv, "cannot parse SE data");
  ------------------
  |  |  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: 7, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1674|       |
 1675|      6|		rv = iasecc_se_cache_info(card, se);
 1676|      6|		LOG_TEST_RET(ctx, rv, "failed to put SE data into cache");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1677|      6|	}
 1678|       |
 1679|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1680|      6|}
sc_get_iasecc_driver:
 3684|  3.69k|{
 3685|  3.69k|	return sc_get_driver();
 3686|  3.69k|}
card-iasecc.c:iasecc_is_cpx:
  590|  4.54k|{
  591|  4.54k|	switch(card->type) {
  592|     48|		case SC_CARD_TYPE_IASECC_CPX:
  ------------------
  |  Branch (592:3): [True: 48, False: 4.50k]
  ------------------
  593|    629|		case SC_CARD_TYPE_IASECC_CPXCL:
  ------------------
  |  Branch (593:3): [True: 581, False: 3.96k]
  ------------------
  594|    629|			return 1;
  595|  3.92k|		default:
  ------------------
  |  Branch (595:3): [True: 3.92k, False: 629]
  ------------------
  596|  3.92k|			return 0;
  597|  4.54k|	}
  598|       |
  599|      0|	return 0;
  600|  4.54k|}
card-iasecc.c:iasecc_select_mf:
  283|    845|{
  284|    845|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  285|    845|	struct sc_context *ctx = card->ctx;
  286|    845|	struct sc_file *mf_file = NULL;
  287|    845|	struct sc_path path;
  288|    845|	int rv;
  289|       |
  290|    845|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    845|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    845|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    845|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    845|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 845]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|       |
  292|    845|	if (file_out)
  ------------------
  |  Branch (292:6): [True: 580, False: 265]
  ------------------
  293|    580|		*file_out = NULL;
  294|       |
  295|    845|	memset(&path, 0, sizeof(struct sc_path));
  296|    845|	if (!card->ef_atr || !card->ef_atr->aid.len)   {
  ------------------
  |  Branch (296:6): [True: 105, False: 740]
  |  Branch (296:23): [True: 548, False: 192]
  ------------------
  297|    653|		struct sc_apdu apdu;
  298|    653|		unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE];
  299|       |
  300|       |		/* ISO 'select' command fails when not FCP data returned */
  301|    653|		sc_format_path("3F00", &path);
  302|    653|		path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    653|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  303|       |
  304|    653|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x0C);
  ------------------
  |  |  293|    653|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  305|    653|		apdu.lc = path.len;
  306|    653|		apdu.data = path.value;
  307|    653|		apdu.datalen = path.len;
  308|    653|		apdu.resplen = sizeof(apdu_resp);
  309|    653|		apdu.resp = apdu_resp;
  310|       |
  311|       |		/* TODO: this might be obsolete now that 0x0c (no data) is default for p2 */
  312|    653|		if (card->type == SC_CARD_TYPE_IASECC_MI2)
  ------------------
  |  Branch (312:7): [True: 0, False: 653]
  ------------------
  313|      0|			apdu.p2 = 0x04;
  314|       |
  315|    653|		rv = sc_transmit_apdu(card, &apdu);
  316|    653|		LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    653|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    653|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    653|	int _ret = (r); \
  |  |  |  |  168|    653|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 653]
  |  |  |  |  ------------------
  |  |  |  |  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|    653|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 653]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  317|    653|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  318|    653|		LOG_TEST_RET(card->ctx, rv, "Cannot select MF");
  ------------------
  |  |  174|    653|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    653|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    653|	int _ret = (r); \
  |  |  |  |  168|    653|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 378, False: 275]
  |  |  |  |  ------------------
  |  |  |  |  169|    378|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    378|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    378|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    378|		return _ret; \
  |  |  |  |  172|    378|	} \
  |  |  |  |  173|    653|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 275]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  319|    653|	}
  320|    192|	else   {
  321|    192|		memset(&path, 0, sizeof(path));
  322|    192|		path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    192|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  323|    192|		memcpy(path.value, card->ef_atr->aid.value, card->ef_atr->aid.len);
  324|    192|		path.len = card->ef_atr->aid.len;
  325|    192|		rv = iasecc_select_file(card, &path, file_out);
  326|    192|		LOG_TEST_RET(ctx, rv, "Unable to ROOT selection");
  ------------------
  |  |  174|    192|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    192|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    192|	int _ret = (r); \
  |  |  |  |  168|    192|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 96, False: 96]
  |  |  |  |  ------------------
  |  |  |  |  169|     96|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     96|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     96|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     96|		return _ret; \
  |  |  |  |  172|     96|	} \
  |  |  |  |  173|    192|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  327|    192|	}
  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|    371|	mf_file = sc_file_new();
  334|    371|	if (mf_file == NULL)
  ------------------
  |  Branch (334:6): [True: 0, False: 371]
  ------------------
  335|    371|		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|    371|	mf_file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    371|#define SC_FILE_TYPE_DF			0x04
  ------------------
  337|    371|	mf_file->path = path;
  338|       |
  339|    371|	sc_invalidate_cache(card);
  340|    371|	sc_file_dup(&prv->cache.current_df, mf_file);
  341|    371|	prv->cache.valid = 1;
  342|       |
  343|    371|	if (file_out && *file_out == NULL)
  ------------------
  |  Branch (343:6): [True: 293, False: 78]
  |  Branch (343:18): [True: 258, False: 35]
  ------------------
  344|    258|		*file_out = mf_file;
  345|    113|	else
  346|    113|		sc_file_free(mf_file);
  347|       |
  348|    371|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    371|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    371|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    371|	int _ret = r; \
  |  |  |  |  155|    371|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 371, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    371|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 371]
  |  |  |  |  ------------------
  |  |  |  |  157|    371|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    371|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    371|	return _ret; \
  |  |  |  |  163|    371|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|    371|}
card-iasecc.c:iasecc_select_file:
  877|  3.28k|{
  878|  3.28k|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  879|  3.28k|	struct sc_context *ctx = card->ctx;
  880|  3.28k|	struct sc_path lpath;
  881|  3.28k|	int rv, ii;
  882|       |
  883|  3.28k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.28k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.28k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.28k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.28k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.28k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  884|  3.28k|	memcpy(&lpath, path, sizeof(struct sc_path));
  885|  3.28k|	if (file_out)
  ------------------
  |  Branch (885:6): [True: 1.65k, False: 1.62k]
  ------------------
  886|  1.65k|		*file_out = NULL;
  887|       |
  888|  3.28k|	sc_log(ctx,
  ------------------
  |  |   71|  3.28k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  889|  3.28k|	       "iasecc_select_file(card:%p) path.len %"SC_FORMAT_LEN_SIZE_T"u; path.type %i; aid_len %"SC_FORMAT_LEN_SIZE_T"u",
  890|  3.28k|	       card, path->len, path->type, path->aid.len);
  891|  3.28k|	sc_log(ctx, "iasecc_select_file() path:%s", sc_print_path(path));
  ------------------
  |  |   71|  3.28k|#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|       |
  893|  3.28k|	if ((!iasecc_is_cpx(card)) &&
  ------------------
  |  Branch (893:6): [True: 3.08k, False: 198]
  ------------------
  894|  3.08k|	    (card->type != SC_CARD_TYPE_IASECC_GEMALTO) &&
  ------------------
  |  Branch (894:6): [True: 1.42k, False: 1.66k]
  ------------------
  895|  1.42k|	    (path->type != SC_PATH_TYPE_DF_NAME
  ------------------
  |  |  118|  2.84k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (895:7): [True: 967, False: 454]
  ------------------
  896|    967|			&& lpath.len >= 2
  ------------------
  |  Branch (896:7): [True: 903, False: 64]
  ------------------
  897|    903|			&& lpath.value[0] == 0x3F && lpath.value[1] == 0x00))   {
  ------------------
  |  Branch (897:7): [True: 829, False: 74]
  |  Branch (897:33): [True: 819, False: 10]
  ------------------
  898|    819|		sc_log(ctx, "EF.ATR(aid:'%s')", card->ef_atr ? sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len) : "");
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 714, False: 105]
  |  |  ------------------
  ------------------
  899|       |
  900|    819|		rv = iasecc_select_mf(card, file_out);
  901|    819|		LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|    819|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    819|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    819|	int _ret = (r); \
  |  |  |  |  168|    819|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 465, False: 354]
  |  |  |  |  ------------------
  |  |  |  |  169|    465|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    465|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    465|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    465|		return _ret; \
  |  |  |  |  172|    465|	} \
  |  |  |  |  173|    819|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 354]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  902|       |
  903|    354|		memmove(&lpath.value[0], &lpath.value[2], lpath.len - 2);
  904|    354|		lpath.len -=  2;
  905|    354|	}
  906|       |
  907|  2.82k|	if (lpath.aid.len)	{
  ------------------
  |  Branch (907:6): [True: 10, False: 2.81k]
  ------------------
  908|     10|		struct sc_file *file = NULL;
  909|     10|		struct sc_path ppath;
  910|       |
  911|     10|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  912|     10|		       "iasecc_select_file() select parent AID:%p/%"SC_FORMAT_LEN_SIZE_T"u",
  913|     10|		       lpath.aid.value, lpath.aid.len);
  914|     10|		sc_log(ctx, "iasecc_select_file() select parent AID:%s", sc_dump_hex(lpath.aid.value, lpath.aid.len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  915|     10|		memset(&ppath, 0, sizeof(ppath));
  916|     10|		memcpy(ppath.value, lpath.aid.value, lpath.aid.len);
  917|     10|		ppath.len = lpath.aid.len;
  918|     10|		ppath.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|     10|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  919|       |
  920|     10|		rv = iasecc_select_file(card, &ppath, &file);
  921|     10|		LOG_TEST_GOTO_ERR(ctx, rv, "select AID path failed");
  ------------------
  |  |  184|     10|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     10|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     10|	int _ret = (r); \
  |  |  |  |  178|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 4, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  922|       |
  923|      6|		if (file_out) {
  ------------------
  |  Branch (923:7): [True: 3, False: 3]
  ------------------
  924|      3|			sc_file_free(*file_out);
  925|      3|			*file_out = file;
  926|      3|		} else {
  927|      3|			sc_file_free(file);
  928|      3|		}
  929|       |
  930|      6|		if (lpath.type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|      6|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (930:7): [True: 4, False: 2]
  ------------------
  931|      4|			lpath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|      4|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  932|      6|	}
  933|       |
  934|  2.81k|	if (lpath.type == SC_PATH_TYPE_PATH)
  ------------------
  |  |  119|  2.81k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (934:6): [True: 1.54k, False: 1.27k]
  ------------------
  935|  1.54k|		lpath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|  1.54k|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  936|       |
  937|  2.81k|	if (!lpath.len) {
  ------------------
  |  Branch (937:6): [True: 181, False: 2.63k]
  ------------------
  938|    181|		if (file_out) {
  ------------------
  |  Branch (938:7): [True: 146, False: 35]
  ------------------
  939|    146|			sc_file_free(*file_out);
  940|    146|			*file_out = NULL;
  941|    146|		}
  942|    181|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 181]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  943|    181|	}
  944|       |
  945|  2.63k|	do   {
  946|  2.63k|		struct sc_apdu apdu;
  947|  2.63k|		struct sc_file *file = NULL;
  948|  2.63k|		unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  949|  2.63k|		size_t pathlen = lpath.len;
  950|       |
  951|  2.63k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  2.63k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  952|       |
  953|  2.63k|		if (card->type != SC_CARD_TYPE_IASECC_GEMALTO
  ------------------
  |  Branch (953:7): [True: 1.06k, False: 1.56k]
  ------------------
  954|  1.06k|				&& card->type != SC_CARD_TYPE_IASECC_OBERTHUR
  ------------------
  |  Branch (954:8): [True: 882, False: 186]
  ------------------
  955|    882|				&& card->type != SC_CARD_TYPE_IASECC_SAGEM
  ------------------
  |  Branch (955:8): [True: 192, False: 690]
  ------------------
  956|    192|				&& card->type != SC_CARD_TYPE_IASECC_AMOS
  ------------------
  |  Branch (956:8): [True: 192, False: 0]
  ------------------
  957|    192|				&& card->type != SC_CARD_TYPE_IASECC_MI
  ------------------
  |  Branch (957:8): [True: 192, False: 0]
  ------------------
  958|    192|				&& card->type != SC_CARD_TYPE_IASECC_MI2
  ------------------
  |  Branch (958:8): [True: 192, False: 0]
  ------------------
  959|    192|				&& !iasecc_is_cpx(card)) {
  ------------------
  |  Branch (959:8): [True: 0, False: 192]
  ------------------
  960|      0|			rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  961|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  962|      0|		}
  963|       |
  964|  2.63k|		if (lpath.type == SC_PATH_TYPE_FILE_ID)   {
  ------------------
  |  |  117|  2.63k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (964:7): [True: 89, False: 2.54k]
  ------------------
  965|     89|			apdu.p1 = 0x02;
  966|     89|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)
  ------------------
  |  Branch (966:8): [True: 29, False: 60]
  ------------------
  967|     29|				apdu.p1 = 0x01;
  968|     89|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (968:8): [True: 29, False: 60]
  ------------------
  969|     60|			    card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (969:8): [True: 0, False: 60]
  ------------------
  970|     60|			    card->type == SC_CARD_TYPE_IASECC_MI ||
  ------------------
  |  Branch (970:8): [True: 0, False: 60]
  ------------------
  971|     60|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (971:8): [True: 0, False: 60]
  ------------------
  972|     60|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (972:8): [True: 0, False: 60]
  ------------------
  973|     60|			    iasecc_is_cpx(card)
  ------------------
  |  Branch (973:8): [True: 6, False: 54]
  ------------------
  974|     89|			    )   {
  975|     35|				apdu.p2 = 0x04;
  976|     35|			}
  977|     89|		}
  978|  2.54k|		else if (lpath.type == SC_PATH_TYPE_FROM_CURRENT)  {
  ------------------
  |  |  122|  2.54k|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (978:12): [True: 1.54k, False: 1.00k]
  ------------------
  979|  1.54k|			apdu.p1 = 0x09;
  980|  1.54k|			if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (980:8): [True: 75, False: 1.47k]
  ------------------
  981|  1.47k|			    card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (981:8): [True: 0, False: 1.47k]
  ------------------
  982|  1.47k|			    card->type == SC_CARD_TYPE_IASECC_MI ||
  ------------------
  |  Branch (982:8): [True: 0, False: 1.47k]
  ------------------
  983|  1.47k|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (983:8): [True: 0, False: 1.47k]
  ------------------
  984|  1.47k|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (984:8): [True: 1.06k, False: 407]
  ------------------
  985|  1.27k|			    iasecc_is_cpx(card)) {
  ------------------
  |  Branch (985:8): [True: 135, False: 272]
  ------------------
  986|  1.27k|				apdu.p2 = 0x04;
  987|  1.27k|			}
  988|  1.54k|		}
  989|  1.00k|		else if (lpath.type == SC_PATH_TYPE_PARENT)   {
  ------------------
  |  |  123|  1.00k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (989:12): [True: 0, False: 1.00k]
  ------------------
  990|      0|			apdu.p1 = 0x03;
  991|      0|			pathlen = 0;
  992|      0|			apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|      0|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  993|      0|		}
  994|  1.00k|		else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  1.00k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (994:12): [True: 1.00k, False: 0]
  ------------------
  995|  1.00k|			apdu.p1 = 0x04;
  996|  1.00k|			if (card->type == SC_CARD_TYPE_IASECC_AMOS ||
  ------------------
  |  Branch (996:8): [True: 0, False: 1.00k]
  ------------------
  997|  1.00k|			    card->type == SC_CARD_TYPE_IASECC_MI2 ||
  ------------------
  |  Branch (997:8): [True: 0, False: 1.00k]
  ------------------
  998|  1.00k|			    card->type == SC_CARD_TYPE_IASECC_OBERTHUR ||
  ------------------
  |  Branch (998:8): [True: 82, False: 918]
  ------------------
  999|    918|			    card->type == SC_CARD_TYPE_IASECC_GEMALTO ||
  ------------------
  |  Branch (999:8): [True: 503, False: 415]
  ------------------
 1000|    636|			    iasecc_is_cpx(card)) {
  ------------------
  |  Branch (1000:8): [True: 51, False: 364]
  ------------------
 1001|    636|				apdu.p2 = 0x04;
 1002|    636|			}
 1003|  1.00k|		}
 1004|      0|		else   {
 1005|      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__
  |  |  ------------------
  ------------------
 1006|      0|			rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1007|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1008|      0|		}
 1009|       |
 1010|  2.71k|		for (ii=0; ii<2; ii++)   {
  ------------------
  |  Branch (1010:14): [True: 2.71k, False: 0]
  ------------------
 1011|  2.71k|			apdu.lc = pathlen;
 1012|  2.71k|			apdu.data = lpath.value;
 1013|  2.71k|			apdu.datalen = pathlen;
 1014|       |
 1015|  2.71k|			apdu.resp = rbuf;
 1016|  2.71k|			apdu.resplen = sizeof(rbuf);
 1017|  2.71k|			apdu.le = 256;
 1018|       |
 1019|  2.71k|			rv = sc_transmit_apdu(card, &apdu);
 1020|  2.71k|			LOG_TEST_GOTO_ERR(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  184|  2.71k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.71k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.71k|	int _ret = (r); \
  |  |  |  |  178|  2.71k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 42, False: 2.67k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.71k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.67k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1021|  2.67k|			rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1022|  2.67k|			if (rv == SC_ERROR_INCORRECT_PARAMETERS &&
  ------------------
  |  |   55|  5.34k|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (1022:8): [True: 114, False: 2.55k]
  ------------------
 1023|    114|					lpath.type == SC_PATH_TYPE_DF_NAME && apdu.p2 == 0x00)   {
  ------------------
  |  |  118|  2.78k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1023:6): [True: 87, False: 27]
  |  Branch (1023:44): [True: 77, False: 10]
  ------------------
 1024|     77|				sc_log(ctx, "Warning: SC_ERROR_INCORRECT_PARAMETERS for SC_PATH_TYPE_DF_NAME, try again with P2=0x0C");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1025|     77|				apdu.p2 = 0x0C;
 1026|     77|				continue;
 1027|     77|			}
 1028|       |
 1029|  2.59k|			if (ii)   {
  ------------------
  |  Branch (1029:8): [True: 77, False: 2.51k]
  ------------------
 1030|       |				/* 'SELECT AID' do not returned FCP. Try to emulate. */
 1031|     77|				apdu.resplen = sizeof(rbuf);
 1032|     77|				rv = iasecc_emulate_fcp(ctx, &apdu);
 1033|     77|				LOG_TEST_GOTO_ERR(ctx, rv, "Failed to emulate DF FCP");
  ------------------
  |  |  184|     77|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     77|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     77|	int _ret = (r); \
  |  |  |  |  178|     77|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 77]
  |  |  |  |  ------------------
  |  |  |  |  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|     77|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 77]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1034|     77|			}
 1035|       |
 1036|  2.59k|			break;
 1037|  2.59k|		}
 1038|       |
 1039|  2.59k|		LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_select_file() check SW failed");
  ------------------
  |  |  184|  2.59k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.59k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.59k|	int _ret = (r); \
  |  |  |  |  178|  2.59k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.22k, False: 1.36k]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.22k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.22k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.22k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.22k|		goto err; \
  |  |  |  |  182|  1.22k|	} \
  |  |  |  |  183|  2.59k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.36k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1040|       |
 1041|  1.36k|		sc_log(ctx,
  ------------------
  |  |   71|  1.36k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1042|  1.36k|		       "iasecc_select_file() apdu.resp %"SC_FORMAT_LEN_SIZE_T"u",
 1043|  1.36k|		       apdu.resplen);
 1044|  1.36k|		if (apdu.resplen)   {
  ------------------
  |  Branch (1044:7): [True: 595, False: 769]
  ------------------
 1045|    595|			sc_log(ctx, "apdu.resp %02X:%02X:%02X...", apdu.resp[0], apdu.resp[1], apdu.resp[2]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1046|       |
 1047|    595|			switch (apdu.resp[0]) {
 1048|     80|			case 0x62:
  ------------------
  |  Branch (1048:4): [True: 80, False: 515]
  ------------------
 1049|    552|			case 0x6F:
  ------------------
  |  Branch (1049:4): [True: 472, False: 123]
  ------------------
 1050|    552|				file = sc_file_new();
 1051|    552|				if (file == NULL) {
  ------------------
  |  Branch (1051:9): [True: 0, False: 552]
  ------------------
 1052|      0|					if (file_out) {
  ------------------
  |  Branch (1052:10): [True: 0, False: 0]
  ------------------
 1053|      0|						sc_file_free(*file_out);
 1054|      0|						*file_out = NULL;
 1055|      0|					}
 1056|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1057|      0|				}
 1058|    552|				file->path = lpath;
 1059|       |
 1060|    552|				rv = iasecc_process_fci(card, file, apdu.resp, apdu.resplen);
 1061|    552|				if (rv) {
  ------------------
  |  Branch (1061:9): [True: 130, False: 422]
  ------------------
 1062|    130|					sc_file_free(file);
 1063|    130|					if (file_out) {
  ------------------
  |  Branch (1063:10): [True: 7, False: 123]
  ------------------
 1064|      7|						sc_file_free(*file_out);
 1065|      7|						*file_out = NULL;
 1066|      7|					}
 1067|    130|					LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1068|    130|				}
 1069|    422|				break;
 1070|    422|			default:
  ------------------
  |  Branch (1070:4): [True: 43, False: 552]
  ------------------
 1071|     43|				if (file_out) {
  ------------------
  |  Branch (1071:9): [True: 25, False: 18]
  ------------------
 1072|     25|					sc_file_free(*file_out);
 1073|     25|					*file_out = NULL;
 1074|     25|				}
 1075|     43|				LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1076|    595|			}
 1077|       |
 1078|    422|			sc_log(ctx, "FileType %i", file->type);
  ------------------
  |  |   71|    422|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1079|    422|			if (file->type == SC_FILE_TYPE_DF)   {
  ------------------
  |  |  214|    422|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1079:8): [True: 88, False: 334]
  ------------------
 1080|     88|				sc_invalidate_cache(card);
 1081|     88|				sc_file_dup(&prv->cache.current_df, file);
 1082|     88|				prv->cache.valid = 1;
 1083|     88|			}
 1084|    334|			else   {
 1085|    334|				sc_file_free(prv->cache.current_ef);
 1086|    334|				sc_file_dup(&prv->cache.current_ef, file);
 1087|    334|				prv->cache.valid = 1;
 1088|    334|			}
 1089|       |
 1090|    422|			if (file_out)   {
  ------------------
  |  Branch (1090:8): [True: 337, False: 85]
  ------------------
 1091|    337|				sc_file_free(*file_out);
 1092|    337|				*file_out = file;
 1093|    337|			}
 1094|     85|			else   {
 1095|     85|				sc_file_free(file);
 1096|     85|			}
 1097|    422|		}
 1098|    769|		else if (lpath.type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|    769|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1098:12): [True: 296, False: 473]
  ------------------
 1099|    296|			sc_invalidate_cache(card);
 1100|    296|			prv->cache.valid = 1;
 1101|    296|		}
 1102|  1.36k|	} while(0);
  ------------------
  |  Branch (1102:10): [Folded, False: 1.19k]
  ------------------
 1103|       |
 1104|  1.19k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.19k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.19k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.19k|	int _ret = r; \
  |  |  |  |  155|  1.19k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.19k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.19k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.19k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.19k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.19k|	} else { \
  |  |  |  |  159|      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.19k|	return _ret; \
  |  |  |  |  163|  1.19k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1105|  1.27k|err:
 1106|  1.27k|	if (file_out) {
  ------------------
  |  Branch (1106:6): [True: 473, False: 802]
  ------------------
 1107|    473|		sc_file_free(*file_out);
 1108|       |		*file_out = NULL;
 1109|    473|	}
 1110|  1.27k|	return rv;
 1111|  1.19k|}
card-iasecc.c:iasecc_emulate_fcp:
  842|     77|{
  843|     77|	unsigned char dummy_df_fcp[] = {
  844|     77|		0x62,0xFF,
  845|     77|			0x82,0x01,0x38,
  846|     77|			0x8A,0x01,0x05,
  847|     77|			0xA1,0x04,0x8C,0x02,0x02,0x00,
  848|     77|			0x84,0xFF,
  849|     77|				0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
  850|     77|				0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
  851|     77|	};
  852|       |
  853|     77|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     77|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     77|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     77|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     77|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 77]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  854|       |
  855|     77|	if (apdu->p1 != 0x04)
  ------------------
  |  Branch (855:6): [True: 0, False: 77]
  ------------------
  856|     77|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  857|     77|	if (apdu->datalen > 16)
  ------------------
  |  Branch (857:6): [True: 0, False: 77]
  ------------------
  858|     77|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|     77|	if (apdu->resplen < apdu->datalen + 16)
  ------------------
  |  Branch (859:6): [True: 0, False: 77]
  ------------------
  860|     77|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  861|       |
  862|     77|	memcpy(dummy_df_fcp + 16, apdu->data, apdu->datalen);
  863|     77|	dummy_df_fcp[15] = apdu->datalen;
  864|     77|	dummy_df_fcp[1] = apdu->datalen + 14;
  865|     77|	apdu->resplen = apdu->datalen + 16;
  866|     77|	memcpy(apdu->resp, dummy_df_fcp, apdu->resplen);
  867|       |
  868|     77|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 77]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  869|     77|}
card-iasecc.c:iasecc_process_fci:
 1117|    552|{
 1118|    552|	struct sc_context *ctx = card->ctx;
 1119|    552|	size_t taglen, offs, ii;
 1120|    552|	int rv;
 1121|    552|	const unsigned char *acls = NULL, *tag = NULL;
 1122|    552|	unsigned char mask;
 1123|    552|	unsigned char ops_DF[7] = {
 1124|    552|		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_CREATE, 0xFF
  ------------------
  |  |  168|    552|#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|    552|#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|    552|#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|    552|#define SC_AC_OP_CREATE			3
  ------------------
 1125|    552|	};
 1126|    552|	unsigned char ops_EF[7] = {
 1127|    552|		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  168|    552|#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|    552|#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|    552|#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|    552|#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|    552|#define SC_AC_OP_READ			22
  ------------------
 1128|    552|	};
 1129|       |
 1130|    552|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    552|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    552|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    552|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    552|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 552]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1131|       |
 1132|    552|	tag = sc_asn1_find_tag(ctx,  buf, buflen, 0x6F, &taglen);
 1133|    552|	sc_log(ctx, "processing FCI: 0x6F tag %p", tag);
  ------------------
  |  |   71|    552|#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|    552|	if (tag != NULL) {
  ------------------
  |  Branch (1134:6): [True: 451, False: 101]
  ------------------
 1135|    451|		sc_log(ctx, "  FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
  ------------------
  |  |   71|    451|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1136|    451|		buf = tag;
 1137|    451|		buflen = taglen;
 1138|    451|	}
 1139|       |
 1140|    552|	tag = sc_asn1_find_tag(ctx,  buf, buflen, 0x62, &taglen);
 1141|    552|	sc_log(ctx, "processing FCI: 0x62 tag %p", tag);
  ------------------
  |  |   71|    552|#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|    552|	if (tag != NULL) {
  ------------------
  |  Branch (1142:6): [True: 80, False: 472]
  ------------------
 1143|     80|		sc_log(ctx, "  FCP length %"SC_FORMAT_LEN_SIZE_T"u", taglen);
  ------------------
  |  |   71|     80|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1144|     80|		buf = tag;
 1145|     80|		buflen = taglen;
 1146|     80|	}
 1147|       |
 1148|    552|	rv = iso_ops->process_fci(card, file, buf, buflen);
 1149|    552|	LOG_TEST_RET(ctx, rv, "ISO parse FCI failed");
  ------------------
  |  |  174|    552|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    552|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    552|	int _ret = (r); \
  |  |  |  |  168|    552|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 552]
  |  |  |  |  ------------------
  |  |  |  |  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|    552|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 552]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1150|       |/*
 1151|       |	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
 1152|       |	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
 1153|       |	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
 1154|       |*/
 1155|       |
 1156|    552|	sc_log(ctx, "iasecc_process_fci() type %i; let's parse file ACLs", file->type);
  ------------------
  |  |   71|    552|#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|    552|	tag = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS, &taglen);
  ------------------
  |  |   39|    552|#define IASECC_DOCP_TAG_ACLS			0xA1
  ------------------
 1158|    552|	if (tag)
  ------------------
  |  Branch (1158:6): [True: 77, False: 475]
  ------------------
 1159|     77|		acls = sc_asn1_find_tag(ctx, tag, taglen, IASECC_DOCP_TAG_ACLS_CONTACT, &taglen);
  ------------------
  |  |   40|     77|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
 1160|    475|	else
 1161|    475|		acls = sc_asn1_find_tag(ctx, buf, buflen, IASECC_DOCP_TAG_ACLS_CONTACT, &taglen);
  ------------------
  |  |   40|    475|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
 1162|       |
 1163|    552|	if (!acls)   {
  ------------------
  |  Branch (1163:6): [True: 130, False: 422]
  ------------------
 1164|    130|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1165|    130|		       "ACLs not found in data(%"SC_FORMAT_LEN_SIZE_T"u) %s",
 1166|    130|		       buflen, sc_dump_hex(buf, buflen));
 1167|    130|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "ACLs tag missing");
  ------------------
  |  |  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: 130, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    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
  |  |  |  |  ------------------
  |  |  |  |  170|    130|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    130|		return _ret; \
  |  |  |  |  172|    130|	} \
  |  |  |  |  173|    130|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1168|    130|	}
 1169|       |
 1170|    422|	sc_log(ctx, "ACLs(%"SC_FORMAT_LEN_SIZE_T"u) '%s'", taglen,
  ------------------
  |  |   71|    422|#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|    422|	       sc_dump_hex(acls, taglen));
 1172|    422|	mask = 0x40, offs = 1;
 1173|  3.13k|	for (ii = 0; ii < 7; ii++, mask /= 2)  {
  ------------------
  |  Branch (1173:15): [True: 2.88k, False: 255]
  ------------------
 1174|  2.88k|		unsigned char op = file->type == SC_FILE_TYPE_DF ? ops_DF[ii] : ops_EF[ii];
  ------------------
  |  |  214|  2.88k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1174:22): [True: 575, False: 2.30k]
  ------------------
 1175|       |
 1176|       |		/* avoid any access to acls[offs] beyond the taglen */
 1177|  2.88k|		if (offs >= taglen) {
  ------------------
  |  Branch (1177:7): [True: 167, False: 2.71k]
  ------------------
 1178|    167|			sc_log(ctx, "Warning: Invalid offset reached during ACL parsing");
  ------------------
  |  |   71|    167|#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|    167|			break;
 1180|    167|		}
 1181|  2.71k|		if (!(mask & acls[0]))
  ------------------
  |  Branch (1181:7): [True: 1.31k, False: 1.39k]
  ------------------
 1182|  1.31k|			continue;
 1183|       |
 1184|  1.39k|		sc_log(ctx, "ACLs mask 0x%X, offs %"SC_FORMAT_LEN_SIZE_T"u, op 0x%X, acls[offs] 0x%X", mask, offs, op, acls[offs]);
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 1185|  1.39k|		if (op == 0xFF)   {
  ------------------
  |  Branch (1185:7): [True: 484, False: 914]
  ------------------
 1186|    484|			;
 1187|    484|		}
 1188|    914|		else if (acls[offs] == 0)   {
  ------------------
  |  Branch (1188:12): [True: 310, False: 604]
  ------------------
 1189|    310|			sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|    310|#define SC_AC_NONE			0x00000000
  ------------------
 1190|    310|		}
 1191|    604|		else if (acls[offs] == 0xFF)   {
  ------------------
  |  Branch (1191:12): [True: 95, False: 509]
  ------------------
 1192|     95|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|     95|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1193|     95|		}
 1194|    509|		else if ((acls[offs] & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   89|    509|#define IASECC_SCB_METHOD_MASK		0x70
  ------------------
              		else if ((acls[offs] & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   93|    509|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
  |  Branch (1194:12): [True: 42, False: 467]
  ------------------
 1195|     42|			sc_file_add_acl_entry(file, op, SC_AC_SEN, acls[offs] & IASECC_SCB_METHOD_MASK_REF);
  ------------------
  |  |  156|     42|#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|     42|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1196|     42|		}
 1197|    467|		else if (acls[offs] & IASECC_SCB_METHOD_MASK)   {
  ------------------
  |  |   89|    467|#define IASECC_SCB_METHOD_MASK		0x70
  ------------------
  |  Branch (1197:12): [True: 328, False: 139]
  ------------------
 1198|    328|			sc_file_add_acl_entry(file, op, SC_AC_SCB, acls[offs]);
  ------------------
  |  |  157|    328|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
 1199|    328|		}
 1200|    139|		else   {
 1201|    139|			sc_log(ctx, "Warning: non supported SCB method: %X", acls[offs]);
  ------------------
  |  |   71|    139|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1202|    139|			sc_file_add_acl_entry(file, op, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    139|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1203|    139|		}
 1204|       |
 1205|  1.39k|		offs++;
 1206|  1.39k|	}
 1207|       |
 1208|    422|	LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  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: 422, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    422|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 422]
  |  |  |  |  ------------------
  |  |  |  |  157|    422|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    422|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    422|	return _ret; \
  |  |  |  |  163|    422|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1209|    422|}
card-iasecc.c:iasecc_se_get_info_from_cache:
 1592|     18|{
 1593|     18|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1594|     18|	struct sc_context *ctx = card->ctx;
 1595|     18|	struct iasecc_se_info *si = NULL;
 1596|     18|	int rv;
 1597|       |
 1598|     18|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1599|       |
 1600|     18|	for(si = prv->se_info; si; si = si->next)   {
  ------------------
  |  Branch (1600:25): [True: 0, False: 18]
  ------------------
 1601|      0|		if (si->reference != se->reference)
  ------------------
  |  Branch (1601:7): [True: 0, False: 0]
  ------------------
 1602|      0|			continue;
 1603|      0|		if (!(prv->cache.valid && prv->cache.current_df) && si->df)
  ------------------
  |  Branch (1603:9): [True: 0, False: 0]
  |  Branch (1603:29): [True: 0, False: 0]
  |  Branch (1603:55): [True: 0, False: 0]
  ------------------
 1604|      0|			continue;
 1605|      0|		if (prv->cache.valid && prv->cache.current_df && !si->df)
  ------------------
  |  Branch (1605:7): [True: 0, False: 0]
  |  Branch (1605:27): [True: 0, False: 0]
  |  Branch (1605:52): [True: 0, False: 0]
  ------------------
 1606|      0|			continue;
 1607|      0|		if (prv->cache.valid && prv->cache.current_df && si->df)
  ------------------
  |  Branch (1607:7): [True: 0, False: 0]
  |  Branch (1607:27): [True: 0, False: 0]
  |  Branch (1607:52): [True: 0, False: 0]
  ------------------
 1608|      0|			if (memcmp(&prv->cache.current_df->path, &si->df->path, sizeof(struct sc_path)))
  ------------------
  |  Branch (1608:8): [True: 0, False: 0]
  ------------------
 1609|      0|				continue;
 1610|      0|		break;
 1611|      0|	}
 1612|       |
 1613|     18|	if (!si)
  ------------------
  |  Branch (1613:6): [True: 18, False: 0]
  ------------------
 1614|     18|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|     18|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1615|       |
 1616|      0|	memcpy(se, si, sizeof(struct iasecc_se_info));
 1617|       |
 1618|      0|	if (si->df)   {
  ------------------
  |  Branch (1618:6): [True: 0, False: 0]
  ------------------
 1619|      0|		sc_file_dup(&se->df, si->df);
 1620|      0|		if (se->df == NULL)
  ------------------
  |  Branch (1620:7): [True: 0, False: 0]
  ------------------
 1621|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1622|      0|	}
 1623|       |
 1624|      0|	rv = iasecc_docp_copy(ctx, &si->docp, &se->docp);
 1625|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1626|       |
 1627|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|      0|}
card-iasecc.c:iasecc_se_cache_info:
 1549|      6|{
 1550|      6|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1551|      6|	struct sc_context *ctx = card->ctx;
 1552|      6|	struct iasecc_se_info *se_info = NULL, *si = NULL;
 1553|      6|	int rv;
 1554|       |
 1555|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1556|       |
 1557|      6|	se_info = calloc(1, sizeof(struct iasecc_se_info));
 1558|      6|	if (!se_info)
  ------------------
  |  Branch (1558:6): [True: 0, False: 6]
  ------------------
 1559|      6|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1560|      6|	memcpy(se_info, se, sizeof(struct iasecc_se_info));
 1561|       |
 1562|      6|	if (prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  Branch (1562:6): [True: 6, False: 0]
  |  Branch (1562:26): [True: 0, False: 6]
  ------------------
 1563|      0|		sc_file_dup(&se_info->df, prv->cache.current_df);
 1564|      0|		if (se_info->df == NULL)   {
  ------------------
  |  Branch (1564:7): [True: 0, False: 0]
  ------------------
 1565|      0|			free(se_info);
 1566|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1567|      0|		}
 1568|      0|	}
 1569|       |
 1570|      6|	rv = iasecc_docp_copy(ctx, &se->docp, &se_info->docp);
 1571|      6|	if (rv < 0)   {
  ------------------
  |  Branch (1571:6): [True: 0, False: 6]
  ------------------
 1572|      0|		free(se_info->df);
 1573|      0|		free(se_info);
 1574|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1575|      0|	}
 1576|       |
 1577|      6|	if (!prv->se_info)   {
  ------------------
  |  Branch (1577:6): [True: 6, False: 0]
  ------------------
 1578|      6|		prv->se_info = se_info;
 1579|      6|	}
 1580|      0|	else    {
 1581|      0|		for (si = prv->se_info; si->next; si = si->next)
  ------------------
  |  Branch (1581:27): [True: 0, False: 0]
  ------------------
 1582|      0|			;
 1583|      0|		si->next = se_info;
 1584|      0|	}
 1585|       |
 1586|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1587|      6|}
card-iasecc.c:sc_get_driver:
 3637|  3.69k|{
 3638|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 3639|       |
 3640|  3.69k|	if (!iso_ops)
  ------------------
  |  Branch (3640:6): [True: 1, False: 3.69k]
  ------------------
 3641|      1|		iso_ops = iso_drv->ops;
 3642|       |
 3643|  3.69k|	iasecc_ops = *iso_ops;
 3644|       |
 3645|  3.69k|	iasecc_ops.match_card = iasecc_match_card;
 3646|  3.69k|	iasecc_ops.init = iasecc_init;
 3647|  3.69k|	iasecc_ops.finish = iasecc_finish;
 3648|  3.69k|	iasecc_ops.read_binary = iasecc_read_binary;
 3649|       |	/*	write_binary: ISO7816 implementation works	*/
 3650|       |	/*	update_binary: ISO7816 implementation works	*/
 3651|  3.69k|	iasecc_ops.erase_binary = iasecc_erase_binary;
 3652|       |	/*	resize_binary	*/
 3653|       |	/* 	read_record: Untested	*/
 3654|       |	/*	write_record: Untested	*/
 3655|       |	/*	append_record: Untested	*/
 3656|       |	/*	update_record: Untested	*/
 3657|  3.69k|	iasecc_ops.select_file = iasecc_select_file;
 3658|       |	/*	get_response: Untested	*/
 3659|  3.69k|	iasecc_ops.get_challenge = iasecc_get_challenge;
 3660|  3.69k|	iasecc_ops.logout = iasecc_logout;
 3661|       |	/*	restore_security_env	*/
 3662|  3.69k|	iasecc_ops.set_security_env = iasecc_set_security_env;
 3663|  3.69k|	iasecc_ops.decipher = iasecc_decipher;
 3664|  3.69k|	iasecc_ops.compute_signature = iasecc_compute_signature;
 3665|  3.69k|	iasecc_ops.create_file = iasecc_create_file;
 3666|  3.69k|	iasecc_ops.delete_file = iasecc_delete_file;
 3667|       |	/*	list_files	*/
 3668|  3.69k|	iasecc_ops.check_sw = iasecc_check_sw;
 3669|  3.69k|	iasecc_ops.card_ctl = iasecc_card_ctl;
 3670|  3.69k|	iasecc_ops.process_fci = iasecc_process_fci;
 3671|       |	/*	construct_fci: Not needed	*/
 3672|  3.69k|	iasecc_ops.pin_cmd = iasecc_pin_cmd;
 3673|       |	/*	get_data: Not implemented	*/
 3674|       |	/*	put_data: Not implemented	*/
 3675|       |	/*	delete_record: Not implemented	*/
 3676|       |
 3677|  3.69k|	iasecc_ops.read_public_key = iasecc_read_public_key;
 3678|       |
 3679|  3.69k|	return &iasecc_drv;
 3680|  3.69k|}
card-iasecc.c:iasecc_match_card:
  353|  2.71k|{
  354|  2.71k|	struct sc_context *ctx = card->ctx;
  355|  2.71k|	int i;
  356|       |
  357|  2.71k|	i = _sc_match_atr(card, iasecc_known_atrs, &card->type);
  358|  2.71k|	if (i < 0)   {
  ------------------
  |  Branch (358:6): [True: 2.45k, False: 259]
  ------------------
  359|  2.45k|		sc_log(ctx, "card not matched");
  ------------------
  |  |   71|  2.45k|#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|  2.45k|		return 0;
  361|  2.45k|	}
  362|       |
  363|    259|	sc_log(ctx, "'%s' card matched", iasecc_known_atrs[i].name);
  ------------------
  |  |   71|    259|#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|    259|	return 1;
  365|  2.71k|}
card-iasecc.c:iasecc_init:
  628|    259|{
  629|    259|	struct sc_context *ctx = card->ctx;
  630|    259|	struct iasecc_private_data *private_data = NULL;
  631|    259|	int rv = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|    259|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
  632|    259|	void *old_drv_data = card->drv_data;
  633|       |
  634|    259|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    259|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    259|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    259|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    259|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 259]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  635|    259|	private_data = (struct iasecc_private_data *) calloc(1, sizeof(struct iasecc_private_data));
  636|    259|	if (private_data == NULL)
  ------------------
  |  Branch (636:6): [True: 0, False: 259]
  ------------------
  637|    259|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  638|       |
  639|    259|	card->cla  = 0x00;
  640|    259|	card->drv_data = private_data;
  641|       |
  642|    259|	if (card->type == SC_CARD_TYPE_IASECC_GEMALTO)
  ------------------
  |  Branch (642:6): [True: 122, False: 137]
  ------------------
  643|    122|		rv = iasecc_init_gemalto(card);
  644|    137|	else if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)
  ------------------
  |  Branch (644:11): [True: 26, False: 111]
  ------------------
  645|     26|		rv = iasecc_init_oberthur(card);
  646|    111|	else if (card->type == SC_CARD_TYPE_IASECC_SAGEM)
  ------------------
  |  Branch (646:11): [True: 79, False: 32]
  ------------------
  647|     79|		rv = iasecc_init_amos_or_sagem(card);
  648|     32|	else if (card->type == SC_CARD_TYPE_IASECC_AMOS)
  ------------------
  |  Branch (648:11): [True: 0, False: 32]
  ------------------
  649|      0|		rv = iasecc_init_amos_or_sagem(card);
  650|     32|	else if (card->type == SC_CARD_TYPE_IASECC_MI)
  ------------------
  |  Branch (650:11): [True: 0, False: 32]
  ------------------
  651|      0|		rv = iasecc_init_amos_or_sagem(card);
  652|     32|	else if (iasecc_is_cpx(card))
  ------------------
  |  Branch (652:11): [True: 32, False: 0]
  ------------------
  653|     32|		rv = iasecc_init_cpx(card);
  654|      0|	else {
  655|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|      0|	}
  657|       |
  658|       |
  659|    259|	if (!rv)   {
  ------------------
  |  Branch (659:6): [True: 208, False: 51]
  ------------------
  660|    208|		if (card->ef_atr && card->ef_atr->aid.len)   {
  ------------------
  |  Branch (660:7): [True: 208, False: 0]
  |  Branch (660:23): [True: 17, False: 191]
  ------------------
  661|     17|			struct sc_path path;
  662|       |
  663|     17|			memset(&path, 0, sizeof(struct sc_path));
  664|     17|			path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|     17|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  665|     17|			memcpy(path.value, card->ef_atr->aid.value, card->ef_atr->aid.len);
  666|     17|			path.len = card->ef_atr->aid.len;
  667|       |
  668|     17|			rv = iasecc_select_file(card, &path, NULL);
  669|     17|			sc_log(ctx, "Select ECC ROOT with the AID from EF.ATR: rv %i", 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__
  |  |  ------------------
  ------------------
  670|     17|			LOG_TEST_GOTO_ERR(ctx, rv, "Select EF.ATR AID failed");
  ------------------
  |  |  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: 1, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  671|     17|		}
  672|       |
  673|    207|		iasecc_get_serialnr(card, NULL);
  674|    207|	}
  675|       |
  676|    258|#ifdef ENABLE_SM
  677|    258|	card->sm_ctx.ops.read_binary = _iasecc_sm_read_binary;
  678|    258|	card->sm_ctx.ops.update_binary = _iasecc_sm_update_binary;
  679|    258|#endif
  680|       |
  681|    258|	if (!rv && card->ef_atr && card->ef_atr->aid.len)   {
  ------------------
  |  Branch (681:6): [True: 207, False: 51]
  |  Branch (681:13): [True: 207, False: 0]
  |  Branch (681:29): [True: 16, False: 191]
  ------------------
  682|     16|		sc_log(ctx, "EF.ATR(aid:'%s')", sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  683|     16|	}
  684|       |
  685|    259|err:
  686|    259|	if (rv < 0) {
  ------------------
  |  Branch (686:6): [True: 52, False: 207]
  ------------------
  687|     52|		sc_invalidate_cache(card);
  688|     52|		free(private_data);
  689|     52|		card->drv_data = old_drv_data;
  690|    207|	} else {
  691|    207|		free(old_drv_data);
  692|    207|	}
  693|       |
  694|    259|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    259|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    259|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    259|	int _ret = r; \
  |  |  |  |  155|    259|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 259, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    259|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 207]
  |  |  |  |  ------------------
  |  |  |  |  157|    259|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    259|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    259|	return _ret; \
  |  |  |  |  163|    259|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  695|    259|}
card-iasecc.c:iasecc_init_gemalto:
  423|    122|{
  424|    122|	struct sc_context *ctx = card->ctx;
  425|    122|	struct sc_path path;
  426|    122|	unsigned int flags;
  427|    122|	int rv = 0;
  428|       |
  429|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  430|       |
  431|    122|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|    122|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|    122|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |  102|    122|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|    122|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  115|    122|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|    122|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  120|    122|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  118|    122|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|    122|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|    122|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  142|    122|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|    122|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  143|    122|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|    122|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  147|    122|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  432|       |
  433|    122|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|    122|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|    122|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  557|    122|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|    122|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  554|    122|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|    122|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  564|    122|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|    122|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  560|    122|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  434|       |
  435|    122|	sc_format_path("3F00", &path);
  436|    122|	if (SC_SUCCESS != sc_select_file(card, &path, NULL)) {
  ------------------
  |  |   28|    122|#define SC_SUCCESS				0
  ------------------
  |  Branch (436:6): [True: 122, False: 0]
  ------------------
  437|       |		/* Result ignored*/
  438|    122|		sc_log(card->ctx, "Warning, MF select failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  439|    122|	}
  440|       |
  441|    122|	rv = iasecc_parse_ef_atr(card);
  442|    122|	sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  443|    122|	if (rv == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|    122|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (443:6): [True: 0, False: 122]
  ------------------
  444|      0|		sc_log(ctx, "Select MF");
  ------------------
  |  |   71|      0|#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|      0|		rv = iasecc_select_mf(card, NULL);
  446|      0|		sc_log(ctx, "rv %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__
  |  |  ------------------
  ------------------
  447|      0|		LOG_TEST_RET(ctx, rv, "MF selection 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  448|       |
  449|      0|		rv = iasecc_parse_ef_atr(card);
  450|      0|		sc_log(ctx, "rv %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__
  |  |  ------------------
  ------------------
  451|      0|	}
  452|    122|	sc_log(ctx, "rv %i", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  453|    122|	LOG_TEST_RET(ctx, rv, "Cannot read/parse EF.ATR");
  ------------------
  |  |  174|    122|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    122|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    122|	int _ret = (r); \
  |  |  |  |  168|    122|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 116]
  |  |  |  |  ------------------
  |  |  |  |  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|    122|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 116]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|       |
  455|    116|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  456|    116|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  457|       |
  458|    116|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    116|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    116|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    116|	int _ret = r; \
  |  |  |  |  155|    116|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 116, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    116|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 116]
  |  |  |  |  ------------------
  |  |  |  |  157|    116|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    116|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    116|	return _ret; \
  |  |  |  |  163|    116|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  459|    116|}
card-iasecc.c:iasecc_parse_ef_atr:
  369|    276|{
  370|    276|	struct sc_context *ctx = card->ctx;
  371|    276|	struct iasecc_private_data *pdata = (struct iasecc_private_data *) card->drv_data;
  372|    276|	struct iasecc_version *version = &pdata->version;
  373|    276|	struct iasecc_io_buffer_sizes *sizes = &pdata->max_sizes;
  374|    276|	int rv;
  375|       |
  376|    276|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    276|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    276|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    276|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    276|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 276]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  377|    276|	rv = sc_parse_ef_atr(card);
  378|    276|	LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  174|    276|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    276|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    276|	int _ret = (r); \
  |  |  |  |  168|    276|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 27, False: 249]
  |  |  |  |  ------------------
  |  |  |  |  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|    276|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 249]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|       |
  380|    249|	if (card->ef_atr->pre_issuing_len < 4)
  ------------------
  |  Branch (380:6): [True: 30, False: 219]
  ------------------
  381|    249|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid pre-issuing data");
  ------------------
  |  |  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: 30, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|       |
  383|    219|	version->ic_manufacturer =	card->ef_atr->pre_issuing[0];
  384|    219|	version->ic_type =		card->ef_atr->pre_issuing[1];
  385|    219|	version->os_version =		card->ef_atr->pre_issuing[2];
  386|    219|	version->iasecc_version =	card->ef_atr->pre_issuing[3];
  387|    219|	sc_log(ctx, "EF.ATR: IC manufacturer/type %X/%X, OS/IasEcc versions %X/%X",
  ------------------
  |  |   71|    219|#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|    219|		version->ic_manufacturer, version->ic_type, version->os_version, version->iasecc_version);
  389|       |
  390|    219|	if (card->ef_atr->issuer_data_len < 16)
  ------------------
  |  Branch (390:6): [True: 11, False: 208]
  ------------------
  391|    219|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid issuer 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|       |
  393|    208|	sizes->send =	 card->ef_atr->issuer_data[2] * 0x100 + card->ef_atr->issuer_data[3];
  394|    208|	sizes->send_sc = card->ef_atr->issuer_data[6] * 0x100 + card->ef_atr->issuer_data[7];
  395|    208|	sizes->recv =	 card->ef_atr->issuer_data[10] * 0x100 + card->ef_atr->issuer_data[11];
  396|    208|	sizes->recv_sc = card->ef_atr->issuer_data[14] * 0x100 + card->ef_atr->issuer_data[15];
  397|       |
  398|    208|	sc_log(ctx,
  ------------------
  |  |   71|    208|#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|    208|		"EF.ATR: IO Buffer Size send/sc %"SC_FORMAT_LEN_SIZE_T"d/%"SC_FORMAT_LEN_SIZE_T"d "
  400|    208|		"recv/sc %"SC_FORMAT_LEN_SIZE_T"d/%"SC_FORMAT_LEN_SIZE_T"d",
  401|    208|		sizes->send, sizes->send_sc, sizes->recv, sizes->recv_sc);
  402|       |
  403|    208|	card->max_send_size = sizes->send;
  404|    208|	card->max_recv_size = sizes->recv;
  405|       |
  406|       |	/* Most of the card producers interpret 'send' values as "maximum APDU data size".
  407|       |	 * Oberthur strictly follows specification and interpret these values as "maximum APDU command size".
  408|       |	 * Here we need 'data size'.
  409|       |	 */
  410|    208|	if (card->max_send_size > 0xFF)
  ------------------
  |  Branch (410:6): [True: 38, False: 170]
  ------------------
  411|     38|		card->max_send_size -= 5;
  412|       |
  413|    208|	sc_log(ctx,
  ------------------
  |  |   71|    208|#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|    208|	       "EF.ATR: max send/recv sizes %"SC_FORMAT_LEN_SIZE_T"X/%"SC_FORMAT_LEN_SIZE_T"X",
  415|    208|	       card->max_send_size, card->max_recv_size);
  416|       |
  417|    208|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    208|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    208|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    208|	int _ret = r; \
  |  |  |  |  155|    208|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 208, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    208|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 208]
  |  |  |  |  ------------------
  |  |  |  |  157|    208|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    208|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    208|	return _ret; \
  |  |  |  |  163|    208|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  418|    208|}
card-iasecc.c:iasecc_init_oberthur:
  492|     26|{
  493|     26|	struct sc_context *ctx = card->ctx;
  494|     26|	unsigned int flags;
  495|     26|	int rv = 0;
  496|       |
  497|     26|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     26|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     26|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     26|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  498|       |
  499|     26|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|     26|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|     26|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |  102|     26|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|     26|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  115|     26|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|     26|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  120|     26|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  118|     26|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|     26|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|     26|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  142|     26|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|     26|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  143|     26|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|     26|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  147|     26|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  500|       |
  501|     26|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  502|     26|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  503|       |
  504|     26|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|     26|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|     26|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  557|     26|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|     26|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  554|     26|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|     26|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  564|     26|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|     26|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  560|     26|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  505|       |
  506|     26|	iasecc_parse_ef_atr(card);
  507|       |
  508|       |	/* if we fail to select CM, */
  509|     26|	if (gp_select_card_manager(card)) {
  ------------------
  |  Branch (509:6): [True: 14, False: 12]
  ------------------
  510|     14|		gp_select_isd_rid(card);
  511|     14|	}
  512|       |
  513|     26|	rv = iasecc_oberthur_match(card);
  514|     26|	LOG_TEST_RET(ctx, rv, "unknown Oberthur's IAS/ECC card");
  ------------------
  |  |  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: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  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|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  515|       |
  516|     26|	rv = iasecc_select_mf(card, NULL);
  517|     26|	LOG_TEST_RET(ctx, rv, "MF selection error");
  ------------------
  |  |  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: 9, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  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|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  518|       |
  519|     17|	rv = iasecc_parse_ef_atr(card);
  520|     17|	LOG_TEST_RET(ctx, rv, "EF.ATR read or parse error");
  ------------------
  |  |  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: 5, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  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|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  521|       |
  522|     12|	sc_log(ctx, "EF.ATR(aid:'%s')", sc_dump_hex(card->ef_atr->aid.value, card->ef_atr->aid.len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  523|     12|	LOG_FUNC_RETURN(ctx, 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: 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|      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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|     12|}
card-iasecc.c:iasecc_oberthur_match:
  464|     26|{
  465|     26|	struct sc_context *ctx = card->ctx;
  466|     26|	unsigned char *hist = card->reader->atr_info.hist_bytes;
  467|       |
  468|     26|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     26|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     26|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     26|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  469|       |
  470|     26|	if (*hist != 0x80 || ((*(hist+1)&0xF0) != 0xF0))
  ------------------
  |  Branch (470:6): [True: 0, False: 26]
  |  Branch (470:23): [True: 0, False: 26]
  ------------------
  471|     26|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  472|       |
  473|     26|	sc_log_hex(ctx, "AID in historical_bytes", hist + 2, *(hist+1) & 0x0F);
  ------------------
  |  |  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__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  474|       |
  475|     26|	if (memcmp(hist + 2, OberthurIASECC_AID.value, *(hist+1) & 0x0F))
  ------------------
  |  Branch (475:6): [True: 0, False: 26]
  ------------------
  476|     26|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  477|       |
  478|     26|	if (!card->ef_atr)
  ------------------
  |  Branch (478:6): [True: 19, False: 7]
  ------------------
  479|     19|		card->ef_atr = calloc(1, sizeof(struct sc_ef_atr));
  480|     26|	if (!card->ef_atr)
  ------------------
  |  Branch (480:6): [True: 0, False: 26]
  ------------------
  481|     26|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  482|       |
  483|     26|	memcpy(card->ef_atr->aid.value, OberthurIASECC_AID.value, OberthurIASECC_AID.len);
  484|     26|	card->ef_atr->aid.len = OberthurIASECC_AID.len;
  485|       |
  486|     26|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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: 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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  487|     26|}
card-iasecc.c:iasecc_init_amos_or_sagem:
  554|     79|{
  555|     79|	struct sc_context *ctx = card->ctx;
  556|     79|	unsigned int flags;
  557|     79|	int rv = 0;
  558|       |
  559|     79|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     79|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     79|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     79|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     79|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 79]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|       |
  561|     79|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|     79|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|     79|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |  102|     79|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|     79|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  115|     79|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|     79|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  120|     79|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  118|     79|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|     79|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|     79|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  142|     79|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|     79|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  143|     79|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|     79|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  147|     79|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  562|       |
  563|     79|	_sc_card_add_rsa_alg(card, 1024, flags, 0x10001);
  564|     79|	_sc_card_add_rsa_alg(card, 2048, flags, 0x10001);
  565|       |
  566|     79|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|     79|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|     79|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  557|     79|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|     79|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  554|     79|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|     79|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  564|     79|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|     79|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  560|     79|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  567|       |
  568|     79|	if (card->type == SC_CARD_TYPE_IASECC_MI)   {
  ------------------
  |  Branch (568:6): [True: 0, False: 79]
  ------------------
  569|      0|		rv = iasecc_mi_match(card);
  570|      0|		if (rv)
  ------------------
  |  Branch (570:7): [True: 0, False: 0]
  ------------------
  571|      0|			card->type = SC_CARD_TYPE_IASECC_MI2;
  572|      0|		else
  573|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  574|      0|	}
  575|       |
  576|     79|	rv = iasecc_parse_ef_atr(card);
  577|     79|	if (rv == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|     79|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (577:6): [True: 0, False: 79]
  ------------------
  578|      0|		rv = iasecc_select_mf(card, NULL);
  579|      0|		LOG_TEST_RET(ctx, rv, "MF selection 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  580|       |
  581|      0|		rv = iasecc_parse_ef_atr(card);
  582|      0|	}
  583|     79|	LOG_TEST_RET(ctx, rv, "IASECC: ATR parse failed");
  ------------------
  |  |  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: 12, False: 67]
  |  |  |  |  ------------------
  |  |  |  |  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|     79|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 67]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|       |
  585|     67|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     67|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     67|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     67|	int _ret = r; \
  |  |  |  |  155|     67|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 67, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     67|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 67]
  |  |  |  |  ------------------
  |  |  |  |  157|     67|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     67|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     67|	return _ret; \
  |  |  |  |  163|     67|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  586|     67|}
card-iasecc.c:iasecc_init_cpx:
  604|     32|{
  605|     32|	struct sc_context *ctx = card->ctx;
  606|     32|	unsigned int flags;
  607|     32|	int rv = 0;
  608|       |
  609|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  610|       |
  611|     32|	card->caps = IASECC_CARD_DEFAULT_CAPS;
  ------------------
  |  |   61|     32|#define IASECC_CARD_DEFAULT_CAPS ( 0 			\
  |  |   62|     32|		| SC_CARD_CAP_RNG			\
  |  |  ------------------
  |  |  |  |  557|     32|#define SC_CARD_CAP_RNG			0x00000004
  |  |  ------------------
  |  |   63|     32|		| SC_CARD_CAP_APDU_EXT			\
  |  |  ------------------
  |  |  |  |  554|     32|#define SC_CARD_CAP_APDU_EXT		0x00000001
  |  |  ------------------
  |  |   64|     32|		| SC_CARD_CAP_USE_FCI_AC		\
  |  |  ------------------
  |  |  |  |  564|     32|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  |  |  ------------------
  |  |   65|     32|		| SC_CARD_CAP_ISO7816_PIN_INFO)
  |  |  ------------------
  |  |  |  |  560|     32|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  |  |  ------------------
  ------------------
  612|       |
  613|     32|	flags = IASECC_CARD_DEFAULT_FLAGS;
  ------------------
  |  |   53|     32|#define IASECC_CARD_DEFAULT_FLAGS ( 0			\
  |  |   54|     32|		| SC_ALGORITHM_ONBOARD_KEY_GEN		\
  |  |  ------------------
  |  |  |  |  102|     32|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  |  |  ------------------
  |  |   55|     32|		| SC_ALGORITHM_RSA_PAD_ISO9796		\
  |  |  ------------------
  |  |  |  |  115|     32|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  |  |  ------------------
  |  |   56|     32|		| SC_ALGORITHM_RSA_PAD_PKCS1		\
  |  |  ------------------
  |  |  |  |  120|     32|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  118|     32|#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) */
  |  |  |  |  ------------------
  |  |  |  |  |  |  119|     32|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   57|     32|		| SC_ALGORITHM_RSA_HASH_NONE		\
  |  |  ------------------
  |  |  |  |  142|     32|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  |  |   58|     32|		| SC_ALGORITHM_RSA_HASH_SHA1		\
  |  |  ------------------
  |  |  |  |  143|     32|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  |  |   59|     32|		| SC_ALGORITHM_RSA_HASH_SHA256)
  |  |  ------------------
  |  |  |  |  147|     32|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
  614|       |
  615|     32|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  616|     32|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  617|     32|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  618|       |
  619|     32|	rv = iasecc_parse_ef_atr(card);
  620|     32|	LOG_TEST_RET(ctx, rv, "Parse EF.ATR");
  ------------------
  |  |  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: 19, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  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|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|       |
  622|     13|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  623|     13|}
card-iasecc.c:iasecc_get_serialnr:
 2492|    379|{
 2493|    379|	struct sc_context *ctx = card->ctx;
 2494|    379|	struct sc_iin *iin = &card->serialnr.iin;
 2495|    379|	struct sc_apdu apdu;
 2496|    379|	unsigned char rbuf[0xC0];
 2497|    379|	size_t ii, offs, len;
 2498|    379|	int rv;
 2499|       |
 2500|    379|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    379|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    379|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    379|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    379|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 379]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2501|    379|	if (card->serialnr.len)
  ------------------
  |  Branch (2501:6): [True: 4, False: 375]
  ------------------
 2502|      4|		goto end;
 2503|       |
 2504|    375|	memset(&card->serialnr, 0, sizeof(card->serialnr));
 2505|       |
 2506|    375|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, 0x80 | IASECC_SFI_EF_SN, 0);
  ------------------
  |  |  292|    375|#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|    375|#define IASECC_SFI_EF_SN	0x1C
  ------------------
 2507|    375|	apdu.le = sizeof(rbuf);
 2508|    375|	apdu.resp = rbuf;
 2509|    375|	apdu.resplen = sizeof(rbuf);
 2510|       |
 2511|    375|	rv = sc_transmit_apdu(card, &apdu);
 2512|    375|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    375|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    375|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    375|	int _ret = (r); \
  |  |  |  |  168|    375|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 367]
  |  |  |  |  ------------------
  |  |  |  |  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|    375|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 367]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2513|    367|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2514|    367|	LOG_TEST_RET(ctx, rv, "Get 'serial number' data failed");
  ------------------
  |  |  174|    367|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    367|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    367|	int _ret = (r); \
  |  |  |  |  168|    367|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 279, False: 88]
  |  |  |  |  ------------------
  |  |  |  |  169|    279|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    279|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    279|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    279|		return _ret; \
  |  |  |  |  172|    279|	} \
  |  |  |  |  173|    367|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 88]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2515|       |
 2516|     88|	if (apdu.resplen < 2 || rbuf[0] != ISO7812_PAN_SN_TAG || rbuf[1] > (apdu.resplen-2))
  ------------------
  |  |   29|    125|#define ISO7812_PAN_SN_TAG	0x5A
  ------------------
  |  Branch (2516:6): [True: 51, False: 37]
  |  Branch (2516:26): [True: 35, False: 2]
  |  Branch (2516:59): [True: 0, False: 2]
  ------------------
 2517|     88|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "serial number parse error");
  ------------------
  |  |  174|     86|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     86|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     86|	int _ret = (r); \
  |  |  |  |  168|     86|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 86, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     86|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     86|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     86|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     86|		return _ret; \
  |  |  |  |  172|     86|	} \
  |  |  |  |  173|     86|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2518|      2|	len = rbuf[1];
 2519|       |
 2520|      2|	iin->mii = (rbuf[2] >> 4) & 0x0F;
 2521|       |
 2522|      2|	iin->country = 0;
 2523|      8|	for (ii=5; ii<8; ii++)   {
  ------------------
  |  Branch (2523:13): [True: 6, False: 2]
  ------------------
 2524|      6|		iin->country *= 10;
 2525|      6|		iin->country += (rbuf[ii/2] >> ((ii & 0x01) ? 0 : 4)) & 0x0F;
  ------------------
  |  Branch (2525:35): [True: 4, False: 2]
  ------------------
 2526|      6|	}
 2527|       |
 2528|      2|	iin->issuer_id = 0;
 2529|      6|	for (ii=8; ii<10; ii++)   {
  ------------------
  |  Branch (2529:13): [True: 4, False: 2]
  ------------------
 2530|      4|		iin->issuer_id *= 10;
 2531|      4|		iin->issuer_id += (rbuf[ii/2] >> (ii & 0x01 ? 0 : 4)) & 0x0F;
  ------------------
  |  Branch (2531:37): [True: 2, False: 2]
  ------------------
 2532|      4|	}
 2533|       |
 2534|       |	/* Copy the serial number from the last 8 bytes (at most) */
 2535|      2|	offs = len > 8 ? len - 8 : 0;
  ------------------
  |  Branch (2535:9): [True: 2, False: 0]
  ------------------
 2536|      2|	if (card->type == SC_CARD_TYPE_IASECC_SAGEM)   {
  ------------------
  |  Branch (2536:6): [True: 0, False: 2]
  ------------------
 2537|       |		/* 5A 0A 92 50 00 20 10 10 25 00 01 3F */
 2538|       |		/*            00 02 01 01 02 50 00 13  */
 2539|      0|		for (ii=0; ii < len - offs; ii++)
  ------------------
  |  Branch (2539:14): [True: 0, False: 0]
  ------------------
 2540|      0|			*(card->serialnr.value + ii) = ((rbuf[ii + offs + 1] & 0x0F) << 4)
 2541|      0|				+ ((rbuf[ii + offs + 2] & 0xF0) >> 4) ;
 2542|      0|		card->serialnr.len = ii;
 2543|      0|	}
 2544|      2|	else   {
 2545|     18|		for (ii=0; ii < len - offs; ii++)
  ------------------
  |  Branch (2545:14): [True: 16, False: 2]
  ------------------
 2546|     16|			*(card->serialnr.value + ii) = rbuf[ii + offs + 2];
 2547|      2|		card->serialnr.len = ii;
 2548|      2|	}
 2549|       |
 2550|      2|	do  {
 2551|      2|		char txt[0x200];
 2552|       |
 2553|     18|		for (ii=0;ii<card->serialnr.len;ii++)
  ------------------
  |  Branch (2553:13): [True: 16, False: 2]
  ------------------
 2554|     16|			sprintf(txt + ii*2, "%02X", *(card->serialnr.value + ii));
 2555|       |
 2556|      2|		sc_log(ctx, "serial number '%s'; mii %i; country %i; issuer_id %li", txt, iin->mii, iin->country, iin->issuer_id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2557|      2|	} while(0);
  ------------------
  |  Branch (2557:10): [Folded, False: 2]
  ------------------
 2558|       |
 2559|      6|end:
 2560|      6|	if (serial)
  ------------------
  |  Branch (2560:6): [True: 4, False: 2]
  ------------------
 2561|      4|		memcpy(serial, &card->serialnr, sizeof(*serial));
 2562|       |
 2563|      6|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2564|      6|}
card-iasecc.c:_iasecc_sm_read_binary:
  770|     21|{
  771|     21|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
  772|     21|	struct sc_context *ctx = card->ctx;
  773|     21|	const struct sc_acl_entry *entry = NULL;
  774|     21|	int rv;
  775|       |
  776|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  777|     21|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  778|     21|	       "iasecc_sm_read_binary() card:%p offs:%i count:%"SC_FORMAT_LEN_SIZE_T"u ",
  779|     21|	       card, offs, count);
  780|     21|	if (offs > 0x7fff)
  ------------------
  |  Branch (780:6): [True: 0, False: 21]
  ------------------
  781|     21|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  782|       |
  783|     21|	if (count == 0)
  ------------------
  |  Branch (783:6): [True: 0, False: 21]
  ------------------
  784|      0|		return 0;
  785|       |
  786|     21|	if (prv->cache.valid && prv->cache.current_ef) {
  ------------------
  |  Branch (786:6): [True: 21, False: 0]
  |  Branch (786:26): [True: 21, False: 0]
  ------------------
  787|     21|		entry = sc_file_get_acl_entry(prv->cache.current_ef, SC_AC_OP_READ);
  ------------------
  |  |  188|     21|#define SC_AC_OP_READ			22
  ------------------
  788|     21|		if (!entry)
  ------------------
  |  Branch (788:7): [True: 2, False: 19]
  ------------------
  789|     21|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "iasecc_sm_read() 'READ' ACL not present");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  790|       |
  791|     19|		sc_log(ctx, "READ method/reference %X/%X", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  792|     19|		if ((entry->method == SC_AC_SCB) && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |  157|     19|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
              		if ((entry->method == SC_AC_SCB) && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |   91|     14|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  |  Branch (792:7): [True: 14, False: 5]
  |  Branch (792:39): [True: 14, False: 0]
  ------------------
  793|     14|			unsigned char se_num = entry->key_ref & IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|     14|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
  794|       |
  795|     14|			rv = iasecc_sm_read_binary(card, se_num, offs, buff, count);
  796|     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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  797|     14|		}
  798|     19|	}
  799|       |
  800|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  801|      5|}
card-iasecc.c:iasecc_finish:
 1438|    207|{
 1439|    207|	struct sc_context *ctx = card->ctx;
 1440|    207|	struct iasecc_private_data *private_data = (struct iasecc_private_data *)card->drv_data;
 1441|    207|	struct iasecc_se_info *se_info = private_data->se_info, *next;
 1442|       |
 1443|    207|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    207|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    207|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    207|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    207|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 207]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1444|       |
 1445|    207|	sc_invalidate_cache(card);
 1446|       |
 1447|    213|	while (se_info)   {
  ------------------
  |  Branch (1447:9): [True: 6, False: 207]
  ------------------
 1448|      6|		sc_file_free(se_info->df);
 1449|      6|		next = se_info->next;
 1450|      6|		free(se_info);
 1451|      6|		se_info = next;
 1452|      6|	}
 1453|       |
 1454|    207|	free(card->drv_data);
 1455|    207|	card->drv_data = NULL;
 1456|       |
 1457|    207|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    207|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 207]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1458|    207|}
card-iasecc.c:iasecc_read_binary:
  701|  1.37k|{
  702|  1.37k|	struct sc_context *ctx = card->ctx;
  703|  1.37k|	struct sc_apdu apdu;
  704|  1.37k|	int rv;
  705|       |
  706|  1.37k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.37k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.37k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.37k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.37k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  707|  1.37k|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  708|  1.37k|	       "iasecc_read_binary(card:%p) offs %i; count %"SC_FORMAT_LEN_SIZE_T"u",
  709|  1.37k|	       card, offs, count);
  710|  1.37k|	if (offs > 0x7fff) {
  ------------------
  |  Branch (710:6): [True: 1, False: 1.37k]
  ------------------
  711|      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__
  |  |  ------------------
  ------------------
  712|      1|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      1|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  713|      1|	}
  714|       |
  715|  1.37k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB0, (offs >> 8) & 0x7F, offs & 0xFF);
  ------------------
  |  |  292|  1.37k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  716|  1.37k|	apdu.le = count < 0x100 ? count : 0x100;
  ------------------
  |  Branch (716:12): [True: 124, False: 1.25k]
  ------------------
  717|  1.37k|	apdu.resplen = count;
  718|  1.37k|	apdu.resp = buf;
  719|       |
  720|  1.37k|	rv = sc_transmit_apdu(card, &apdu);
  721|  1.37k|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  1.37k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.37k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.37k|	int _ret = (r); \
  |  |  |  |  168|  1.37k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 10, False: 1.36k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.36k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  722|  1.36k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  723|  1.36k|	LOG_TEST_RET(ctx, rv, "iasecc_read_binary() failed");
  ------------------
  |  |  174|  1.36k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.36k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.36k|	int _ret = (r); \
  |  |  |  |  168|  1.36k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 217, False: 1.14k]
  |  |  |  |  ------------------
  |  |  |  |  169|    217|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    217|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    217|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    217|		return _ret; \
  |  |  |  |  172|    217|	} \
  |  |  |  |  173|  1.36k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  724|  1.14k|	sc_log(ctx,
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
  725|  1.14k|	       "iasecc_read_binary() apdu.resplen %"SC_FORMAT_LEN_SIZE_T"u",
  726|  1.14k|	       apdu.resplen);
  727|       |
  728|  1.14k|	if (apdu.resplen == IASECC_READ_BINARY_LENGTH_MAX && apdu.resplen < count)   {
  ------------------
  |  |   76|  2.29k|#define IASECC_READ_BINARY_LENGTH_MAX	0xE7
  ------------------
  |  Branch (728:6): [True: 26, False: 1.12k]
  |  Branch (728:55): [True: 25, False: 1]
  ------------------
  729|     25|		rv = iasecc_read_binary(card, (int)(offs + apdu.resplen), buf + apdu.resplen, count - apdu.resplen, flags);
  730|     25|		if (rv != SC_ERROR_WRONG_LENGTH)   {
  ------------------
  |  |   56|     25|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  |  Branch (730:7): [True: 25, False: 0]
  ------------------
  731|     25|			LOG_TEST_RET(ctx, rv, "iasecc_read_binary() read tail failed");
  ------------------
  |  |  174|     25|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     25|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     25|	int _ret = (r); \
  |  |  |  |  168|     25|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  732|     16|			apdu.resplen += rv;
  733|     16|		}
  734|     25|	}
  735|       |
  736|  1.13k|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  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: 30, False: 1.10k]
  |  |  |  |  ------------------
  |  |  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  157|     30|			"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.13k|	return _ret; \
  |  |  |  |  163|  1.13k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|  1.13k|}
card-iasecc.c:iasecc_sdo_get_data:
 2876|    132|{
 2877|    132|	struct sc_context *ctx = card->ctx;
 2878|    132|	int rv, sdo_tag;
 2879|       |
 2880|    132|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    132|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    132|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    132|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    132|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 132]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2881|       |
 2882|    132|	sdo_tag = iasecc_sdo_tag_from_class(sdo->sdo_class);
 2883|       |
 2884|    132|	rv = iasecc_sdo_get_tagged_data(card, sdo_tag, sdo);
 2885|       |	/* When there is no public data 'GET DATA' returns error */
 2886|    132|	if (rv != SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|    132|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (2886:6): [True: 125, False: 7]
  ------------------
 2887|    132|		LOG_TEST_RET(ctx, rv, "cannot parse ECC SDO data");
  ------------------
  |  |  174|    125|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    125|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    125|	int _ret = (r); \
  |  |  |  |  168|    125|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 124, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|    124|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    124|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    124|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    124|		return _ret; \
  |  |  |  |  172|    124|	} \
  |  |  |  |  173|    125|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2888|       |
 2889|      8|	rv = iasecc_sdo_get_tagged_data(card, IASECC_DOCP_TAG, sdo);
  ------------------
  |  |   31|      8|#define IASECC_DOCP_TAG				0xA0
  ------------------
 2890|      8|	LOG_TEST_RET(ctx, rv, "cannot parse ECC DOCP data");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2891|       |
 2892|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2893|      0|}
card-iasecc.c:iasecc_sdo_tag_from_class:
 2777|    132|{
 2778|    132|	switch (sdo_class & ~IASECC_OBJECT_REF_LOCAL)   {
  ------------------
  |  |   59|    132|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  |  Branch (2778:10): [True: 132, False: 0]
  ------------------
 2779|    124|	case IASECC_SDO_CLASS_CHV:
  ------------------
  |  |   98|    124|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
  |  Branch (2779:2): [True: 124, False: 8]
  ------------------
 2780|    124|		return IASECC_SDO_CHV_TAG;
  ------------------
  |  |   63|    124|#define IASECC_SDO_CHV_TAG		0x7F41
  ------------------
 2781|      5|	case IASECC_SDO_CLASS_RSA_PRIVATE:
  ------------------
  |  |  100|      5|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  Branch (2781:2): [True: 5, False: 127]
  ------------------
 2782|      5|		return IASECC_SDO_PRVKEY_TAG;
  ------------------
  |  |   68|      5|#define IASECC_SDO_PRVKEY_TAG			0x7F48
  ------------------
 2783|      3|	case IASECC_SDO_CLASS_RSA_PUBLIC:
  ------------------
  |  |  101|      3|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  |  Branch (2783:2): [True: 3, False: 129]
  ------------------
 2784|      3|		return IASECC_SDO_PUBKEY_TAG;
  ------------------
  |  |   76|      3|#define IASECC_SDO_PUBKEY_TAG			0x7F49
  ------------------
 2785|      0|	case IASECC_SDO_CLASS_SE:
  ------------------
  |  |  102|      0|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
  |  Branch (2785:2): [True: 0, False: 132]
  ------------------
 2786|      0|		return IASECC_SDO_CLASS_SE;
  ------------------
  |  |  102|      0|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
 2787|      0|	case IASECC_SDO_CLASS_KEYSET:
  ------------------
  |  |   99|      0|#define IASECC_SDO_CLASS_KEYSET		0x0A
  ------------------
  |  Branch (2787:2): [True: 0, False: 132]
  ------------------
 2788|      0|		return IASECC_SDO_KEYSET_TAG;
  ------------------
  |  |   83|      0|#define IASECC_SDO_KEYSET_TAG			0xA2
  ------------------
 2789|    132|	}
 2790|       |
 2791|      0|	return -1;
 2792|    132|}
card-iasecc.c:iasecc_sdo_get_tagged_data:
 2797|    140|{
 2798|    140|	struct sc_context *ctx = card->ctx;
 2799|    140|	struct sc_apdu apdu;
 2800|    140|	unsigned char sbuf[0x100];
 2801|    140|	size_t offs = sizeof(sbuf) - 1;
 2802|    140|	unsigned char rbuf[0x400];
 2803|    140|	int rv;
 2804|       |
 2805|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2806|       |
 2807|    140|	sc_log(ctx, "sdo_tag=0x%x sdo_ref=0x%x sdo_class=0x%x", sdo_tag,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2808|    140|			sdo->sdo_ref, sdo->sdo_class);
 2809|       |
 2810|       |	/* XXX: for the CPx, the SDO are available from some specific path */
 2811|    140|	if (iasecc_is_cpx(card)) {
  ------------------
  |  Branch (2811:6): [True: 15, False: 125]
  ------------------
 2812|     15|		struct sc_path path;
 2813|     15|		char *path_str = NULL;
 2814|     15|		switch(sdo_tag) {
 2815|      3|			case IASECC_SDO_PRVKEY_TAG:
  ------------------
  |  |   68|      3|#define IASECC_SDO_PRVKEY_TAG			0x7F48
  ------------------
  |  Branch (2815:4): [True: 3, False: 12]
  ------------------
 2816|       |			/* APDU 00 CB 3F FF 0B 4D 09 70 07 BF 90 02 03 7F 48 80 */
 2817|      3|			path_str = "3F00:0001";
 2818|      3|			break;
 2819|      8|			case IASECC_SDO_CHV_TAG:
  ------------------
  |  |   63|      8|#define IASECC_SDO_CHV_TAG		0x7F41
  ------------------
  |  Branch (2819:4): [True: 8, False: 7]
  ------------------
 2820|       |			/* APDU 00 CB 3F FF 0B 4D 09 70 07 BF 81 01 03 7F 41 80 */
 2821|      8|			path_str = "3F00";
 2822|      8|			break;
 2823|      4|			default:
  ------------------
  |  Branch (2823:4): [True: 4, False: 11]
  ------------------
 2824|      4|			path_str = NULL;
 2825|      4|			break;
 2826|     15|		}
 2827|     15|		if (path_str) {
  ------------------
  |  Branch (2827:7): [True: 11, False: 4]
  ------------------
 2828|     11|			sc_log(ctx, "Warning: Enforce the path=%s", path_str);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2829|     11|			sc_format_path(path_str, &path);
 2830|     11|			rv = iasecc_select_file(card, &path, NULL);
 2831|     11|			LOG_TEST_RET(ctx, rv, "path 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: 6, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2832|     11|		}
 2833|     15|	}
 2834|       |
 2835|    134|	sbuf[offs--] = 0x80;
 2836|    134|	sbuf[offs--] = sdo_tag & 0xFF;
 2837|    134|	if ((sdo_tag >> 8) & 0xFF)
  ------------------
  |  Branch (2837:6): [True: 126, False: 8]
  ------------------
 2838|    126|		sbuf[offs--] = (sdo_tag >> 8) & 0xFF;
 2839|    134|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2840|    134|	offs--;
 2841|       |
 2842|    134|	sbuf[offs--] = sdo->sdo_ref & 0x9F;
 2843|    134|	sbuf[offs--] = sdo->sdo_class | IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|    134|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 2844|    134|	sbuf[offs--] = IASECC_SDO_TAG_HEADER;
  ------------------
  |  |   27|    134|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
 2845|       |
 2846|    134|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2847|    134|	offs--;
 2848|    134|	sbuf[offs--] = IASECC_SDO_TEMPLATE_TAG;
  ------------------
  |  |   29|    134|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
 2849|       |
 2850|    134|	sbuf[offs] = sizeof(sbuf) - offs - 1;
 2851|    134|	offs--;
 2852|    134|	sbuf[offs] = 0x4D;
 2853|       |
 2854|    134|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xCB, 0x3F, 0xFF);
  ------------------
  |  |  294|    134|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 2855|    134|	apdu.data = sbuf + offs;
 2856|    134|	apdu.datalen = sizeof(sbuf) - offs;
 2857|    134|	apdu.lc = sizeof(sbuf) - offs;
 2858|    134|	apdu.resp = rbuf;
 2859|    134|	apdu.resplen = sizeof(rbuf);
 2860|    134|	apdu.le = 0x100;
 2861|       |
 2862|    134|	rv = sc_transmit_apdu(card, &apdu);
 2863|    134|	LOG_TEST_RET(ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    134|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    134|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    134|	int _ret = (r); \
  |  |  |  |  168|    134|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 129]
  |  |  |  |  ------------------
  |  |  |  |  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|    134|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 129]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2864|    129|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2865|    129|	LOG_TEST_RET(ctx, rv, "SDO get data error");
  ------------------
  |  |  174|    129|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    129|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    129|	int _ret = (r); \
  |  |  |  |  168|    129|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 19, False: 110]
  |  |  |  |  ------------------
  |  |  |  |  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|    129|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2866|       |
 2867|    110|	rv = iasecc_sdo_parse(card, apdu.resp, apdu.resplen, sdo);
 2868|    110|	LOG_TEST_RET(ctx, rv, "cannot parse SDO data");
  ------------------
  |  |  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: 109, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|    110|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2869|       |
 2870|      1|	LOG_FUNC_RETURN(ctx, 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2871|      1|}
card-iasecc.c:iasecc_create_file:
 1335|     23|{
 1336|     23|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1337|     23|	struct sc_context *ctx = card->ctx;
 1338|     23|	struct sc_apdu apdu;
 1339|     23|	const struct sc_acl_entry *entry = NULL;
 1340|     23|	unsigned char sbuf[0x100];
 1341|     23|	size_t sbuf_len;
 1342|     23|	int rv;
 1343|       |
 1344|     23|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     23|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     23|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     23|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     23|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1345|       |
 1346|     23|	if (file->type != SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|     23|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1346:6): [True: 1, False: 22]
  ------------------
 1347|     23|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Creation of the file with of this type is not 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1348|       |
 1349|     22|	rv = iasecc_fcp_encode(card, file, sbuf + 2, sizeof(sbuf)-2);
 1350|     22|	LOG_TEST_RET(ctx, rv, "FCP encode 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: 14, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1351|      8|	sbuf_len = rv;
 1352|       |
 1353|      8|	sbuf[0] = IASECC_FCP_TAG;
  ------------------
  |  |   46|      8|#define IASECC_FCP_TAG			0x62
  ------------------
 1354|      8|	sbuf[1] = sbuf_len;
 1355|       |
 1356|      8|	if (prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  Branch (1356:6): [True: 8, False: 0]
  |  Branch (1356:26): [True: 8, False: 0]
  ------------------
 1357|      8|		entry = sc_file_get_acl_entry(prv->cache.current_df, SC_AC_OP_CREATE);
  ------------------
  |  |  169|      8|#define SC_AC_OP_CREATE			3
  ------------------
 1358|      8|		if (!entry)
  ------------------
  |  Branch (1358:7): [True: 8, False: 0]
  ------------------
 1359|      8|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "iasecc_create_file() 'CREATE' ACL not present");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1360|       |
 1361|      0|		sc_log(ctx, "iasecc_create_file() 'CREATE' method/reference %X/%X", entry->method, entry->key_ref);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1362|      0|		sc_log(ctx, "iasecc_create_file() create data: '%s'", sc_dump_hex(sbuf, sbuf_len + 2));
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1363|      0|		if (entry->method == SC_AC_SCB && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |  157|      0|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
              		if (entry->method == SC_AC_SCB && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |   91|      0|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  |  Branch (1363:7): [True: 0, False: 0]
  |  Branch (1363:37): [True: 0, False: 0]
  ------------------
 1364|      0|                        rv = iasecc_sm_create_file(card, entry->key_ref & IASECC_SCB_METHOD_MASK_REF, sbuf, sbuf_len + 2);
  ------------------
  |  |   90|      0|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1365|      0|                        LOG_TEST_RET(ctx, rv, "iasecc_create_file() SM create 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1366|       |
 1367|      0|                        rv = iasecc_select_file(card, &file->path, NULL);
 1368|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1369|       |
 1370|      0|		}
 1371|      0|	}
 1372|       |
 1373|      0|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0, 0);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1374|      0|	apdu.data = sbuf;
 1375|      0|	apdu.datalen = sbuf_len + 2;
 1376|      0|	apdu.lc = sbuf_len + 2;
 1377|       |
 1378|      0|	rv = sc_transmit_apdu(card, &apdu);
 1379|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1380|      0|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1381|      0|	LOG_TEST_RET(ctx, rv, "iasecc_create_file() create 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1382|       |
 1383|      0|	rv = iasecc_select_file(card, &file->path, NULL);
 1384|      0|	LOG_TEST_RET(ctx, rv, "Cannot select newly created 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1385|       |
 1386|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1387|      0|}
card-iasecc.c:iasecc_fcp_encode:
 1214|     22|{
 1215|     22|	struct sc_context *ctx = card->ctx;
 1216|     22|	unsigned char buf[0x80], type;
 1217|     22|	unsigned char  ops[7] = {
 1218|     22|		SC_AC_OP_DELETE, 0xFF, SC_AC_OP_ACTIVATE, SC_AC_OP_DEACTIVATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  168|     22|#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|     22|#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|     22|#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|     22|#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|     22|#define SC_AC_OP_READ			22
  ------------------
 1219|     22|	};
 1220|     22|	unsigned char smbs[8];
 1221|     22|	size_t ii, amb, offs = 0, mask, nn_smb;
 1222|       |
 1223|     22|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     22|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     22|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     22|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     22|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1224|       |
 1225|     22|	if (file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     22|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1225:6): [True: 0, False: 22]
  ------------------
 1226|      0|		type = IASECC_FCP_TYPE_DF;
  ------------------
  |  |   57|      0|#define IASECC_FCP_TYPE_DF	0x38
  ------------------
 1227|     22|	else
 1228|     22|		type = IASECC_FCP_TYPE_EF;
  ------------------
  |  |   56|     22|#define IASECC_FCP_TYPE_EF	0x01
  ------------------
 1229|       |
 1230|     22|	buf[offs++] = IASECC_FCP_TAG_SIZE;
  ------------------
  |  |   47|     22|#define IASECC_FCP_TAG_SIZE		0x80
  ------------------
 1231|     22|	buf[offs++] = 2;
 1232|     22|	buf[offs++] = (file->size >> 8) & 0xFF;
 1233|     22|	buf[offs++] = file->size & 0xFF;
 1234|       |
 1235|     22|	buf[offs++] = IASECC_FCP_TAG_TYPE;
  ------------------
  |  |   48|     22|#define IASECC_FCP_TAG_TYPE		0x82
  ------------------
 1236|     22|	buf[offs++] = 1;
 1237|     22|	buf[offs++] = type;
 1238|       |
 1239|     22|	buf[offs++] = IASECC_FCP_TAG_FID;
  ------------------
  |  |   49|     22|#define IASECC_FCP_TAG_FID		0x83
  ------------------
 1240|     22|	buf[offs++] = 2;
 1241|     22|	buf[offs++] = (file->id >> 8) & 0xFF;
 1242|     22|	buf[offs++] = file->id & 0xFF;
 1243|       |
 1244|     22|	buf[offs++] = IASECC_FCP_TAG_SFID;
  ------------------
  |  |   51|     22|#define IASECC_FCP_TAG_SFID		0x88
  ------------------
 1245|     22|	buf[offs++] = 0;
 1246|       |
 1247|     22|	amb = 0, mask = 0x40, nn_smb = 0;
 1248|     89|	for (ii = 0; ii < sizeof(ops); ii++, mask >>= 1) {
  ------------------
  |  Branch (1248:15): [True: 81, False: 8]
  ------------------
 1249|     81|		const struct sc_acl_entry *entry;
 1250|       |
 1251|     81|		if (ops[ii]==0xFF)
  ------------------
  |  Branch (1251:7): [True: 20, False: 61]
  ------------------
 1252|     20|			continue;
 1253|       |
 1254|     61|		entry = sc_file_get_acl_entry(file, ops[ii]);
 1255|     61|		if (!entry)
  ------------------
  |  Branch (1255:7): [True: 0, False: 61]
  ------------------
 1256|      0|			continue;
 1257|       |
 1258|     61|		sc_log(ctx, "method %X; reference %X", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1259|     61|		if (entry->method == SC_AC_NEVER)
  ------------------
  |  |  163|     61|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (1259:7): [True: 14, False: 47]
  ------------------
 1260|     14|			continue;
 1261|     47|		else if (entry->method == SC_AC_NONE)
  ------------------
  |  |  150|     47|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (1261:12): [True: 20, False: 27]
  ------------------
 1262|     20|			smbs[nn_smb++] = 0x00;
 1263|     27|		else if (entry->method == SC_AC_CHV)
  ------------------
  |  |  151|     27|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1263:12): [True: 6, False: 21]
  ------------------
 1264|      6|			smbs[nn_smb++] = entry->key_ref | IASECC_SCB_METHOD_USER_AUTH;
  ------------------
  |  |   93|      6|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
 1265|     21|		else if (entry->method == SC_AC_SEN)
  ------------------
  |  |  156|     21|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (1265:12): [True: 1, False: 20]
  ------------------
 1266|      1|			smbs[nn_smb++] = entry->key_ref | IASECC_SCB_METHOD_USER_AUTH;
  ------------------
  |  |   93|      1|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
 1267|     20|		else if (entry->method == SC_AC_SCB)
  ------------------
  |  |  157|     20|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (1267:12): [True: 0, False: 20]
  ------------------
 1268|      0|			smbs[nn_smb++] = entry->key_ref;
 1269|     20|		else if (entry->method == SC_AC_PRO)
  ------------------
  |  |  153|     20|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (1269:12): [True: 6, False: 14]
  ------------------
 1270|      6|			smbs[nn_smb++] = entry->key_ref | IASECC_SCB_METHOD_SM;
  ------------------
  |  |   91|      6|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
 1271|     14|		else
 1272|     14|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported AC method");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1273|       |
 1274|     33|		amb |= mask;
 1275|     33|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1276|     33|		       "%"SC_FORMAT_LEN_SIZE_T"u: AMB %"SC_FORMAT_LEN_SIZE_T"X; nn_smb %"SC_FORMAT_LEN_SIZE_T"u",
 1277|     33|		       ii, amb, nn_smb);
 1278|     33|	}
 1279|       |
 1280|       |	/* TODO: Encode contactless ACLs and life cycle status for all IAS/ECC cards */
 1281|      8|	if (card->type == SC_CARD_TYPE_IASECC_SAGEM ||
  ------------------
  |  Branch (1281:6): [True: 8, False: 0]
  ------------------
 1282|      8|			card->type == SC_CARD_TYPE_IASECC_AMOS )  {
  ------------------
  |  Branch (1282:4): [True: 0, False: 0]
  ------------------
 1283|      8|		unsigned char status = 0;
 1284|       |
 1285|      8|		buf[offs++] = IASECC_FCP_TAG_ACLS;
  ------------------
  |  |   52|      8|#define IASECC_FCP_TAG_ACLS		0xA1
  ------------------
 1286|      8|		buf[offs++] = 2*(2 + 1 + nn_smb);
 1287|       |
 1288|      8|		buf[offs++] = IASECC_FCP_TAG_ACLS_CONTACT;
  ------------------
  |  |   53|      8|#define IASECC_FCP_TAG_ACLS_CONTACT	0x8C
  ------------------
 1289|      8|		buf[offs++] = nn_smb + 1;
 1290|      8|		buf[offs++] = amb;
 1291|      8|		memcpy(buf + offs, smbs, nn_smb);
 1292|      8|		offs += nn_smb;
 1293|       |
 1294|       |		/* Same ACLs for contactless */
 1295|      8|		buf[offs++] = IASECC_FCP_TAG_ACLS_CONTACTLESS;
  ------------------
  |  |   54|      8|#define IASECC_FCP_TAG_ACLS_CONTACTLESS	0x9C
  ------------------
 1296|      8|		buf[offs++] = nn_smb + 1;
 1297|      8|		buf[offs++] = amb;
 1298|      8|		memcpy(buf + offs, smbs, nn_smb);
 1299|      8|		offs += nn_smb;
 1300|       |
 1301|      8|		if (file->status == SC_FILE_STATUS_ACTIVATED)
  ------------------
  |  |  236|      8|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  |  Branch (1301:7): [True: 8, False: 0]
  ------------------
 1302|      8|			status = 0x05;
 1303|      0|		else if (file->status == SC_FILE_STATUS_CREATION)
  ------------------
  |  |  240|      0|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (1303:12): [True: 0, False: 0]
  ------------------
 1304|      0|			status = 0x01;
 1305|       |
 1306|      8|		if (status)   {
  ------------------
  |  Branch (1306:7): [True: 8, False: 0]
  ------------------
 1307|      8|			buf[offs++] = 0x8A;
 1308|      8|			buf[offs++] = 0x01;
 1309|      8|			buf[offs++] = status;
 1310|      8|		}
 1311|      8|	}
 1312|      0|	else   {
 1313|      0|		buf[offs++] = IASECC_FCP_TAG_ACLS;
  ------------------
  |  |   52|      0|#define IASECC_FCP_TAG_ACLS		0xA1
  ------------------
 1314|      0|		buf[offs++] = 2 + 1 + nn_smb;
 1315|       |
 1316|      0|		buf[offs++] = IASECC_FCP_TAG_ACLS_CONTACT;
  ------------------
  |  |   53|      0|#define IASECC_FCP_TAG_ACLS_CONTACT	0x8C
  ------------------
 1317|      0|		buf[offs++] = nn_smb + 1;
 1318|      0|		buf[offs++] = amb;
 1319|      0|		memcpy(buf + offs, smbs, nn_smb);
 1320|      0|		offs += nn_smb;
 1321|      0|	}
 1322|       |
 1323|      8|	if (out)   {
  ------------------
  |  Branch (1323:6): [True: 8, False: 0]
  ------------------
 1324|      8|		if (out_len < offs)
  ------------------
  |  Branch (1324:7): [True: 0, False: 8]
  ------------------
 1325|      8|			LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "Buffer too small to encode FCP");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1326|      8|		memcpy(out, buf, offs);
 1327|      8|	}
 1328|       |
 1329|      8|	LOG_FUNC_RETURN(ctx, (int)offs);
  ------------------
  |  |  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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1330|      8|}
card-iasecc.c:iasecc_delete_file:
 1463|     12|{
 1464|     12|	struct sc_context *ctx = card->ctx;
 1465|     12|	const struct sc_acl_entry *entry = NULL;
 1466|     12|	struct sc_apdu apdu;
 1467|     12|	struct sc_file *file = NULL;
 1468|     12|	int rv;
 1469|       |
 1470|     12|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     12|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1471|       |
 1472|     12|	rv = iasecc_select_file(card, path, &file);
 1473|     12|	if (rv == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|     12|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (1473:6): [True: 1, False: 11]
  ------------------
 1474|     12|		LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1475|     11|	LOG_TEST_RET(ctx, rv, "Cannot select file to delete");
  ------------------
  |  |  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: 3, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1476|       |
 1477|      8|	entry = sc_file_get_acl_entry(file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      8|#define SC_AC_OP_DELETE			2
  ------------------
 1478|      8|	if (!entry) {
  ------------------
  |  Branch (1478:6): [True: 3, False: 5]
  ------------------
 1479|      3|		sc_file_free(file);
 1480|      3|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "Cannot delete file: no 'DELETE' acl");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1481|      3|	}
 1482|       |
 1483|      5|	sc_log(ctx, "DELETE method/reference %X/%X", entry->method, entry->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1484|      5|	if (entry->method == SC_AC_SCB && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |  157|     10|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
              	if (entry->method == SC_AC_SCB && (entry->key_ref & IASECC_SCB_METHOD_SM))   {
  ------------------
  |  |   91|      2|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  |  Branch (1484:6): [True: 2, False: 3]
  |  Branch (1484:36): [True: 1, False: 1]
  ------------------
 1485|      1|		unsigned char se_num = entry->key_ref & IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      1|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1486|      1|		rv = iasecc_sm_delete_file(card, se_num, file->id);
 1487|      1|		sc_file_free(file);
 1488|      1|	}
 1489|      4|	else   {
 1490|      4|		struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 1491|      4|		sc_file_free(file);
 1492|      4|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE4, 0x00, 0x00);
  ------------------
  |  |  291|      4|#define SC_APDU_CASE_1			0x01
  ------------------
 1493|       |
 1494|      4|		rv = sc_transmit_apdu(card, &apdu);
 1495|      4|		LOG_TEST_RET(ctx, rv, "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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1496|      3|		rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1497|      3|		LOG_TEST_RET(ctx, rv, "Delete file 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1498|       |
 1499|      2|		if (prv->cache.valid) {
  ------------------
  |  Branch (1499:7): [True: 2, False: 0]
  ------------------
 1500|      2|			sc_file_free(prv->cache.current_ef);
 1501|      2|		}
 1502|      2|		prv->cache.current_ef = NULL;
 1503|      2|	}
 1504|       |
 1505|      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|      1|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1506|      3|}
card-iasecc.c:iasecc_check_sw:
 1511|  6.03k|{
 1512|  6.03k|	if (sw1 == 0x62 && sw2 == 0x82)
  ------------------
  |  Branch (1512:6): [True: 941, False: 5.09k]
  |  Branch (1512:21): [True: 924, False: 17]
  ------------------
 1513|    924|		return SC_SUCCESS;
  ------------------
  |  |   28|    924|#define SC_SUCCESS				0
  ------------------
 1514|       |
 1515|  5.11k|	return iso_ops->check_sw(card, sw1, sw2);
 1516|  6.03k|}
card-iasecc.c:iasecc_card_ctl:
 3001|    412|{
 3002|    412|	struct sc_context *ctx = card->ctx;
 3003|    412|	struct iasecc_sdo *sdo = (struct iasecc_sdo *) ptr;
 3004|       |
 3005|    412|	switch (cmd) {
  ------------------
  |  Branch (3005:10): [True: 182, False: 230]
  ------------------
 3006|    172|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (3006:2): [True: 172, False: 240]
  ------------------
 3007|    172|		return iasecc_get_serialnr(card, (struct sc_serial_number *)ptr);
 3008|      0|	case SC_CARDCTL_IASECC_SDO_CREATE:
  ------------------
  |  Branch (3008:2): [True: 0, False: 412]
  ------------------
 3009|      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__
  |  |  ------------------
  ------------------
 3010|      0|		return iasecc_sdo_create(card, (struct iasecc_sdo *) ptr);
 3011|      0|	case SC_CARDCTL_IASECC_SDO_DELETE:
  ------------------
  |  Branch (3011:2): [True: 0, False: 412]
  ------------------
 3012|      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__
  |  |  ------------------
  ------------------
 3013|      0|		return iasecc_sdo_delete(card, (struct iasecc_sdo *) ptr);
 3014|      0|	case SC_CARDCTL_IASECC_SDO_PUT_DATA:
  ------------------
  |  Branch (3014:2): [True: 0, False: 412]
  ------------------
 3015|      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__
  |  |  ------------------
  ------------------
 3016|      0|		return iasecc_sdo_put_data(card, (struct iasecc_sdo_update *) ptr);
 3017|      0|	case SC_CARDCTL_IASECC_SDO_KEY_RSA_PUT_DATA:
  ------------------
  |  Branch (3017:2): [True: 0, False: 412]
  ------------------
 3018|      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__
  |  |  ------------------
  ------------------
 3019|      0|		return iasecc_sdo_key_rsa_put_data(card, (struct iasecc_sdo_rsa_update *) ptr);
 3020|      3|	case SC_CARDCTL_IASECC_SDO_GET_DATA:
  ------------------
  |  Branch (3020:2): [True: 3, False: 409]
  ------------------
 3021|      3|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_SDO_GET_DATA: sdo_class %X", sdo->sdo_class);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3022|      3|		return iasecc_sdo_get_data(card, (struct iasecc_sdo *) ptr);
 3023|      0|	case SC_CARDCTL_IASECC_SDO_GENERATE:
  ------------------
  |  Branch (3023:2): [True: 0, False: 412]
  ------------------
 3024|      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__
  |  |  ------------------
  ------------------
 3025|      0|		return iasecc_sdo_generate(card, (struct iasecc_sdo *) ptr);
 3026|      0|	case SC_CARDCTL_GET_SE_INFO:
  ------------------
  |  Branch (3026:2): [True: 0, False: 412]
  ------------------
 3027|      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__
  |  |  ------------------
  ------------------
 3028|      0|		return iasecc_se_get_info(card, (struct iasecc_se_info *) ptr);
 3029|      2|	case SC_CARDCTL_GET_CHV_REFERENCE_IN_SE:
  ------------------
  |  Branch (3029:2): [True: 2, False: 410]
  ------------------
 3030|      2|		sc_log(ctx, "CMD SC_CARDCTL_GET_CHV_REFERENCE_IN_SE");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3031|      2|		return iasecc_get_chv_reference_from_se(card, (int *)ptr);
 3032|      5|	case SC_CARDCTL_IASECC_GET_FREE_KEY_REFERENCE:
  ------------------
  |  Branch (3032:2): [True: 5, False: 407]
  ------------------
 3033|      5|		sc_log(ctx, "CMD SC_CARDCTL_IASECC_GET_FREE_KEY_REFERENCE");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3034|      5|		return iasecc_get_free_reference(card, (struct iasecc_ctl_get_free_reference *)ptr);
 3035|    412|	}
 3036|    230|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    230|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 3037|    412|}
card-iasecc.c:iasecc_get_chv_reference_from_se:
 2970|      2|{
 2971|      2|	struct sc_context *ctx = card->ctx;
 2972|      2|	struct iasecc_se_info se;
 2973|      2|	struct sc_crt crt;
 2974|      2|	int rv;
 2975|       |
 2976|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2977|       |
 2978|      2|	if (!se_reference)
  ------------------
  |  Branch (2978:6): [True: 0, False: 2]
  ------------------
 2979|      2|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2980|       |
 2981|      2|	memset(&se, 0, sizeof(se));
 2982|      2|	se.reference = *se_reference;
 2983|       |
 2984|      2|	rv = iasecc_se_get_info(card, &se);
 2985|      2|	LOG_TEST_RET(ctx, rv, "get SE info 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2986|       |
 2987|      0|	memset(&crt, 0, sizeof(crt));
 2988|      0|	crt.tag = IASECC_CRT_TAG_AT;
  ------------------
  |  |  104|      0|#define IASECC_CRT_TAG_AT	0xA4
  ------------------
 2989|      0|	crt.usage = IASECC_UQB_AT_USER_PASSWORD;
  ------------------
  |  |  130|      0|#define IASECC_UQB_AT_USER_PASSWORD		0x08
  ------------------
 2990|       |
 2991|      0|	rv = iasecc_se_get_crt(card, &se, &crt);
 2992|      0|	LOG_TEST_RET(ctx, rv, "Cannot get 'USER PASSWORD' authentication template");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2993|       |
 2994|      0|	sc_file_free(se.df);
 2995|      0|	LOG_FUNC_RETURN(ctx, crt.refs[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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2996|      0|}
card-iasecc.c:iasecc_get_free_reference:
 3528|      5|{
 3529|      5|	struct sc_context *ctx = card->ctx;
 3530|      5|	struct iasecc_sdo *sdo = NULL;
 3531|      5|	int idx, rv;
 3532|       |
 3533|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3534|       |
 3535|      5|	if ((ctl_data->key_size % 0x40) || ctl_data->index < 1 || (ctl_data->index > IASECC_OBJECT_REF_MAX))
  ------------------
  |  |   63|      5|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (3535:6): [True: 0, False: 5]
  |  Branch (3535:37): [True: 0, False: 5]
  |  Branch (3535:60): [True: 0, False: 5]
  ------------------
 3536|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3537|       |
 3538|      5|	sc_log(ctx, "get reference for key(index:%i,usage:%X,access:%X)", ctl_data->index, ctl_data->usage, ctl_data->access);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3539|       |	/* TODO: when looking for the slot for the signature keys, check also PSO_SIGNATURE ACL */
 3540|      5|	for (idx = ctl_data->index; idx <= IASECC_OBJECT_REF_MAX; idx++)   {
  ------------------
  |  |   63|      5|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (3540:30): [True: 5, False: 0]
  ------------------
 3541|      5|		unsigned char sdo_tag[3] = {
 3542|      5|			IASECC_SDO_TAG_HEADER, IASECC_OBJECT_REF_LOCAL | IASECC_SDO_CLASS_RSA_PRIVATE, idx
  ------------------
  |  |   27|      5|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
              			IASECC_SDO_TAG_HEADER, IASECC_OBJECT_REF_LOCAL | IASECC_SDO_CLASS_RSA_PRIVATE, idx
  ------------------
  |  |   59|      5|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
              			IASECC_SDO_TAG_HEADER, IASECC_OBJECT_REF_LOCAL | IASECC_SDO_CLASS_RSA_PRIVATE, idx
  ------------------
  |  |  100|      5|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
 3543|      5|		};
 3544|      5|		size_t sz;
 3545|       |
 3546|      5|		if (sdo)
  ------------------
  |  Branch (3546:7): [True: 0, False: 5]
  ------------------
 3547|      0|			iasecc_sdo_free(card, sdo);
 3548|       |
 3549|      5|		rv = iasecc_sdo_allocate_and_parse(card, sdo_tag, 3, &sdo);
 3550|      5|		LOG_TEST_RET(ctx, rv, "cannot parse SDO data");
  ------------------
  |  |  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: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3551|       |
 3552|      5|		rv = iasecc_sdo_get_data(card, sdo);
 3553|      5|		if (rv == SC_ERROR_DATA_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   66|      5|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (3553:7): [True: 3, False: 2]
  ------------------
 3554|      3|			iasecc_sdo_free(card, sdo);
 3555|       |
 3556|      3|			sc_log(ctx, "found empty key slot %i", idx);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3557|      3|			break;
 3558|      3|		} else if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
  |  Branch (3558:14): [True: 2, False: 0]
  ------------------
 3559|      2|			iasecc_sdo_free(card, sdo);
 3560|       |
 3561|      2|			sc_log(ctx, "get new key reference failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3562|      2|			LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3563|      2|		}
 3564|       |
 3565|      0|		sz = *(sdo->docp.size.value + 0) * 0x100 + *(sdo->docp.size.value + 1);
 3566|      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__
  |  |  ------------------
  ------------------
 3567|      0|		       "SDO(idx:%i) size %"SC_FORMAT_LEN_SIZE_T"u; key_size %"SC_FORMAT_LEN_SIZE_T"u",
 3568|      0|		       idx, sz, ctl_data->key_size);
 3569|       |
 3570|      0|		if (sz != ctl_data->key_size / 8)   {
  ------------------
  |  Branch (3570:7): [True: 0, False: 0]
  ------------------
 3571|      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__
  |  |  ------------------
  ------------------
 3572|      0|			       "key index %i ignored: different key sizes %"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u",
 3573|      0|			       idx, sz, ctl_data->key_size / 8);
 3574|      0|			continue;
 3575|      0|		}
 3576|       |
 3577|      0|		if (sdo->docp.non_repudiation.value)   {
  ------------------
  |  Branch (3577:7): [True: 0, False: 0]
  ------------------
 3578|      0|			sc_log(ctx, "non repudiation flag %X", sdo->docp.non_repudiation.value[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__
  |  |  ------------------
  ------------------
 3579|      0|			if ((ctl_data->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION) && !(*sdo->docp.non_repudiation.value))   {
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  |  Branch (3579:8): [True: 0, False: 0]
  |  Branch (3579:68): [True: 0, False: 0]
  ------------------
 3580|      0|				sc_log(ctx, "key index %i ignored: need non repudiation", 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__
  |  |  ------------------
  ------------------
 3581|      0|				continue;
 3582|      0|			}
 3583|       |
 3584|      0|			if (!(ctl_data->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION) && *sdo->docp.non_repudiation.value)   {
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  |  Branch (3584:8): [True: 0, False: 0]
  |  Branch (3584:69): [True: 0, False: 0]
  ------------------
 3585|      0|				sc_log(ctx, "key index %i ignored: don't need non-repudiation", 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__
  |  |  ------------------
  ------------------
 3586|      0|				continue;
 3587|      0|			}
 3588|      0|		}
 3589|       |
 3590|      0|		if (ctl_data->access & SC_PKCS15_PRKEY_ACCESS_LOCAL)   {
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  |  Branch (3590:7): [True: 0, False: 0]
  ------------------
 3591|      0|			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_GENERATE] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   54|      0|#define IASECC_ACLS_RSAKEY_GENERATE		3
  ------------------
              			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_GENERATE] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   95|      0|#define IASECC_SCB_NEVER	0xFF
  ------------------
  |  Branch (3591:8): [True: 0, False: 0]
  ------------------
 3592|      0|				sc_log(ctx, "key index %i ignored: GENERATE KEY not allowed", 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__
  |  |  ------------------
  ------------------
 3593|      0|				continue;
 3594|      0|			}
 3595|      0|		}
 3596|      0|		else   {
 3597|      0|			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_PUT_DATA] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   55|      0|#define IASECC_ACLS_RSAKEY_PUT_DATA		5
  ------------------
              			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_PUT_DATA] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   95|      0|#define IASECC_SCB_NEVER	0xFF
  ------------------
  |  Branch (3597:8): [True: 0, False: 0]
  ------------------
 3598|      0|				sc_log(ctx, "key index %i ignored: PUT DATA not allowed", 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__
  |  |  ------------------
  ------------------
 3599|      0|				continue;
 3600|      0|			}
 3601|      0|		}
 3602|       |
 3603|      0|		if ((ctl_data->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION) && (ctl_data->usage & SC_PKCS15_PRKEY_USAGE_SIGN))   {
  ------------------
  |  |  314|      0|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
              		if ((ctl_data->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION) && (ctl_data->usage & SC_PKCS15_PRKEY_USAGE_SIGN))   {
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  |  Branch (3603:7): [True: 0, False: 0]
  |  Branch (3603:67): [True: 0, False: 0]
  ------------------
 3604|      0|			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_PSO_SIGN] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   51|      0|#define IASECC_ACLS_RSAKEY_PSO_SIGN		0
  ------------------
              			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_PSO_SIGN] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   95|      0|#define IASECC_SCB_NEVER	0xFF
  ------------------
  |  Branch (3604:8): [True: 0, False: 0]
  ------------------
 3605|      0|				sc_log(ctx, "key index %i ignored: PSO SIGN not allowed", 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__
  |  |  ------------------
  ------------------
 3606|      0|				continue;
 3607|      0|			}
 3608|      0|		}
 3609|      0|		else if (ctl_data->usage & SC_PKCS15_PRKEY_USAGE_SIGN)   {
  ------------------
  |  |  307|      0|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  |  Branch (3609:12): [True: 0, False: 0]
  ------------------
 3610|      0|			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_INTERNAL_AUTH] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   52|      0|#define IASECC_ACLS_RSAKEY_INTERNAL_AUTH	1
  ------------------
              			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_INTERNAL_AUTH] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   95|      0|#define IASECC_SCB_NEVER	0xFF
  ------------------
  |  Branch (3610:8): [True: 0, False: 0]
  ------------------
 3611|      0|				sc_log(ctx, "key index %i ignored: INTERNAL AUTHENTICATE not allowed", 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__
  |  |  ------------------
  ------------------
 3612|      0|				continue;
 3613|      0|			}
 3614|      0|		}
 3615|       |
 3616|      0|		if (ctl_data->usage & (SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP))   {
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
              		if (ctl_data->usage & (SC_PKCS15_PRKEY_USAGE_DECRYPT | SC_PKCS15_PRKEY_USAGE_UNWRAP))   {
  ------------------
  |  |  310|      0|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  |  Branch (3616:7): [True: 0, False: 0]
  ------------------
 3617|      0|			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_PSO_DECIPHER] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   53|      0|#define IASECC_ACLS_RSAKEY_PSO_DECIPHER		2
  ------------------
              			if (sdo->docp.scbs[IASECC_ACLS_RSAKEY_PSO_DECIPHER] == IASECC_SCB_NEVER)   {
  ------------------
  |  |   95|      0|#define IASECC_SCB_NEVER	0xFF
  ------------------
  |  Branch (3617:8): [True: 0, False: 0]
  ------------------
 3618|      0|				sc_log(ctx, "key index %i ignored: PSO DECIPHER not allowed", 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__
  |  |  ------------------
  ------------------
 3619|      0|				continue;
 3620|      0|			}
 3621|      0|		}
 3622|       |
 3623|      0|		break;
 3624|      0|	}
 3625|       |
 3626|      3|	ctl_data->index = idx;
 3627|       |
 3628|      3|	if (idx > IASECC_OBJECT_REF_MAX)
  ------------------
  |  |   63|      3|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (3628:6): [True: 0, False: 3]
  ------------------
 3629|      3|		LOG_FUNC_RETURN(ctx, SC_ERROR_DATA_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3630|       |
 3631|      3|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3632|      3|}
card-iasecc.c:iasecc_pin_cmd:
 2456|    145|{
 2457|    145|	struct sc_context *ctx = card->ctx;
 2458|    145|	int rv;
 2459|       |
 2460|    145|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    145|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    145|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    145|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    145|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 145]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2461|    145|	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|    145|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2462|    145|			data->cmd, data->pin_type, data->pin_reference,
 2463|    145|			data->pin1.data, data->pin1.len, data->pin2.data, data->pin2.len);
 2464|       |
 2465|    145|	switch (data->cmd)   {
 2466|      2|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  422|      2|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (2466:2): [True: 2, False: 143]
  ------------------
 2467|      2|		rv = iasecc_pin_verify(card, data);
 2468|      2|		break;
 2469|      0|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (2469:2): [True: 0, False: 145]
  ------------------
 2470|      0|		if (data->pin_type == SC_AC_AUT)
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (2470:7): [True: 0, False: 0]
  ------------------
 2471|      0|			rv = iasecc_keyset_change(card, data);
 2472|      0|		else
 2473|      0|			rv = iasecc_pin_change(card, data);
 2474|      0|		break;
 2475|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2475:2): [True: 0, False: 145]
  ------------------
 2476|      0|		rv = iasecc_pin_reset(card, data);
 2477|      0|		break;
 2478|    143|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  425|    143|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (2478:2): [True: 143, False: 2]
  ------------------
 2479|    143|		rv = iasecc_pin_get_info(card, data);
 2480|    143|		break;
 2481|      0|	default:
  ------------------
  |  Branch (2481:2): [True: 0, False: 145]
  ------------------
 2482|      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__
  |  |  ------------------
  ------------------
 2483|      0|		rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2484|    145|	}
 2485|       |
 2486|    145|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    145|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    145|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    145|	int _ret = r; \
  |  |  |  |  155|    145|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 145, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    145|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    145|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 145, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    145|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    145|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    145|	return _ret; \
  |  |  |  |  163|    145|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2487|    145|}
card-iasecc.c:iasecc_pin_verify:
 1948|      2|{
 1949|      2|	struct sc_context *ctx = card->ctx;
 1950|      2|	unsigned type = data->pin_type;
 1951|      2|	unsigned reference = data->pin_reference;
 1952|      2|	struct sc_pin_cmd_data pin_cmd;
 1953|      2|	struct iasecc_pin_policy policy;
 1954|      2|	int tries_before_verify = -1;
 1955|      2|	int rv;
 1956|       |
 1957|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1958|      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__
  |  |  ------------------
  ------------------
 1959|      2|	       "Verify PIN(type:%X,ref:%i,data(len:%zu,%p)",
 1960|      2|	       type, reference, data->pin1.len, data->pin1.data);
 1961|       |
 1962|      2|	if (type == SC_AC_AUT)   {
  ------------------
  |  |  154|      2|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (1962:6): [True: 0, False: 2]
  ------------------
 1963|      0|		rv =  iasecc_sm_external_authentication(card, reference, &data->pin1.tries_left);
 1964|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1965|      0|	}
 1966|       |
 1967|      2|	if (type == SC_AC_SCB)   {
  ------------------
  |  |  157|      2|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (1967:6): [True: 2, False: 0]
  ------------------
 1968|      2|		if (reference & IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   93|      2|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
  |  Branch (1968:7): [True: 1, False: 1]
  ------------------
 1969|      1|			type = SC_AC_SEN;
  ------------------
  |  |  156|      1|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
 1970|      1|			reference = reference & IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      1|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
 1971|      1|		}
 1972|      2|	}
 1973|       |
 1974|      2|	if (type == SC_AC_SEN)   {
  ------------------
  |  |  156|      2|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (1974:6): [True: 1, False: 1]
  ------------------
 1975|      1|		type = SC_AC_CHV;
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1976|      1|		rv = iasecc_se_at_to_chv_reference(card, reference,  &reference);
 1977|      1|		LOG_TEST_RET(ctx, rv, "SE AT to CHV reference 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1978|      1|	}
 1979|       |
 1980|      1|	if (type != SC_AC_CHV)   {
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1980:6): [True: 1, False: 0]
  ------------------
 1981|      1|		sc_log(ctx, "Do not try to verify non CHV PINs");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1982|      1|		LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1983|      1|	}
 1984|       |
 1985|      0|	pin_cmd = *data;
 1986|      0|	pin_cmd.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1987|      0|	pin_cmd.pin_reference = reference;
 1988|      0|	pin_cmd.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  422|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
 1989|       |
 1990|      0|	rv = iasecc_pin_get_status(card, &pin_cmd);
 1991|      0|	if (data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1991:6): [True: 0, False: 0]
  |  Branch (1991:25): [True: 0, False: 0]
  ------------------
 1992|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1993|       |
 1994|      0|	if (!rv)   {
  ------------------
  |  Branch (1994:6): [True: 0, False: 0]
  ------------------
 1995|      0|		if (pin_cmd.pin1.logged_in & SC_PIN_STATE_LOGGED_IN)
  ------------------
  |  |  439|      0|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
  |  Branch (1995:7): [True: 0, False: 0]
  ------------------
 1996|      0|			if (iasecc_chv_cache_is_verified(card, &pin_cmd))
  ------------------
  |  Branch (1996:8): [True: 0, False: 0]
  ------------------
 1997|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1998|      0|	}
 1999|      0|	else if (rv != SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)   {
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (1999:11): [True: 0, False: 0]
  ------------------
 2000|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2001|      0|	}
 2002|       |
 2003|      0|	iasecc_chv_cache_clean(card, &pin_cmd);
 2004|       |
 2005|      0|	rv = iasecc_pin_merge_policy(card, &pin_cmd, &pin_cmd.pin1, &policy);
 2006|      0|	LOG_TEST_RET(ctx, rv, "Failed to update PIN1 info");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2007|       |
 2008|       |	/* PIN-pads work best with fixed-size lengths. Use PIN padding when length is available. */
 2009|      0|	if (pin_cmd.flags & SC_PIN_CMD_USE_PINPAD) {
  ------------------
  |  |  428|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (2009:6): [True: 0, False: 0]
  ------------------
 2010|      0|		tries_before_verify = pin_cmd.pin1.tries_left;
 2011|      0|		if (policy.stored_length > 0)
  ------------------
  |  Branch (2011:7): [True: 0, False: 0]
  ------------------
 2012|      0|			iasecc_set_pin_padding(&pin_cmd, &pin_cmd.pin1, policy.stored_length);
 2013|      0|	}
 2014|       |
 2015|      0|	rv = iasecc_chv_verify(card, &pin_cmd, policy.scbs);
 2016|       |
 2017|       |	/*
 2018|       |	 * Detect and log PIN-pads which don't handle variable-length PIN - special case where they
 2019|       |	 * forward the CHV verify command with Lc = 0 to the card, without updating Lc. An IAS-ECC
 2020|       |	 * card responds to this command by returning the number of attempts left, without
 2021|       |	 * decreasing the counter.
 2022|       |	 */
 2023|      0|	if ((pin_cmd.flags & SC_PIN_CMD_USE_PINPAD) && !(pin_cmd.flags & SC_PIN_CMD_NEED_PADDING)) {
  ------------------
  |  |  428|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
              	if ((pin_cmd.flags & SC_PIN_CMD_USE_PINPAD) && !(pin_cmd.flags & SC_PIN_CMD_NEED_PADDING)) {
  ------------------
  |  |  429|      0|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  |  Branch (2023:6): [True: 0, False: 0]
  |  Branch (2023:49): [True: 0, False: 0]
  ------------------
 2024|      0|		if (rv == SC_ERROR_PIN_CODE_INCORRECT && pin_cmd.pin1.tries_left == tries_before_verify) {
  ------------------
  |  |   64|      0|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (2024:7): [True: 0, False: 0]
  |  Branch (2024:44): [True: 0, False: 0]
  ------------------
 2025|      0|			SC_TEST_RET(ctx, SC_LOG_DEBUG_VERBOSE, rv,
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 2026|      0|				    "PIN-pad reader does not support variable-length PIN");
 2027|      0|		}
 2028|      0|	}
 2029|       |
 2030|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2031|       |
 2032|      0|	rv = iasecc_chv_cache_verified(card, &pin_cmd);
 2033|       |
 2034|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2035|      0|}
card-iasecc.c:iasecc_se_at_to_chv_reference:
 1884|      1|{
 1885|      1|	struct sc_context *ctx = card->ctx;
 1886|      1|	struct iasecc_se_info se;
 1887|      1|	struct sc_crt crt;
 1888|      1|	int rv;
 1889|       |
 1890|      1|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1891|      1|	sc_log(ctx, "SE reference %i", reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1892|       |
 1893|      1|	if (reference > IASECC_SE_REF_MAX)
  ------------------
  |  |   66|      1|#define IASECC_SE_REF_MAX	0x0F
  ------------------
  |  Branch (1893:6): [True: 0, False: 1]
  ------------------
 1894|      1|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1895|       |
 1896|      1|	memset(&se, 0, sizeof(se));
 1897|      1|	se.reference = reference;
 1898|       |
 1899|      1|	rv = iasecc_se_get_info(card, &se);
 1900|      1|	LOG_TEST_RET(ctx, rv, "SDO get data 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1901|       |
 1902|      0|	memset(&crt, 0, sizeof(crt));
 1903|      0|	crt.tag = IASECC_CRT_TAG_AT;
  ------------------
  |  |  104|      0|#define IASECC_CRT_TAG_AT	0xA4
  ------------------
 1904|      0|	crt.usage = IASECC_UQB_AT_USER_PASSWORD;
  ------------------
  |  |  130|      0|#define IASECC_UQB_AT_USER_PASSWORD		0x08
  ------------------
 1905|       |
 1906|      0|	rv = iasecc_se_get_crt(card, &se, &crt);
 1907|      0|	LOG_TEST_RET(ctx, rv, "no authentication template for USER PASSWORD");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1908|       |
 1909|      0|	if (chv_reference)
  ------------------
  |  Branch (1909:6): [True: 0, False: 0]
  ------------------
 1910|      0|		*chv_reference = crt.refs[0];
 1911|       |
 1912|      0|	sc_file_free(se.df);
 1913|       |
 1914|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1915|      0|}
card-iasecc.c:iasecc_pin_get_status:
 1920|    143|{
 1921|    143|	struct sc_context *ctx = card->ctx;
 1922|    143|	struct sc_pin_cmd_data info;
 1923|    143|	int rv;
 1924|       |
 1925|    143|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1926|       |
 1927|    143|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|    143|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1927:6): [True: 0, False: 143]
  ------------------
 1928|    143|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1929|       |
 1930|    143|	memset(&info, 0, sizeof(info));
 1931|    143|	info.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  425|    143|#define SC_PIN_CMD_GET_INFO	3
  ------------------
 1932|    143|	info.pin_type = data->pin_type;
 1933|    143|	info.pin_reference = data->pin_reference;
 1934|       |
 1935|    143|	rv = iso_ops->pin_cmd(card, &info);
 1936|    143|	LOG_TEST_RET(ctx, rv, "Failed to get PIN info");
  ------------------
  |  |  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: 15, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  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|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 128]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1937|       |
 1938|    128|	data->pin1.max_tries = info.pin1.max_tries;
 1939|    128|	data->pin1.tries_left = info.pin1.tries_left;
 1940|    128|	data->pin1.logged_in = info.pin1.logged_in;
 1941|       |
 1942|    128|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    128|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    128|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    128|	int _ret = r; \
  |  |  |  |  155|    128|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 128, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    128|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  157|    128|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    128|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    128|	return _ret; \
  |  |  |  |  163|    128|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1943|    128|}
card-iasecc.c:iasecc_pin_get_policy:
 2040|    128|{
 2041|    128|	struct iasecc_private_data *prv = (struct iasecc_private_data *)card->drv_data;
 2042|    128|	struct sc_context *ctx = card->ctx;
 2043|    128|	struct sc_file *save_current_df = NULL, *save_current_ef = NULL;
 2044|    128|	struct iasecc_sdo sdo;
 2045|    128|	struct sc_path path;
 2046|    128|	int rv;
 2047|       |
 2048|    128|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    128|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    128|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    128|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    128|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 128]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2049|    128|	sc_log(ctx, "iasecc_pin_get_policy(card:%p)", card);
  ------------------
  |  |   71|    128|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2050|       |
 2051|    128|	if (data->pin_type != SC_AC_CHV)   {
  ------------------
  |  |  151|    128|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (2051:6): [True: 0, False: 128]
  ------------------
 2052|      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__
  |  |  ------------------
  ------------------
 2053|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2054|      0|	}
 2055|       |
 2056|    128|	if (prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  Branch (2056:6): [True: 128, False: 0]
  |  Branch (2056:26): [True: 12, False: 116]
  ------------------
 2057|     12|		sc_file_dup(&save_current_df, prv->cache.current_df);
 2058|     12|		if (save_current_df == NULL) {
  ------------------
  |  Branch (2058:7): [True: 0, False: 12]
  ------------------
 2059|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2060|      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__
  |  |  ------------------
  ------------------
 2061|      0|			goto err;
 2062|      0|		}
 2063|     12|	}
 2064|       |
 2065|    128|	if (prv->cache.valid && prv->cache.current_ef) {
  ------------------
  |  Branch (2065:6): [True: 128, False: 0]
  |  Branch (2065:26): [True: 3, False: 125]
  ------------------
 2066|      3|		sc_file_dup(&save_current_ef, prv->cache.current_ef);
 2067|      3|		if (save_current_ef == NULL) {
  ------------------
  |  Branch (2067:7): [True: 0, False: 3]
  ------------------
 2068|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2069|      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__
  |  |  ------------------
  ------------------
 2070|      0|			goto err;
 2071|      0|		}
 2072|      3|	}
 2073|       |
 2074|    128|	if (!(data->pin_reference & IASECC_OBJECT_REF_LOCAL) && prv->cache.valid && prv->cache.current_df) {
  ------------------
  |  |   59|    128|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  |  Branch (2074:6): [True: 128, False: 0]
  |  Branch (2074:58): [True: 128, False: 0]
  |  Branch (2074:78): [True: 12, False: 116]
  ------------------
 2075|     12|		sc_format_path("3F00", &path);
 2076|     12|		path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     12|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 2077|     12|		rv = iasecc_select_file(card, &path, NULL);
 2078|     12|		LOG_TEST_GOTO_ERR(ctx, rv, "Unable to select MF");
  ------------------
  |  |  184|     12|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     12|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     12|	int _ret = (r); \
  |  |  |  |  178|     12|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 4, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2079|     12|	}
 2080|       |
 2081|    124|	memset(&sdo, 0, sizeof(sdo));
 2082|    124|	sdo.sdo_class = IASECC_SDO_CLASS_CHV;
  ------------------
  |  |   98|    124|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
 2083|       |
 2084|    124|	sdo.sdo_ref = data->pin_reference & ~IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|    124|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
 2085|       |
 2086|    124|	sc_log(ctx, "iasecc_pin_get_policy() reference %i", sdo.sdo_ref);
  ------------------
  |  |   71|    124|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2087|       |
 2088|    124|	rv = iasecc_sdo_get_data(card, &sdo);
 2089|    124|	LOG_TEST_GOTO_ERR(ctx, rv, "Cannot get SDO PIN data");
  ------------------
  |  |  184|    124|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    124|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    124|	int _ret = (r); \
  |  |  |  |  178|    124|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 124, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    124|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    124|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    124|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    124|		goto err; \
  |  |  |  |  182|    124|	} \
  |  |  |  |  183|    124|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2090|       |
 2091|      0|	if (sdo.docp.acls_contact.size == 0) {
  ------------------
  |  Branch (2091:6): [True: 0, False: 0]
  ------------------
 2092|      0|		rv = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2093|      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__
  |  |  ------------------
  ------------------
 2094|      0|		goto err;
 2095|      0|	}
 2096|       |
 2097|      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__
  |  |  ------------------
  ------------------
 2098|      0|	       "iasecc_pin_get_policy() sdo.docp.size.size %"SC_FORMAT_LEN_SIZE_T"u",
 2099|      0|	       sdo.docp.size.size);
 2100|       |
 2101|      0|	memcpy(pin->scbs, sdo.docp.scbs, sizeof(pin->scbs));
 2102|       |
 2103|      0|	pin->min_length = (sdo.data.chv.size_min.value ? *sdo.data.chv.size_min.value : -1);
  ------------------
  |  Branch (2103:21): [True: 0, False: 0]
  ------------------
 2104|      0|	pin->max_length = (sdo.data.chv.size_max.value ? *sdo.data.chv.size_max.value : -1);
  ------------------
  |  Branch (2104:21): [True: 0, False: 0]
  ------------------
 2105|      0|	pin->tries_maximum = (sdo.docp.tries_maximum.value ? *sdo.docp.tries_maximum.value : -1);
  ------------------
  |  Branch (2105:24): [True: 0, False: 0]
  ------------------
 2106|      0|	pin->tries_remaining = (sdo.docp.tries_remaining.value ? *sdo.docp.tries_remaining.value : -1);
  ------------------
  |  Branch (2106:26): [True: 0, False: 0]
  ------------------
 2107|      0|	if (sdo.docp.size.value && sdo.docp.size.size <= sizeof(int)) {
  ------------------
  |  Branch (2107:6): [True: 0, False: 0]
  |  Branch (2107:29): [True: 0, False: 0]
  ------------------
 2108|      0|		unsigned int n = 0;
 2109|      0|		unsigned int i;
 2110|      0|		for (i=0; i<sdo.docp.size.size; i++)
  ------------------
  |  Branch (2110:13): [True: 0, False: 0]
  ------------------
 2111|      0|			n = (n << 8) + *(sdo.docp.size.value + i);
 2112|      0|		pin->stored_length = n;
 2113|      0|	} else {
 2114|      0|		pin->stored_length = -1;
 2115|      0|	}
 2116|       |
 2117|      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__
  |  |  ------------------
  ------------------
 2118|      0|	       pin->max_length, pin->min_length, pin->tries_maximum, pin->tries_remaining);
 2119|      0|	iasecc_sdo_free_fields(card, &sdo);
 2120|       |
 2121|      0|	if (save_current_df)   {
  ------------------
  |  Branch (2121:6): [True: 0, False: 0]
  ------------------
 2122|      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__
  |  |  ------------------
  ------------------
 2123|      0|		rv = iasecc_select_file(card, &save_current_df->path, NULL);
 2124|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2125|      0|	}
 2126|       |
 2127|      0|	if (save_current_ef)   {
  ------------------
  |  Branch (2127:6): [True: 0, False: 0]
  ------------------
 2128|      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__
  |  |  ------------------
  ------------------
 2129|      0|		rv = iasecc_select_file(card, &save_current_ef->path, NULL);
 2130|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2131|      0|	}
 2132|       |
 2133|    128|err:
 2134|    128|	sc_file_free(save_current_df);
 2135|    128|	sc_file_free(save_current_ef);
 2136|       |
 2137|    128|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    128|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    128|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    128|	int _ret = r; \
  |  |  |  |  155|    128|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 128, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    128|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    128|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 128, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    128|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    128|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    128|	return _ret; \
  |  |  |  |  163|    128|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2138|    128|}
card-iasecc.c:iasecc_pin_get_info:
 2143|    143|{
 2144|    143|	struct sc_context *ctx = card->ctx;
 2145|    143|	struct iasecc_pin_policy policy;
 2146|    143|	int rv;
 2147|       |
 2148|    143|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2149|    143|	sc_log(ctx, "iasecc_pin_get_info(card:%p)", card);
  ------------------
  |  |   71|    143|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2150|       |
 2151|       |	/*
 2152|       |	 * Get PIN status first and thereafter update with info from PIN policy, when available.
 2153|       |	 * The first one is typically used for the PIN verification status and number of remaining
 2154|       |	 * tries, and the second one for the maximum tries. If a field is present in both, the
 2155|       |	 * policy takes precedence.
 2156|       |	 */
 2157|    143|	rv = iasecc_pin_get_status(card, data);
 2158|    143|	LOG_TEST_RET(ctx, rv, "Failed to get PIN status");
  ------------------
  |  |  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: 15, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  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|    143|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 128]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2159|       |
 2160|    128|	rv = iasecc_pin_get_policy(card, data, &policy);
 2161|    128|	LOG_TEST_RET(ctx, rv, "Failed to get PIN policy");
  ------------------
  |  |  174|    128|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    128|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    128|	int _ret = (r); \
  |  |  |  |  168|    128|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 128, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    128|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    128|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    128|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    128|		return _ret; \
  |  |  |  |  172|    128|	} \
  |  |  |  |  173|    128|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2162|       |
 2163|       |	/*
 2164|       |	 * We only care about the tries_xxx fields in the PIN policy, since the other ones are not
 2165|       |	 * commonly expected or used in a SC_PIN_CMD_GET_INFO response.	Note that max_tries is
 2166|       |	 * always taken from the policy, since it is never expected to be available in status (it
 2167|       |	 * is set to -1 when not available in policy).
 2168|       |	 */
 2169|      0|	data->pin1.max_tries = policy.tries_maximum;
 2170|      0|	if (policy.tries_remaining >= 0)
  ------------------
  |  Branch (2170:6): [True: 0, False: 0]
  ------------------
 2171|      0|		data->pin1.tries_left = policy.tries_remaining;
 2172|       |
 2173|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2174|      0|}

idprime_free_private_data:
  225|     90|{
  226|     90|	free(priv->cache_buf);
  227|     90|	list_destroy(&priv->pki_list);
  228|     90|	list_destroy(&priv->containers);
  229|     90|	list_destroy(&priv->keyrefmap);
  230|     90|	free(priv);
  231|     90|	return;
  232|     90|}
idprime_new_private_data:
  235|     90|{
  236|     90|	idprime_private_data_t *priv;
  237|       |
  238|     90|	priv = calloc(1, sizeof(idprime_private_data_t));
  239|     90|	if (priv == NULL)
  ------------------
  |  Branch (239:6): [True: 0, False: 90]
  ------------------
  240|      0|		return NULL;
  241|       |
  242|       |	/* Initialize PKI Applets list */
  243|     90|	if (list_init(&priv->pki_list) != 0 ||
  ------------------
  |  Branch (243:6): [True: 0, False: 90]
  ------------------
  244|     90|	    list_attributes_copy(&priv->pki_list, idprime_list_meter, 1) != 0) {
  ------------------
  |  Branch (244:6): [True: 0, False: 90]
  ------------------
  245|      0|		idprime_free_private_data(priv);
  246|      0|		return NULL;
  247|      0|	}
  248|       |
  249|       |	/* Initialize container list */
  250|     90|	if (list_init(&priv->containers) != 0 ||
  ------------------
  |  Branch (250:6): [True: 0, False: 90]
  ------------------
  251|     90|	    list_attributes_copy(&priv->containers, idprime_container_list_meter, 1) != 0 ||
  ------------------
  |  Branch (251:6): [True: 0, False: 90]
  ------------------
  252|     90|	    list_attributes_seeker(&priv->containers, idprime_container_list_seeker) != 0) {
  ------------------
  |  Branch (252:6): [True: 0, False: 90]
  ------------------
  253|      0|		idprime_free_private_data(priv);
  254|      0|		return NULL;
  255|      0|	}
  256|       |
  257|       |	/* Initialize keyref list */
  258|     90|	if (list_init(&priv->keyrefmap) != 0 ||
  ------------------
  |  Branch (258:6): [True: 0, False: 90]
  ------------------
  259|     90|	    list_attributes_copy(&priv->keyrefmap, idprime_keyref_list_meter, 1) != 0 ||
  ------------------
  |  Branch (259:6): [True: 0, False: 90]
  ------------------
  260|     90|	    list_attributes_seeker(&priv->keyrefmap, idprime_keyref_list_seeker) != 0) {
  ------------------
  |  Branch (260:6): [True: 0, False: 90]
  ------------------
  261|      0|		idprime_free_private_data(priv);
  262|      0|		return NULL;
  263|      0|	}
  264|     90|	return priv;
  265|     90|}
idprime_add_object_to_list:
  268|     90|{
  269|     90|	if (list_append(list, object) < 0)
  ------------------
  |  Branch (269:6): [True: 0, False: 90]
  ------------------
  270|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  271|     90|	return SC_SUCCESS;
  ------------------
  |  |   28|     90|#define SC_SUCCESS				0
  ------------------
  272|     90|}
sc_get_idprime_driver:
 1279|  3.69k|{
 1280|  3.69k|	return sc_get_driver();
 1281|  3.69k|}
card-idprime.c:idprime_list_meter:
  176|     90|static size_t idprime_list_meter(const void *el) {
  177|     90|	return sizeof(idprime_object_t);
  178|     90|}
card-idprime.c:idprime_container_list_meter:
  180|     25|static size_t idprime_container_list_meter(const void *el) {
  181|     25|	return sizeof(idprime_container_t);
  182|     25|}
card-idprime.c:idprime_keyref_list_meter:
  184|  54.6k|static size_t idprime_keyref_list_meter(const void *el) {
  185|  54.6k|	return sizeof(idprime_keyref_t);
  186|  54.6k|}
card-idprime.c:idprime_keyref_list_seeker:
  214|  56.3k|{
  215|  56.3k|	const idprime_keyref_t *keyref = (idprime_keyref_t *)el;
  216|       |
  217|  56.3k|	if ((el == NULL) || (key == NULL))
  ------------------
  |  Branch (217:6): [True: 0, False: 56.3k]
  |  Branch (217:22): [True: 0, False: 56.3k]
  ------------------
  218|      0|		return 0;
  219|  56.3k|	if (keyref->index == *(uint8_t *)key)
  ------------------
  |  Branch (219:6): [True: 11, False: 56.3k]
  ------------------
  220|     11|		return 1;
  221|  56.3k|	return 0;
  222|  56.3k|}
card-idprime.c:sc_get_driver:
 1256|  3.69k|{
 1257|  3.69k|	if (iso_ops == NULL) {
  ------------------
  |  Branch (1257:6): [True: 1, False: 3.69k]
  ------------------
 1258|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 1259|      1|	}
 1260|       |
 1261|  3.69k|	idprime_ops = *iso_ops;
 1262|  3.69k|	idprime_ops.match_card = idprime_match_card;
 1263|  3.69k|	idprime_ops.init = idprime_init;
 1264|  3.69k|	idprime_ops.finish = idprime_finish;
 1265|       |
 1266|  3.69k|	idprime_ops.read_binary = idprime_read_binary;
 1267|  3.69k|	idprime_ops.select_file = idprime_select_file;
 1268|  3.69k|	idprime_ops.card_ctl = idprime_card_ctl;
 1269|  3.69k|	idprime_ops.set_security_env = idprime_set_security_env;
 1270|  3.69k|	idprime_ops.compute_signature = idprime_compute_signature;
 1271|  3.69k|	idprime_ops.decipher = idprime_decipher;
 1272|       |
 1273|  3.69k|	idprime_ops.get_challenge = idprime_get_challenge;
 1274|       |
 1275|  3.69k|	return &idprime_drv;
 1276|  3.69k|}
card-idprime.c:idprime_match_card:
  750|  1.44k|{
  751|  1.44k|	int i, r;
  752|       |
  753|  1.44k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.44k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.44k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.44k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.44k]
  |  |  ------------------
  ------------------
  754|  1.44k|	i = _sc_match_atr(card, idprime_atrs, &card->type);
  755|  1.44k|	if (i < 0)
  ------------------
  |  Branch (755:6): [True: 1.35k, False: 91]
  ------------------
  756|  1.35k|		return 0;
  757|       |
  758|     91|	r = idprime_select_file_by_path(card, "0101");
  759|     91|	LOG_FUNC_RETURN(card->ctx, r > 0);
  ------------------
  |  |  164|     91|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     91|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     91|	int _ret = r; \
  |  |  |  |  155|     91|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1, False: 90]
  |  |  |  |  ------------------
  |  |  |  |  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|     90|	} else { \
  |  |  |  |  159|     90|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     90|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     90|	} \
  |  |  |  |  162|     91|	return _ret; \
  |  |  |  |  163|     91|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  760|     91|}
card-idprime.c:idprime_select_file_by_path:
  283|    297|{
  284|    297|	int r;
  285|    297|	sc_file_t *file = NULL;
  286|    297|	sc_path_t index_path;
  287|       |
  288|       |	/* First, we need to make sure the IDPrime AID is selected */
  289|    297|	r = idprime_select_idprime(card);
  290|    297|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    297|#define SC_SUCCESS				0
  ------------------
  |  Branch (290:6): [True: 20, False: 277]
  ------------------
  291|     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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  292|     20|	}
  293|       |
  294|       |	/* Returns FCI with expected length of data */
  295|    277|	sc_format_path(str_path, &index_path);
  296|    277|	r = iso_ops->select_file(card, &index_path, &file);
  297|       |
  298|    277|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    277|#define SC_SUCCESS				0
  ------------------
  |  Branch (298:6): [True: 1, False: 276]
  ------------------
  299|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  300|      1|	}
  301|       |	/* Ignore too large files */
  302|    276|	if (file->size > MAX_FILE_SIZE) {
  ------------------
  |  |  229|    276|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (302:6): [True: 0, False: 276]
  ------------------
  303|      0|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  304|    276|	} else {
  305|    276|		r = (int)file->size;
  306|    276|	}
  307|    276|	sc_file_free(file);
  308|    276|	LOG_FUNC_RETURN(card->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: 0, False: 276]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    276|	} else { \
  |  |  |  |  159|    276|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    276|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    276|	} \
  |  |  |  |  162|    276|	return _ret; \
  |  |  |  |  163|    276|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  309|    276|}
card-idprime.c:idprime_select_idprime:
  277|    297|{
  278|       |	return iso_ops->select_file(card, &idprime_path, NULL);
  279|    297|}
card-idprime.c:idprime_init:
  560|     90|{
  561|     90|	int r;
  562|     90|	unsigned long flags, ext_flags;
  563|     90|	idprime_private_data_t *priv = NULL;
  564|     90|	struct sc_apdu apdu;
  565|     90|	u8 rbuf[CPLC_LENGTH];
  566|     90|	size_t rbuflen = sizeof(rbuf);
  567|       |
  568|     90|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  569|       |
  570|       |	/* We need to differentiate the OS version since they behave slightly differently */
  571|     90|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, 0x9F, 0x7F);
  ------------------
  |  |  301|     90|#define SC_APDU_CASE_2			0x22
  ------------------
  572|     90|	apdu.resp = rbuf;
  573|     90|	apdu.resplen = rbuflen;
  574|     90|	apdu.le = rbuflen;
  575|     90|	r = sc_transmit_apdu(card, &apdu);
  576|     90|	if (r == SC_SUCCESS && apdu.resplen == CPLC_LENGTH) {
  ------------------
  |  |   28|    180|#define SC_SUCCESS				0
  ------------------
              	if (r == SC_SUCCESS && apdu.resplen == CPLC_LENGTH) {
  ------------------
  |  |  558|     90|#define CPLC_LENGTH 45
  ------------------
  |  Branch (576:6): [True: 90, False: 0]
  |  Branch (576:25): [True: 0, False: 90]
  ------------------
  577|       |		/* We are interested in the OS release level here */
  578|      0|		switch (rbuf[11]) {
  579|      0|		case 0x01:
  ------------------
  |  Branch (579:3): [True: 0, False: 0]
  ------------------
  580|      0|			sc_log(card->ctx, "Detected IDPrime applet version 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__
  |  |  ------------------
  ------------------
  581|      0|			break;
  582|      0|		case 0x02:
  ------------------
  |  Branch (582:3): [True: 0, False: 0]
  ------------------
  583|      0|			sc_log(card->ctx, "Detected IDPrime applet version 2");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  584|      0|			break;
  585|      0|		case 0x03:
  ------------------
  |  Branch (585:3): [True: 0, False: 0]
  ------------------
  586|      0|			sc_log(card->ctx, "Detected IDPrime applet version 3");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  587|      0|			break;
  588|      0|		case 0x04:
  ------------------
  |  Branch (588:3): [True: 0, False: 0]
  ------------------
  589|      0|			sc_log(card->ctx, "Detected IDPrime applet version 4");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  590|      0|			break;
  591|      0|		default:
  ------------------
  |  Branch (591:3): [True: 0, False: 0]
  ------------------
  592|      0|			sc_log(card->ctx, "Unknown OS version received: %d", rbuf[11]);
  ------------------
  |  |   71|      0|#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|      0|			break;
  594|      0|		}
  595|     90|	} else {
  596|     90|		sc_log(card->ctx, "Failed to get CPLC data or invalid length returned, "
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  597|     90|			"err=%d, len=%"SC_FORMAT_LEN_SIZE_T"u",
  598|     90|			r, apdu.resplen);
  599|     90|	}
  600|       |
  601|       |	/* Proprietary data -- Applet version */
  602|     90|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, 0xDF, 0x30);
  ------------------
  |  |  301|     90|#define SC_APDU_CASE_2			0x22
  ------------------
  603|     90|	apdu.resp = rbuf;
  604|     90|	apdu.resplen = rbuflen;
  605|     90|	apdu.le = rbuflen;
  606|     90|	r = sc_transmit_apdu(card, &apdu);
  607|     90|	if (r == SC_SUCCESS && apdu.resplen >= 10) {
  ------------------
  |  |   28|    180|#define SC_SUCCESS				0
  ------------------
  |  Branch (607:6): [True: 90, False: 0]
  |  Branch (607:25): [True: 0, False: 90]
  ------------------
  608|       |		/* Ber-TLV encoded */
  609|      0|		if (rbuf[0] == 0xDF && rbuf[1] == 0x30 && rbuf[2] == apdu.resplen - 3) {
  ------------------
  |  Branch (609:7): [True: 0, False: 0]
  |  Branch (609:26): [True: 0, False: 0]
  |  Branch (609:45): [True: 0, False: 0]
  ------------------
  610|      0|			sc_log(card->ctx, "IDPrime Java Applet version %.*s", (int)apdu.resplen - 3, rbuf + 3);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  611|      0|		}
  612|      0|	}
  613|       |
  614|     90|	priv = idprime_new_private_data();
  615|     90|	if (!priv) {
  ------------------
  |  Branch (615:6): [True: 0, False: 90]
  ------------------
  616|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|      0|	}
  618|       |
  619|       |	/* Select and process container file */
  620|     90|	r = idprime_select_file_by_path(card, "0204");;
  621|     90|	if (r <= 0) {
  ------------------
  |  Branch (621:6): [True: 0, False: 90]
  ------------------
  622|      0|		idprime_free_private_data(priv);
  623|      0|		if (r == 0)
  ------------------
  |  Branch (623:7): [True: 0, False: 0]
  ------------------
  624|      0|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  625|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  626|      0|	}
  627|       |
  628|     90|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Container file found");
  ------------------
  |  |   70|     90|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  629|       |
  630|     90|	r = idprime_process_containermap(card, priv, r);
  631|     90|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     90|#define SC_SUCCESS				0
  ------------------
  |  Branch (631:6): [True: 5, False: 85]
  ------------------
  632|      5|		idprime_free_private_data(priv);
  633|      5|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  634|      5|	}
  635|       |
  636|     85|	if (card->type == SC_CARD_TYPE_IDPRIME_940) {
  ------------------
  |  Branch (636:6): [True: 38, False: 47]
  ------------------
  637|     38|		if ((r = idprime_select_file_by_path(card, "0005")) <= 0) {
  ------------------
  |  Branch (637:7): [True: 0, False: 38]
  ------------------
  638|      0|			idprime_free_private_data(priv);
  639|      0|			if (r == 0)
  ------------------
  |  Branch (639:8): [True: 0, False: 0]
  ------------------
  640|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  641|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  642|      0|		}
  643|       |
  644|     38|		if ((r = idprime_process_keyrefmap(card, priv, r)) != SC_SUCCESS) {
  ------------------
  |  |   28|     38|#define SC_SUCCESS				0
  ------------------
  |  Branch (644:7): [True: 7, False: 31]
  ------------------
  645|      7|			idprime_free_private_data(priv);
  646|      7|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  647|      7|		}
  648|     38|	}
  649|       |
  650|       |	/* Select and process the index file */
  651|     78|	r = idprime_select_file_by_path(card, "0101");
  652|     78|	if (r <= 0) {
  ------------------
  |  Branch (652:6): [True: 20, False: 58]
  ------------------
  653|     20|		idprime_free_private_data(priv);
  654|     20|		if (r == 0)
  ------------------
  |  Branch (654:7): [True: 0, False: 20]
  ------------------
  655|      0|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  656|     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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  657|     20|	}
  658|       |
  659|     58|	sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Index file found");
  ------------------
  |  |   70|     58|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  660|       |
  661|     58|	r = idprime_process_index(card, priv, r);
  662|     58|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     58|#define SC_SUCCESS				0
  ------------------
  |  Branch (662:6): [True: 3, False: 55]
  ------------------
  663|      3|		idprime_free_private_data(priv);
  664|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  665|      3|	}
  666|       |
  667|     55|	card->drv_data = priv;
  668|       |
  669|     55|	switch (card->type) {
  670|      0|	case SC_CARD_TYPE_IDPRIME_3810:
  ------------------
  |  Branch (670:2): [True: 0, False: 55]
  ------------------
  671|      0|		card->name = "Gemalto IDPrime 3810";
  672|      0|		break;
  673|      0|	case SC_CARD_TYPE_IDPRIME_830:
  ------------------
  |  Branch (673:2): [True: 0, False: 55]
  ------------------
  674|      0|		card->name = "Gemalto IDPrime MD 830";
  675|      0|		break;
  676|      0|	case SC_CARD_TYPE_IDPRIME_930:
  ------------------
  |  Branch (676:2): [True: 0, False: 55]
  ------------------
  677|      0|	case SC_CARD_TYPE_IDPRIME_930_PLUS:
  ------------------
  |  Branch (677:2): [True: 0, False: 55]
  ------------------
  678|      0|		card->name = "Gemalto IDPrime 930/3930";
  679|      0|		break;
  680|     16|	case SC_CARD_TYPE_IDPRIME_940:
  ------------------
  |  Branch (680:2): [True: 16, False: 39]
  ------------------
  681|     16|		card->name = "Gemalto IDPrime 940";
  682|     16|		break;
  683|      1|	case SC_CARD_TYPE_IDPRIME_840:
  ------------------
  |  Branch (683:2): [True: 1, False: 54]
  ------------------
  684|      1|		card->name = "Gemalto IDPrime MD 840";
  685|      1|		break;
  686|     38|	case SC_CARD_TYPE_IDPRIME_GENERIC:
  ------------------
  |  Branch (686:2): [True: 38, False: 17]
  ------------------
  687|     38|	default:
  ------------------
  |  Branch (687:2): [True: 0, False: 55]
  ------------------
  688|     38|		card->name = "Gemalto IDPrime (generic)";
  689|     38|		break;
  690|     55|	}
  691|     55|	card->cla = 0x00;
  692|       |
  693|       |	/* Set up algorithm info for RSA. */
  694|     55|	flags = SC_ALGORITHM_RSA_PAD_PKCS1
  ------------------
  |  |  120|     55|#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) */
  |  |  ------------------
  |  |  |  |  118|     55|#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) */
  |  |  ------------------
  |  |  |  |  119|     55|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  695|     55|		| SC_ALGORITHM_RSA_PAD_PSS
  ------------------
  |  |  116|     55|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  696|     55|		| SC_ALGORITHM_RSA_PAD_OAEP
  ------------------
  |  |  117|     55|#define SC_ALGORITHM_RSA_PAD_OAEP	0x00000020 /* PKCS#1 v2.0 OAEP */
  ------------------
  697|       |		/* SHA-1 mechanisms are not allowed in the card I have */
  698|     55|		| (SC_ALGORITHM_RSA_HASH_SHA256 | SC_ALGORITHM_RSA_HASH_SHA384 | SC_ALGORITHM_RSA_HASH_SHA512)
  ------------------
  |  |  147|     55|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
              		| (SC_ALGORITHM_RSA_HASH_SHA256 | SC_ALGORITHM_RSA_HASH_SHA384 | SC_ALGORITHM_RSA_HASH_SHA512)
  ------------------
  |  |  148|     55|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
              		| (SC_ALGORITHM_RSA_HASH_SHA256 | SC_ALGORITHM_RSA_HASH_SHA384 | SC_ALGORITHM_RSA_HASH_SHA512)
  ------------------
  |  |  149|     55|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
  699|     55|		| (SC_ALGORITHM_MGF1_SHA256 | SC_ALGORITHM_MGF1_SHA384 | SC_ALGORITHM_MGF1_SHA512)
  ------------------
  |  |  155|     55|#define SC_ALGORITHM_MGF1_SHA256	0x00200000
  ------------------
              		| (SC_ALGORITHM_MGF1_SHA256 | SC_ALGORITHM_MGF1_SHA384 | SC_ALGORITHM_MGF1_SHA512)
  ------------------
  |  |  156|     55|#define SC_ALGORITHM_MGF1_SHA384	0x00400000
  ------------------
              		| (SC_ALGORITHM_MGF1_SHA256 | SC_ALGORITHM_MGF1_SHA384 | SC_ALGORITHM_MGF1_SHA512)
  ------------------
  |  |  157|     55|#define SC_ALGORITHM_MGF1_SHA512	0x00800000
  ------------------
  700|     55|		;
  701|       |
  702|     55|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  703|     55|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  704|     55|	switch (card->type) {
  705|      0|	case SC_CARD_TYPE_IDPRIME_930_PLUS:
  ------------------
  |  Branch (705:2): [True: 0, False: 55]
  ------------------
  706|     16|	case SC_CARD_TYPE_IDPRIME_940:
  ------------------
  |  Branch (706:2): [True: 16, False: 39]
  ------------------
  707|     16|		_sc_card_add_rsa_alg(card, 3072, flags, 0);
  708|       |		/* fallthrough */
  709|     16|	case SC_CARD_TYPE_IDPRIME_930:
  ------------------
  |  Branch (709:2): [True: 0, False: 55]
  ------------------
  710|     16|		_sc_card_add_rsa_alg(card, 4096, flags, 0);
  711|       |		/* fallthrough */
  712|     17|	case SC_CARD_TYPE_IDPRIME_840:
  ------------------
  |  Branch (712:2): [True: 1, False: 54]
  ------------------
  713|       |		/* Set up algorithm info for EC */
  714|     17|		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  183|     17|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  184|     17|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|     17|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  715|     17|		if (card->type == SC_CARD_TYPE_IDPRIME_930_PLUS || card->type == SC_CARD_TYPE_IDPRIME_940) {
  ------------------
  |  Branch (715:7): [True: 0, False: 17]
  |  Branch (715:54): [True: 16, False: 1]
  ------------------
  716|     16|			flags |= SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  182|     16|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  717|     16|		}
  718|     17|		ext_flags = SC_ALGORITHM_EXT_EC_F_P
  ------------------
  |  |  207|     17|#define SC_ALGORITHM_EXT_EC_F_P          0x00000001
  ------------------
  719|     17|			| SC_ALGORITHM_EXT_EC_ECPARAMETERS
  ------------------
  |  |  209|     17|#define SC_ALGORITHM_EXT_EC_ECPARAMETERS 0x00000004
  ------------------
  720|     17|			| SC_ALGORITHM_EXT_EC_NAMEDCURVE
  ------------------
  |  |  210|     17|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  721|     17|			| SC_ALGORITHM_EXT_EC_UNCOMPRESES
  ------------------
  |  |  211|     17|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  722|     17|			;
  723|     17|		_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
  724|     17|		_sc_card_add_ec_alg(card, 384, flags, ext_flags, NULL);
  725|     17|		_sc_card_add_ec_alg(card, 521, flags, ext_flags, NULL);
  726|     17|		break;
  727|     38|	default:
  ------------------
  |  Branch (727:2): [True: 38, False: 17]
  ------------------
  728|     38|		break;
  729|     55|	}
  730|       |
  731|     55|	card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|     55|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  732|       |
  733|     55|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|     55|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  734|       |
  735|     55|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 55]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  736|     55|}
card-idprime.c:idprime_process_containermap:
  312|     90|{
  313|     90|	u8 *buf = NULL;
  314|     90|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|     90|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  315|     90|	int i;
  316|     90|	uint8_t max_entries, container_index;
  317|       |
  318|     90|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  319|       |
  320|     90|	buf = malloc(length);
  321|     90|	if (buf == NULL) {
  ------------------
  |  Branch (321:6): [True: 0, False: 90]
  ------------------
  322|      0|		goto done;
  323|      0|	}
  324|       |
  325|     90|	r = 0;
  326|    633|	do {
  327|       |		/* Read at most CONTAINER_OBJ_LEN bytes */
  328|    633|		int read_length = length - r > CONTAINER_OBJ_LEN ? CONTAINER_OBJ_LEN : length - r;
  ------------------
  |  |  142|    633|#define CONTAINER_OBJ_LEN 86
  ------------------
              		int read_length = length - r > CONTAINER_OBJ_LEN ? CONTAINER_OBJ_LEN : length - r;
  ------------------
  |  |  142|    613|#define CONTAINER_OBJ_LEN 86
  ------------------
  |  Branch (328:21): [True: 613, False: 20]
  ------------------
  329|    633|		if (length == r) {
  ------------------
  |  Branch (329:7): [True: 0, False: 633]
  ------------------
  330|      0|			r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      0|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  331|      0|			goto done;
  332|      0|		}
  333|    633|		const int got = iso_ops->read_binary(card, r, buf + r, read_length, 0);
  334|    633|		if (got < 1) {
  ------------------
  |  Branch (334:7): [True: 5, False: 628]
  ------------------
  335|      5|			r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      5|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  336|      5|			goto done;
  337|      5|		}
  338|       |
  339|    628|		r += got;
  340|       |		/* Try to read chunks of container size and stop when last container looks empty */
  341|    628|		container_index = r > CONTAINER_OBJ_LEN ? (r / CONTAINER_OBJ_LEN - 1) * CONTAINER_OBJ_LEN : 0;
  ------------------
  |  |  142|    628|#define CONTAINER_OBJ_LEN 86
  ------------------
              		container_index = r > CONTAINER_OBJ_LEN ? (r / CONTAINER_OBJ_LEN - 1) * CONTAINER_OBJ_LEN : 0;
  ------------------
  |  |  142|    436|#define CONTAINER_OBJ_LEN 86
  ------------------
              		container_index = r > CONTAINER_OBJ_LEN ? (r / CONTAINER_OBJ_LEN - 1) * CONTAINER_OBJ_LEN : 0;
  ------------------
  |  |  142|    436|#define CONTAINER_OBJ_LEN 86
  ------------------
  |  Branch (341:21): [True: 436, False: 192]
  ------------------
  342|    628|	} while(length - r > 0 && buf[container_index] != 0);
  ------------------
  |  Branch (342:10): [True: 622, False: 6]
  |  Branch (342:28): [True: 543, False: 79]
  ------------------
  343|     85|	max_entries = r / CONTAINER_OBJ_LEN;
  ------------------
  |  |  142|     85|#define CONTAINER_OBJ_LEN 86
  ------------------
  344|       |
  345|    110|	for (i = 0; i < max_entries; i++) {
  ------------------
  |  Branch (345:14): [True: 26, False: 84]
  ------------------
  346|     26|		u8 *start = &buf[i * CONTAINER_OBJ_LEN];
  ------------------
  |  |  142|     26|#define CONTAINER_OBJ_LEN 86
  ------------------
  347|     26|		idprime_container_t new_container = {0};
  348|     26|		if (start[0] == 0) /* Empty record */
  ------------------
  |  Branch (348:7): [True: 1, False: 25]
  ------------------
  349|      1|			break;
  350|       |
  351|     25|		new_container.index = i;
  352|       |		/* Reading UNICODE characters but skipping second byte */
  353|     25|		int j = 0;
  354|    369|		for (j = 0; j < MAX_CONTAINER_NAME_LEN; j++) {
  ------------------
  |  |  141|    369|#define MAX_CONTAINER_NAME_LEN 39
  ------------------
  |  Branch (354:15): [True: 362, False: 7]
  ------------------
  355|    362|			if (start[2 * j] == 0)
  ------------------
  |  Branch (355:8): [True: 18, False: 344]
  ------------------
  356|     18|				break;
  357|    344|			new_container.guid[j] = start[2 * j];
  358|    344|		}
  359|       |
  360|     25|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found container with index=%d, guid=%s", new_container.index, new_container.guid);
  ------------------
  |  |   70|     25|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  361|       |
  362|     25|		if ((r = idprime_add_container_to_list(&priv->containers, &new_container)) != SC_SUCCESS) {
  ------------------
  |  |   28|     25|#define SC_SUCCESS				0
  ------------------
  |  Branch (362:7): [True: 0, False: 25]
  ------------------
  363|      0|			goto done;
  364|      0|		}
  365|     25|	}
  366|       |
  367|     85|	r = SC_SUCCESS;
  ------------------
  |  |   28|     85|#define SC_SUCCESS				0
  ------------------
  368|     90|done:
  369|     90|	free(buf);
  370|     90|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 85]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  371|     90|}
card-idprime.c:idprime_add_container_to_list:
  189|     25|{
  190|     25|	if (list_append(list, container) < 0)
  ------------------
  |  Branch (190:6): [True: 0, False: 25]
  ------------------
  191|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  192|     25|	return SC_SUCCESS;
  ------------------
  |  |   28|     25|#define SC_SUCCESS				0
  ------------------
  193|     25|}
card-idprime.c:idprime_process_keyrefmap:
  374|     38|{
  375|     38|	u8 *buf = NULL;
  376|     38|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|     38|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  377|     38|	int i, max_entries;
  378|       |
  379|     38|	buf = malloc(length);
  380|     38|	if (buf == NULL) {
  ------------------
  |  Branch (380:6): [True: 0, False: 38]
  ------------------
  381|      0|		goto done;
  382|      0|	}
  383|       |
  384|     38|	r = 0;
  385|    467|	do {
  386|    467|		if (length == r) {
  ------------------
  |  Branch (386:7): [True: 0, False: 467]
  ------------------
  387|      0|			r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      0|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  388|      0|			goto done;
  389|      0|		}
  390|    467|		const int got = iso_ops->read_binary(card, r, buf + r, length - r, 0);
  391|    467|		if (got < 1) {
  ------------------
  |  Branch (391:7): [True: 7, False: 460]
  ------------------
  392|      7|			r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      7|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  393|      7|			goto done;
  394|      7|		}
  395|       |
  396|    460|		r += got;
  397|    460|	} while(length - r > 0);
  ------------------
  |  Branch (397:10): [True: 429, False: 31]
  ------------------
  398|     31|	max_entries = r / KEYREF_OBJ_LEN;
  ------------------
  |  |  151|     31|#define KEYREF_OBJ_LEN 8
  ------------------
  399|       |
  400|  64.4k|	for (i = 0; i < max_entries; i++) {
  ------------------
  |  Branch (400:14): [True: 64.4k, False: 31]
  ------------------
  401|  64.4k|		idprime_keyref_t new_keyref;
  402|  64.4k|		u8 *start = &buf[i * KEYREF_OBJ_LEN];
  ------------------
  |  |  151|  64.4k|#define KEYREF_OBJ_LEN 8
  ------------------
  403|  64.4k|		if (start[0] == 0) /* Empty key ref */
  ------------------
  |  Branch (403:7): [True: 9.75k, False: 54.6k]
  ------------------
  404|  9.75k|			continue;
  405|       |
  406|  54.6k|		new_keyref.index = start[2];
  407|  54.6k|		new_keyref.key_reference = start[1];
  408|  54.6k|		new_keyref.pin_index = start[7];
  409|  54.6k|		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|  54.6k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  410|       |
  411|  54.6k|		if ((r = idprime_add_keyref_to_list(&priv->keyrefmap, &new_keyref)) != SC_SUCCESS) {
  ------------------
  |  |   28|  54.6k|#define SC_SUCCESS				0
  ------------------
  |  Branch (411:7): [True: 0, False: 54.6k]
  ------------------
  412|      0|			goto done;
  413|      0|		}
  414|  54.6k|	}
  415|     31|	r = SC_SUCCESS;
  ------------------
  |  |   28|     31|#define SC_SUCCESS				0
  ------------------
  416|     38|done:
  417|     38|	free(buf);
  418|     38|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 31]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  419|     38|}
card-idprime.c:idprime_add_keyref_to_list:
  207|  54.6k|{
  208|  54.6k|	if (list_append(list, keyref) < 0)
  ------------------
  |  Branch (208:6): [True: 0, False: 54.6k]
  ------------------
  209|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  210|  54.6k|	return SC_SUCCESS;
  ------------------
  |  |   28|  54.6k|#define SC_SUCCESS				0
  ------------------
  211|  54.6k|}
card-idprime.c:idprime_process_index:
  422|     58|{
  423|     58|	u8 *buf = NULL;
  424|     58|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|     58|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  425|     58|	int i, num_entries;
  426|     58|	idprime_object_t new_object;
  427|       |
  428|     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]
  |  |  ------------------
  ------------------
  429|       |
  430|     58|	buf = malloc(length);
  431|     58|	if (buf == NULL) {
  ------------------
  |  Branch (431:6): [True: 0, False: 58]
  ------------------
  432|      0|		goto done;
  433|      0|	}
  434|       |
  435|     58|	r = 0;
  436|    188|	do {
  437|    188|		if (length == r) {
  ------------------
  |  Branch (437:7): [True: 0, False: 188]
  ------------------
  438|      0|			r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      0|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  439|      0|			goto done;
  440|      0|		}
  441|    188|		const int got = iso_ops->read_binary(card, r, buf + r, length - r, 0);
  442|    188|		if (got < 1) {
  ------------------
  |  Branch (442:7): [True: 3, False: 185]
  ------------------
  443|      3|			r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      3|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  444|      3|			goto done;
  445|      3|		}
  446|       |		/* First byte shows the number of entries, each of them 21 bytes long */
  447|    185|		num_entries = buf[0];
  448|    185|		r += got;
  449|    185|	} while(r < num_entries * 21 + 1);
  ------------------
  |  Branch (449:10): [True: 130, False: 55]
  ------------------
  450|       |
  451|     55|	new_object.fd = 0;
  452|  2.39k|	for (i = 0; i < num_entries; i++) {
  ------------------
  |  Branch (452:14): [True: 2.34k, False: 55]
  ------------------
  453|  2.34k|		u8 *start = &buf[i*21+1];
  454|       |
  455|       |		/* First two bytes specify the object DF */
  456|  2.34k|		new_object.df[0] = start[0];
  457|  2.34k|		new_object.df[1] = start[1];
  458|       |		/* Second two bytes refer to the object size */
  459|  2.34k|		new_object.length = bebytes2ushort(&start[2]);
  460|  2.34k|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "df=%s, len=%u",
  ------------------
  |  |   70|  2.34k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  461|  2.34k|			sc_dump_hex(new_object.df, sizeof(new_object.df)), new_object.length);
  462|       |		/* in minidriver, mscp/kxcNN or kscNN lists certificates */
  463|  2.34k|		if (((memcmp(&start[4], "ksc", 3) == 0) || memcmp(&start[4], "kxc", 3) == 0)
  ------------------
  |  Branch (463:8): [True: 106, False: 2.23k]
  |  Branch (463:46): [True: 1, False: 2.23k]
  ------------------
  464|    107|			&& (memcmp(&start[12], "mscp", 5) == 0)) {
  ------------------
  |  Branch (464:7): [True: 90, False: 17]
  ------------------
  465|     90|			uint8_t cert_id = 0;
  466|     90|			idprime_container_t *container = NULL;
  467|       |
  468|     90|			if (start[7] >= '0' && start[7] <= '9' && start[8] >= '0' && start[8] <= '9') {
  ------------------
  |  Branch (468:8): [True: 90, False: 0]
  |  Branch (468:27): [True: 57, False: 33]
  |  Branch (468:46): [True: 46, False: 11]
  |  Branch (468:65): [True: 37, False: 9]
  ------------------
  469|     37|				cert_id = (start[7] - '0') * 10 + start[8] - '0';
  470|     37|			}
  471|     90|			new_object.fd++;
  472|     90|			new_object.key_reference = -1;
  473|     90|			new_object.valid_key_ref = 0;
  474|     90|			new_object.pin_index = 1;
  475|       |
  476|     90|			container = (idprime_container_t *) list_seek(&priv->containers, &cert_id);
  477|     90|			if (!container) {
  ------------------
  |  Branch (477:8): [True: 90, False: 0]
  ------------------
  478|       |				/* Container map missing container with certificate ID */
  479|     90|				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "No corresponding container with private key found for certificate with id=%d", cert_id);
  ------------------
  |  |   70|     90|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  480|     90|				if (card->type != SC_CARD_TYPE_IDPRIME_940) {
  ------------------
  |  Branch (480:9): [True: 60, False: 30]
  ------------------
  481|       |					/* For cards other than the 940, we don't know how to recognize
  482|       |					certificates missing keys other than to check
  483|       |					that there is a corresponding entry in the container map.*/
  484|     60|					sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Adding certificate with fd=%d", new_object.fd);
  ------------------
  |  |   70|     60|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  485|     60|					idprime_add_object_to_list(&priv->pki_list, &new_object);
  486|     60|					continue;
  487|     60|				}
  488|     90|			}
  489|       |
  490|     30|			switch (card->type) {
  491|      0|			case SC_CARD_TYPE_IDPRIME_3810:
  ------------------
  |  Branch (491:4): [True: 0, False: 30]
  ------------------
  492|      0|				new_object.key_reference = 0x31 + cert_id;
  493|      0|				break;
  494|      0|			case SC_CARD_TYPE_IDPRIME_830:
  ------------------
  |  Branch (494:4): [True: 0, False: 30]
  ------------------
  495|      0|				new_object.key_reference = 0x41 + cert_id;
  496|      0|				break;
  497|      0|			case SC_CARD_TYPE_IDPRIME_930:
  ------------------
  |  Branch (497:4): [True: 0, False: 30]
  ------------------
  498|      0|				new_object.key_reference = 0x11 + cert_id * 2;
  499|      0|				break;
  500|      0|			case SC_CARD_TYPE_IDPRIME_930_PLUS:
  ------------------
  |  Branch (500:4): [True: 0, False: 30]
  ------------------
  501|      0|				new_object.key_reference = 0x10 + cert_id * 2;
  502|      0|				break;
  503|     30|			case SC_CARD_TYPE_IDPRIME_940: {
  ------------------
  |  Branch (503:4): [True: 30, False: 0]
  ------------------
  504|     30|					idprime_keyref_t *keyref = (idprime_keyref_t *) list_seek(&priv->keyrefmap, &cert_id);
  505|     30|					if (!keyref) {
  ------------------
  |  Branch (505:10): [True: 19, False: 11]
  ------------------
  506|       |						/* Key reference file does not contain record of the key for given certificate */
  507|     19|						sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "No corresponding key reference found for certificate with id=%d", cert_id);
  ------------------
  |  |   70|     19|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  508|     19|						sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Adding certificate with fd=%d", new_object.fd);
  ------------------
  |  |   70|     19|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  509|     19|						idprime_add_object_to_list(&priv->pki_list, &new_object);
  510|     19|						continue;
  511|     19|					}
  512|     11|					new_object.key_reference = keyref->key_reference;
  513|     11|					new_object.pin_index = keyref->pin_index;
  514|     11|					break;
  515|     30|				}
  516|      0|			case SC_CARD_TYPE_IDPRIME_840:
  ------------------
  |  Branch (516:4): [True: 0, False: 30]
  ------------------
  517|      0|				new_object.key_reference = 0xf7 + cert_id;
  518|      0|				break;
  519|      0|			default:
  ------------------
  |  Branch (519:4): [True: 0, False: 30]
  ------------------
  520|      0|				new_object.key_reference = 0x56 + cert_id;
  521|      0|				break;
  522|     30|			}
  523|     11|			new_object.valid_key_ref = 1;
  524|     11|			if (container != NULL) {
  ------------------
  |  Branch (524:8): [True: 0, False: 11]
  ------------------
  525|      0|				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found certificate with fd=%d, key_ref=%d corresponding to container \"%s\"",
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  526|      0|					new_object.fd, new_object.key_reference, container->guid);
  527|     11|			} else {
  528|     11|				sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found certificate with fd=%d, key_ref=%d without corresponding container",
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  529|     11|					new_object.fd, new_object.key_reference);
  530|     11|			}
  531|       |
  532|     11|			idprime_add_object_to_list(&priv->pki_list, &new_object);
  533|       |
  534|       |		/* This looks like non-standard extension listing pkcs11 token info label in my card */
  535|  2.25k|		} else if ((memcmp(&start[4], "tinfo", 6) == 0) && (memcmp(&start[12], "p11", 4) == 0)) {
  ------------------
  |  Branch (535:14): [True: 70, False: 2.18k]
  |  Branch (535:54): [True: 21, False: 49]
  ------------------
  536|     21|			memcpy(priv->tinfo_df, new_object.df, sizeof(priv->tinfo_df));
  537|     21|			priv->tinfo_present = 1;
  538|     21|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found p11/tinfo object");
  ------------------
  |  |   70|     21|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  539|  2.23k|		} else if ((memcmp(&start[4], "cmapfile", 8) == 0) && (memcmp(&start[12], "mscp", 4) == 0)) {
  ------------------
  |  Branch (539:14): [True: 56, False: 2.17k]
  |  Branch (539:57): [True: 22, False: 34]
  ------------------
  540|     22|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found mscp/cmapfile object %s",
  ------------------
  |  |   70|     79|#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: 13, False: 9]
  |  |  |  Branch (70:115): [True: 0, False: 13]
  |  |  ------------------
  ------------------
  541|     22|					(start[0] == 02 && start[1] == 04 ? "(already processed)" : "(in non-standard path!)"));
  542|  2.21k|		} else if (memcmp(&start[4], "cardapps", 8) == 0) {
  ------------------
  |  Branch (542:14): [True: 9, False: 2.20k]
  ------------------
  543|      9|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found cardapps object");
  ------------------
  |  |   70|      9|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  544|  2.20k|		} else if (memcmp(&start[4], "cardid", 6) == 0) {
  ------------------
  |  Branch (544:14): [True: 0, False: 2.20k]
  ------------------
  545|      0|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found cardid object");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  546|  2.20k|		} else if (memcmp(&start[4], "cardcf", 6) == 0) {
  ------------------
  |  Branch (546:14): [True: 7, False: 2.19k]
  ------------------
  547|      7|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Found cardcf object");
  ------------------
  |  |   70|      7|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  548|      7|		}
  549|  2.34k|	}
  550|       |
  551|     55|	r = SC_SUCCESS;
  ------------------
  |  |   28|     55|#define SC_SUCCESS				0
  ------------------
  552|     58|done:
  553|     58|	free(buf);
  554|     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|      3|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3, False: 55]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  555|     58|}
card-idprime.c:idprime_finish:
  739|     55|{
  740|     55|	idprime_private_data_t * priv = card->drv_data;
  741|       |
  742|     55|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     55|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     55|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     55|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 55]
  |  |  ------------------
  ------------------
  743|     55|	if (priv) {
  ------------------
  |  Branch (743:6): [True: 55, False: 0]
  ------------------
  744|     55|		idprime_free_private_data(priv);
  745|     55|	}
  746|     55|	return SC_SUCCESS;
  ------------------
  |  |   28|     55|#define SC_SUCCESS				0
  ------------------
  747|     55|}
card-idprime.c:idprime_card_ctl:
  905|     55|{
  906|     55|	idprime_private_data_t * priv = card->drv_data;
  907|       |
  908|     55|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     55|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     55|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     55|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     55|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 55]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  909|     55|	sc_log(card->ctx, "cmd=%ld ptr=%p", cmd, ptr);
  ------------------
  |  |   71|     55|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  910|       |
  911|     55|	if (priv == NULL) {
  ------------------
  |  Branch (911:6): [True: 0, False: 55]
  ------------------
  912|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  913|      0|	}
  914|     55|	switch (cmd) {
  ------------------
  |  Branch (914:10): [True: 0, False: 55]
  ------------------
  915|      0|		case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (915:3): [True: 0, False: 55]
  ------------------
  916|      0|			return idprime_get_serial(card, (sc_serial_number_t *) ptr);
  917|      0|		case SC_CARDCTL_IDPRIME_GET_TOKEN_NAME:
  ------------------
  |  Branch (917:3): [True: 0, False: 55]
  ------------------
  918|      0|			return idprime_get_token_name(card, (char **) ptr);
  919|      0|		case SC_CARDCTL_IDPRIME_INIT_GET_OBJECTS:
  ------------------
  |  Branch (919:3): [True: 0, False: 55]
  ------------------
  920|      0|			return idprime_get_init_and_get_count(&priv->pki_list, &priv->pki_current,
  921|      0|				(int *)ptr);
  922|      0|		case SC_CARDCTL_IDPRIME_GET_NEXT_OBJECT:
  ------------------
  |  Branch (922:3): [True: 0, False: 55]
  ------------------
  923|      0|			return idprime_fill_prkey_info(&priv->pki_list, &priv->pki_current,
  924|      0|				(sc_pkcs15_prkey_info_t *)ptr);
  925|      0|		case SC_CARDCTL_IDPRIME_FINAL_GET_OBJECTS:
  ------------------
  |  Branch (925:3): [True: 0, False: 55]
  ------------------
  926|      0|			return idprime_final_iterator(&priv->pki_list);
  927|      0|		case SC_CARDCTL_IDPRIME_GET_PIN_ID:
  ------------------
  |  Branch (927:3): [True: 0, False: 55]
  ------------------
  928|      0|			return idprime_get_pin_id(&priv->pki_list, &priv->pki_current,
  929|      0|				(const char **)ptr);
  930|     55|	}
  931|       |
  932|     55|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  933|     55|}

sc_get_isoApplet_driver:
 1295|  3.69k|{
 1296|  3.69k|	return sc_get_driver();
 1297|  3.69k|}
card-isoApplet.c:sc_get_driver:
 1259|  3.69k|{
 1260|  3.69k|	sc_card_driver_t *iso_drv = sc_get_iso7816_driver();
 1261|       |
 1262|  3.69k|	if(iso_ops == NULL)
  ------------------
  |  Branch (1262:5): [True: 1, False: 3.69k]
  ------------------
 1263|      1|	{
 1264|      1|		iso_ops = iso_drv->ops;
 1265|      1|	}
 1266|       |
 1267|  3.69k|	isoApplet_ops = *iso_drv->ops;
 1268|       |
 1269|  3.69k|	isoApplet_ops.match_card = isoApplet_match_card;
 1270|  3.69k|	isoApplet_ops.init = isoApplet_init;
 1271|  3.69k|	isoApplet_ops.finish = isoApplet_finish;
 1272|       |
 1273|  3.69k|	isoApplet_ops.card_ctl = isoApplet_card_ctl;
 1274|       |
 1275|  3.69k|	isoApplet_ops.create_file = isoApplet_create_file;
 1276|  3.69k|	isoApplet_ops.process_fci = isoApplet_process_fci;
 1277|  3.69k|	isoApplet_ops.set_security_env = isoApplet_set_security_env;
 1278|  3.69k|	isoApplet_ops.compute_signature = isoApplet_compute_signature;
 1279|  3.69k|	isoApplet_ops.get_challenge = isoApplet_get_challenge;
 1280|  3.69k|	isoApplet_ops.card_reader_lock_obtained = isoApplet_card_reader_lock_obtained;
 1281|  3.69k|	isoApplet_ops.logout = isoApplet_logout;
 1282|       |
 1283|       |	/* unsupported functions */
 1284|  3.69k|	isoApplet_ops.write_binary = NULL;
 1285|  3.69k|	isoApplet_ops.read_record = NULL;
 1286|  3.69k|	isoApplet_ops.write_record = NULL;
 1287|  3.69k|	isoApplet_ops.append_record = NULL;
 1288|  3.69k|	isoApplet_ops.update_record = NULL;
 1289|  3.69k|	isoApplet_ops.restore_security_env = NULL;
 1290|       |
 1291|  3.69k|	return &isoApplet_drv;
 1292|  3.69k|}
card-isoApplet.c:isoApplet_match_card:
  111|    598|{
  112|    598|	int rv;
  113|       |
  114|    598|	rv = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), NULL, NULL);
  115|    598|	if(rv != SC_SUCCESS)
  ------------------
  |  |   28|    598|#define SC_SUCCESS				0
  ------------------
  |  Branch (115:5): [True: 494, False: 104]
  ------------------
  116|    494|	{
  117|    494|		return 0;
  118|    494|	}
  119|       |
  120|    104|	return 1;
  121|    598|}
card-isoApplet.c:isoApplet_init:
  155|    104|{
  156|    104|	int i, r;
  157|    104|	unsigned int major_version = 0;
  158|    104|	unsigned long flags = 0;
  159|    104|	unsigned long ext_flags = 0;
  160|    104|	struct isoApplet_drv_data *drvdata;
  161|       |
  162|    104|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    104|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|       |
  164|    104|	drvdata=calloc(1, sizeof(*drvdata));
  165|    104|	if (!drvdata)
  ------------------
  |  Branch (165:6): [True: 0, False: 104]
  ------------------
  166|    104|		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|    104|	card->drv_data = drvdata;
  169|    104|	card->cla = 0x00;
  170|       |
  171|       |	/* Obtain applet version and specific features */
  172|    104|	r = isoApplet_get_info(card, drvdata);
  173|    104|	LOG_TEST_GOTO_ERR(card->ctx, r, "Error obtaining information about applet.");
  ------------------
  |  |  184|    104|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    104|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    104|	int _ret = (r); \
  |  |  |  |  178|    104|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3, False: 101]
  |  |  |  |  ------------------
  |  |  |  |  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|    104|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 101]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  174|       |
  175|    101|	major_version = drvdata->isoapplet_version & 0xFF00;
  176|    101|	if(major_version != (ISOAPPLET_VERSION_V0 & 0xFF00) && major_version != (ISOAPPLET_VERSION_V1 & 0xFF00))
  ------------------
  |  |   36|    101|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
              	if(major_version != (ISOAPPLET_VERSION_V0 & 0xFF00) && major_version != (ISOAPPLET_VERSION_V1 & 0xFF00))
  ------------------
  |  |   37|      8|#define ISOAPPLET_VERSION_V1 0x0100
  ------------------
  |  Branch (176:5): [True: 8, False: 93]
  |  Branch (176:57): [True: 8, False: 0]
  ------------------
  177|      8|	{
  178|      8|		sc_log(card->ctx, "IsoApplet: Mismatching major API version. Not proceeding. "
  ------------------
  |  |   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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  180|      8|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|      8|#define ISOAPPLET_VERSION_V0 0x0006
  |  |  |  |  ------------------
  |  |  |  |               			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|      8|#define ISOAPPLET_VERSION_V1 0x0100
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  179|      8|			   "API versions: Driver (%04X or %04X), applet (%04X). Please update accordingly.",
  180|      8|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  181|      8|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      8|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  182|      8|		goto err;
  183|      8|	}
  184|     93|	else if(drvdata->isoapplet_version != ISOAPPLET_VERSION_V0 && drvdata->isoapplet_version != ISOAPPLET_VERSION_V1)
  ------------------
  |  |   36|    186|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
              	else if(drvdata->isoapplet_version != ISOAPPLET_VERSION_V0 && drvdata->isoapplet_version != ISOAPPLET_VERSION_V1)
  ------------------
  |  |   37|     93|#define ISOAPPLET_VERSION_V1 0x0100
  ------------------
  |  Branch (184:10): [True: 93, False: 0]
  |  Branch (184:64): [True: 93, False: 0]
  ------------------
  185|     93|	{
  186|     93|		sc_log(card->ctx, "IsoApplet: Mismatching minor version. Proceeding anyway. "
  ------------------
  |  |   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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  189|     93|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   36|     93|#define ISOAPPLET_VERSION_V0 0x0006
  |  |  |  |  ------------------
  |  |  |  |               			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  |  |  |  |  ------------------
  |  |  |  |  |  |   37|     93|#define ISOAPPLET_VERSION_V1 0x0100
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  187|     93|			   "API versions: Driver (%04X or %04X), applet (%04X). "
  188|     93|			   "Please update accordingly whenever possible.",
  189|     93|			   ISOAPPLET_VERSION_V0, ISOAPPLET_VERSION_V1, drvdata->isoapplet_version);
  190|     93|	}
  191|       |
  192|     93|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_EXT_APDU)
  ------------------
  |  |   39|     93|#define ISOAPPLET_API_FEATURE_EXT_APDU 0x01
  ------------------
  |  Branch (192:5): [True: 0, False: 93]
  ------------------
  193|      0|		card->caps |=  SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  194|     93|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_SECURE_RANDOM)
  ------------------
  |  |   40|     93|#define ISOAPPLET_API_FEATURE_SECURE_RANDOM 0x02
  ------------------
  |  Branch (194:5): [True: 0, False: 93]
  ------------------
  195|      0|		card->caps |=  SC_CARD_CAP_RNG;
  ------------------
  |  |  557|      0|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  196|     93|	if(drvdata->isoapplet_version <= 0x0005
  ------------------
  |  Branch (196:5): [True: 93, False: 0]
  ------------------
  197|      0|			|| drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_ECC)
  ------------------
  |  |   41|      0|#define ISOAPPLET_API_FEATURE_ECC 0x04
  ------------------
  |  Branch (197:7): [True: 0, False: 0]
  ------------------
  198|     93|	{
  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|     93|		flags = 0;
  206|     93|		if (major_version == (ISOAPPLET_VERSION_V0 & 0xFF00)) {
  ------------------
  |  |   36|     93|#define ISOAPPLET_VERSION_V0 0x0006
  ------------------
  |  Branch (206:7): [True: 93, False: 0]
  ------------------
  207|     93|			flags |= SC_ALGORITHM_ECDSA_HASH_SHA1;
  ------------------
  |  |  185|     93|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  143|     93|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
  208|     93|		} else { // ISOAPPLET_VERSION_V1
  209|      0|			flags |= SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  183|      0|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  210|      0|			flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  184|      0|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  211|      0|		}
  212|     93|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|     93|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  213|     93|		ext_flags = SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  211|     93|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  214|     93|		ext_flags |=  SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  210|     93|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  215|     93|		ext_flags |= SC_ALGORITHM_EXT_EC_F_P;
  ------------------
  |  |  207|     93|#define SC_ALGORITHM_EXT_EC_F_P          0x00000001
  ------------------
  216|  1.02k|		for (i=0; ec_curves[i].oid.value[0] >= 0; i++)
  ------------------
  |  Branch (216:13): [True: 930, False: 93]
  ------------------
  217|    930|		{
  218|    930|			if(drvdata->isoapplet_version >= ec_curves[i].min_applet_version)
  ------------------
  |  Branch (218:7): [True: 744, False: 186]
  ------------------
  219|    744|				_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].oid);
  220|    930|		}
  221|     93|	}
  222|       |
  223|       |	/* RSA */
  224|     93|	flags = 0;
  225|     93|	flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  120|     93|#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) */
  |  |  ------------------
  |  |  |  |  118|     93|#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) */
  |  |  ------------------
  |  |  |  |  119|     93|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  226|     93|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  142|     93|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  227|     93|	if(drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_RSA_PSS) {
  ------------------
  |  |   42|     93|#define ISOAPPLET_API_FEATURE_RSA_PSS 0x08
  ------------------
  |  Branch (227:5): [True: 0, False: 93]
  ------------------
  228|      0|		flags |= SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  116|      0|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  229|      0|	}
  230|       |	/* Key-generation: */
  231|     93|	flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|     93|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  232|       |	/* Modulus lengths: */
  233|     93|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  234|     93|	if (drvdata->isoapplet_features & ISOAPPLET_API_FEATURE_RSA_4096) {
  ------------------
  |  |   43|     93|#define ISOAPPLET_API_FEATURE_RSA_4096 0x20
  ------------------
  |  Branch (234:6): [True: 0, False: 93]
  ------------------
  235|      0|		_sc_card_add_rsa_alg(card, 4096, flags, 0);
  236|      0|	}
  237|       |
  238|     93|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     93|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     93|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     93|	int _ret = r; \
  |  |  |  |  155|     93|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 93, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     93|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 93]
  |  |  |  |  ------------------
  |  |  |  |  157|     93|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     93|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     93|	return _ret; \
  |  |  |  |  163|     93|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  239|     11|err:
  240|     11|	free(drvdata);
  241|     11|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|     11|}
card-isoApplet.c:isoApplet_get_info:
  124|    104|isoApplet_get_info(sc_card_t * card, struct isoApplet_drv_data * drvdata) {
  125|    104|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  126|    104|	int rv;
  127|    104|	sc_context_t * ctx = card->ctx;
  128|       |
  129|    104|	rv = sc_get_data(card, 0x0101, rbuf, 3);
  130|    104|	if(rv == SC_ERROR_INS_NOT_SUPPORTED) {
  ------------------
  |  |   54|    104|#define SC_ERROR_INS_NOT_SUPPORTED		-1204
  ------------------
  |  Branch (130:5): [True: 6, False: 98]
  ------------------
  131|       |		/* INS not supported. This is an older IsoApplet that might return the
  132|       |		 * applet information upon selection. For backward compatibility, try this. */
  133|      6|		size_t rlen = sizeof(rbuf);
  134|      6|		rv = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), rbuf, &rlen);
  135|      6|		LOG_TEST_RET(ctx, rv, "Error selecting applet.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  136|      5|		rv = (int)rlen;
  137|      5|	}
  138|       |
  139|    103|	if (rv < 0) {
  ------------------
  |  Branch (139:6): [True: 2, False: 101]
  ------------------
  140|      2|		LOG_TEST_RET(ctx, rv, "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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|      2|	}
  142|       |
  143|       |	/* Fill up drvdata */
  144|    101|	if(rv >= 3)
  ------------------
  |  Branch (144:5): [True: 8, False: 93]
  ------------------
  145|      8|	{
  146|      8|		drvdata->isoapplet_version = rbuf[0] << 8 | rbuf[1];
  147|      8|		drvdata->isoapplet_features = rbuf[2];
  148|      8|	}
  149|       |
  150|    101|	return SC_SUCCESS;
  ------------------
  |  |   28|    101|#define SC_SUCCESS				0
  ------------------
  151|    103|}
card-isoApplet.c:isoApplet_finish:
   97|     93|{
   98|     93|	struct isoApplet_drv_data *drvdata=DRVDATA(card);
  ------------------
  |  |   59|     93|#define DRVDATA(card)	((struct isoApplet_drv_data *) ((card)->drv_data))
  ------------------
   99|       |
  100|     93|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     93|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     93|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     93|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     93|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 93]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  101|     93|	if (drvdata)
  ------------------
  |  Branch (101:6): [True: 93, False: 0]
  ------------------
  102|     93|	{
  103|     93|		free(drvdata);
  104|     93|		card->drv_data=NULL;
  105|     93|	}
  106|     93|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     93|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     93|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     93|	int _ret = r; \
  |  |  |  |  155|     93|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 93, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     93|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 93]
  |  |  |  |  ------------------
  |  |  |  |  157|     93|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     93|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     93|	return _ret; \
  |  |  |  |  163|     93|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|     93|}
card-isoApplet.c:isoApplet_card_ctl:
 1037|    195|{
 1038|    195|	int r = 0;
 1039|       |
 1040|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1041|    195|	switch (cmd)
 1042|    195|	{
 1043|     21|	case SC_CARDCTL_ISOAPPLET_GENERATE_KEY:
  ------------------
  |  Branch (1043:2): [True: 21, False: 174]
  ------------------
 1044|     21|		r = isoApplet_ctl_generate_key(card,
 1045|     21|		                               (sc_cardctl_isoApplet_genkey_t *) ptr);
 1046|     21|		break;
 1047|      0|	case SC_CARDCTL_ISOAPPLET_IMPORT_KEY:
  ------------------
  |  Branch (1047:2): [True: 0, False: 195]
  ------------------
 1048|      0|		r = isoApplet_ctl_import_key(card,
 1049|      0|		                             (sc_cardctl_isoApplet_import_key_t *) ptr);
 1050|      0|		break;
 1051|    174|	default:
  ------------------
  |  Branch (1051:2): [True: 174, False: 21]
  ------------------
 1052|    174|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    174|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1053|    195|	}
 1054|    195|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1055|    195|}
card-isoApplet.c:isoApplet_ctl_generate_key:
  528|     21|{
  529|     21|	int r;
  530|     21|	sc_apdu_t apdu;
  531|     21|	u8 rbuf[SC_MAX_EXT_APDU_RESP_SIZE];
  532|     21|	u8 sbuf[SC_MAX_EXT_APDU_DATA_SIZE];
  533|     21|	u8 *p;
  534|     21|	const u8 *inner_tag_value;
  535|     21|	const u8 *outer_tag_value;
  536|     21|	unsigned int tag;
  537|     21|	size_t outer_tag_len;
  538|     21|	size_t inner_tag_len;
  539|     21|	unsigned int cla;
  540|     21|	size_t sz;
  541|       |
  542|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  543|       |
  544|       |	/* MANAGE SECURITY ENVIRONMENT (SET). Set the algorithm and key references. */
  545|     21|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x22, 0x41, 0x00);
  ------------------
  |  |  293|     21|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  546|       |
  547|     21|	p = sbuf;
  548|     21|	*p++ = 0x80; /* algorithm reference */
  549|     21|	*p++ = 0x01;
  550|     21|	*p++ = args->algorithm_ref;
  551|       |
  552|     21|	*p++ = 0x84; /* Private key reference */
  553|     21|	*p++ = 0x01;
  554|     21|	*p++ = args->priv_key_ref;
  555|       |
  556|     21|	sz = p - sbuf;
  557|     21|	p = NULL;
  558|       |
  559|     21|	apdu.lc = sz;
  560|     21|	apdu.datalen = sz;
  561|     21|	apdu.data = sbuf;
  562|       |
  563|     21|	r = sc_transmit_apdu(card, &apdu);
  564|     21|	LOG_TEST_RET(card->ctx, r, "APDU transmit 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: 0, False: 21]
  |  |  |  |  ------------------
  |  |  |  |  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|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 21]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  565|       |
  566|     21|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  567|     21|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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: 17, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|     21|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  568|       |
  569|       |
  570|       |	/* GENERATE ASYMMETRIC KEY PAIR
  571|       |	 * We use a larger buffer here, even if the card does not support extended apdus.
  572|       |	 * There are two cases:
  573|       |	 *  1) The card can do ext. apdus: The data fits in one apdu.
  574|       |	 *  2) The card can't do ext. apdus: sc_transmit_apdu will handle that - the
  575|       |	 *     card will send SW_BYTES_REMAINING, OpenSC will automatically do a
  576|       |	 *     GET RESPONSE to get the remaining data, and will append it to the data
  577|       |	 *     buffer. */
  578|      4|	if(args->algorithm_ref == SC_ISOAPPLET_ALG_REF_EC_GEN)
  ------------------
  |  |  980|      4|#define SC_ISOAPPLET_ALG_REF_EC_GEN 0xEC
  ------------------
  |  Branch (578:5): [True: 4, False: 0]
  ------------------
  579|      4|	{
  580|      4|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0x46, 0x00, 0x00);
  ------------------
  |  |  303|      4|#define SC_APDU_CASE_4			0x24
  ------------------
  581|      4|		apdu.data = sbuf;
  582|      4|		p = sbuf;
  583|      4|		r = isoApplet_put_ec_params(card, &args->pubkey.ec.params, p, sizeof(sbuf), &p);
  584|      4|		LOG_TEST_RET(card->ctx, r, "Error composing EC params.");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|      4|		apdu.datalen = p - sbuf;
  586|      4|		apdu.lc = p - sbuf;
  587|       |		/* Use APDU chaining if the card does not support extended apdus
  588|       |		 * and the data does not fit in one short apdu. */
  589|      4|		if ((apdu.datalen > 255) && !(card->caps & SC_CARD_CAP_APDU_EXT))
  ------------------
  |  |  554|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (589:7): [True: 0, False: 4]
  |  Branch (589:31): [True: 0, False: 0]
  ------------------
  590|      0|		{
  591|      0|			apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|      0|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
  592|      0|		}
  593|      4|	}
  594|      0|	else
  595|      0|	{
  596|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x46, 0x42, 0x00);
  ------------------
  |  |  301|      0|#define SC_APDU_CASE_2			0x22
  ------------------
  597|      0|	}
  598|       |
  599|      4|	apdu.resp = rbuf;
  600|      4|	apdu.resplen = sizeof(rbuf);
  601|      4|	if (card->caps & SC_CARD_CAP_APDU_EXT) {
  ------------------
  |  |  554|      4|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (601:6): [True: 0, False: 4]
  ------------------
  602|      0|		apdu.le = apdu.resplen;
  603|      4|	} else {
  604|      4|		apdu.le = 256;
  605|      4|	}
  606|      4|	r = sc_transmit_apdu(card, &apdu);
  607|      4|	LOG_TEST_RET(card->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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  608|       |
  609|      4|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  610|      4|	if(apdu.sw1 == 0x6A && apdu.sw2 == 0x81)
  ------------------
  |  Branch (610:5): [True: 0, False: 4]
  |  Branch (610:25): [True: 0, False: 0]
  ------------------
  611|      0|	{
  612|      0|		sc_log(card->ctx, "Key generation not supported by the card with that particular 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__
  |  |  ------------------
  ------------------
  613|      0|		       "Your card may not support the specified algorithm used by the applet / specified by you. "
  614|      0|		       "In most cases, this happens when trying to generate EC keys not supported by your java card. "
  615|      0|		       "In this case, look for supported field lengths and whether FP and/or F2M are supported.");
  616|      0|	}
  617|      4|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  618|       |
  619|       |	/* Parse the public key / response. */
  620|      3|	outer_tag_value = apdu.resp;
  621|      3|	r = sc_asn1_read_tag(&outer_tag_value, apdu.resplen, &cla, &tag, &outer_tag_len);
  622|      3|	LOG_TEST_RET(card->ctx, r, "Error in ASN1 handling.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  623|       |	/* Interindustry template for nesting one set of public key data objects */
  624|      2|	if((tag != 0x1F49) || (cla != 0x60))
  ------------------
  |  Branch (624:5): [True: 2, False: 0]
  |  Branch (624:24): [True: 0, False: 0]
  ------------------
  625|      2|	{
  626|      2|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  627|      2|		             "The data returned by the card is unexpected.");
  628|      2|	}
  629|       |
  630|      0|	switch(args->algorithm_ref)
  631|      0|	{
  632|       |
  633|      0|	case SC_ISOAPPLET_ALG_REF_RSA_GEN_2048:
  ------------------
  |  |  978|      0|#define SC_ISOAPPLET_ALG_REF_RSA_GEN_2048 0xF3
  ------------------
  |  Branch (633:2): [True: 0, False: 0]
  ------------------
  634|      0|	case SC_ISOAPPLET_ALG_REF_RSA_GEN_4096:
  ------------------
  |  |  979|      0|#define SC_ISOAPPLET_ALG_REF_RSA_GEN_4096 0xF5
  ------------------
  |  Branch (634:2): [True: 0, False: 0]
  ------------------
  635|       |		/* Search for the modulus tag (81). */
  636|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x81, &inner_tag_len);
  637|      0|		const size_t expected_modulus_len = args->algorithm_ref == SC_ISOAPPLET_ALG_REF_RSA_GEN_2048 ? 256 : 512;
  ------------------
  |  |  978|      0|#define SC_ISOAPPLET_ALG_REF_RSA_GEN_2048 0xF3
  ------------------
  |  Branch (637:39): [True: 0, False: 0]
  ------------------
  638|      0|		if(inner_tag_value == NULL || inner_tag_len != expected_modulus_len)
  ------------------
  |  Branch (638:6): [True: 0, False: 0]
  |  Branch (638:33): [True: 0, False: 0]
  ------------------
  639|      0|		{
  640|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid modulus.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  641|      0|		}
  642|      0|		if(inner_tag_len > args->pubkey.rsa.modulus.len)
  ------------------
  |  Branch (642:6): [True: 0, False: 0]
  ------------------
  643|      0|		{
  644|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  645|      0|		}
  646|      0|		memcpy(args->pubkey.rsa.modulus.value, inner_tag_value, inner_tag_len);
  647|      0|		args->pubkey.rsa.modulus.len = inner_tag_len;
  648|       |
  649|       |		/* Exponent tag (82) */
  650|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x82, &inner_tag_len);
  651|      0|		if(inner_tag_value == NULL || inner_tag_len != 3)
  ------------------
  |  Branch (651:6): [True: 0, False: 0]
  |  Branch (651:33): [True: 0, False: 0]
  ------------------
  652|      0|		{
  653|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid exponent.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  654|      0|		}
  655|      0|		if(inner_tag_len > args->pubkey.rsa.exponent.len)
  ------------------
  |  Branch (655:6): [True: 0, False: 0]
  ------------------
  656|      0|		{
  657|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  658|      0|		}
  659|      0|		if(memcmp(inner_tag_value, "\x01\x00\x01", 3) != 0)
  ------------------
  |  Branch (659:6): [True: 0, False: 0]
  ------------------
  660|      0|		{
  661|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|      0|			             "Key generation error: Unexpected public key exponent.");
  663|      0|		}
  664|      0|		memcpy(args->pubkey.rsa.exponent.value, inner_tag_value, inner_tag_len);
  665|      0|		args->pubkey.rsa.exponent.len = inner_tag_len;
  666|      0|		p = NULL;
  667|      0|		break;
  668|       |
  669|      0|	case SC_ISOAPPLET_ALG_REF_EC_GEN:
  ------------------
  |  |  980|      0|#define SC_ISOAPPLET_ALG_REF_EC_GEN 0xEC
  ------------------
  |  Branch (669:2): [True: 0, False: 0]
  ------------------
  670|       |		/* Compare the parameters received from the card to the ones sent to the card. */
  671|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x81, &inner_tag_len);
  672|      0|		if(inner_tag_value == NULL || inner_tag_len != args->pubkey.ec.params.prime.len
  ------------------
  |  Branch (672:6): [True: 0, False: 0]
  |  Branch (672:33): [True: 0, False: 0]
  ------------------
  673|      0|		        || memcmp(inner_tag_value, args->pubkey.ec.params.prime.value, inner_tag_len) != 0)
  ------------------
  |  Branch (673:14): [True: 0, False: 0]
  ------------------
  674|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid prime.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  675|       |
  676|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x82, &inner_tag_len);
  677|      0|		if(inner_tag_value == NULL || inner_tag_len != args->pubkey.ec.params.coefficientA.len
  ------------------
  |  Branch (677:6): [True: 0, False: 0]
  |  Branch (677:33): [True: 0, False: 0]
  ------------------
  678|      0|		        || memcmp(inner_tag_value, args->pubkey.ec.params.coefficientA.value, inner_tag_len) != 0)
  ------------------
  |  Branch (678:14): [True: 0, False: 0]
  ------------------
  679|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid coefficient A.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  680|       |
  681|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x83, &inner_tag_len);
  682|      0|		if(inner_tag_value == NULL || inner_tag_len != args->pubkey.ec.params.coefficientB.len
  ------------------
  |  Branch (682:6): [True: 0, False: 0]
  |  Branch (682:33): [True: 0, False: 0]
  ------------------
  683|      0|		        || memcmp(inner_tag_value, args->pubkey.ec.params.coefficientB.value, inner_tag_len) != 0)
  ------------------
  |  Branch (683:14): [True: 0, False: 0]
  ------------------
  684|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid coefficient B.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  685|       |
  686|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x84, &inner_tag_len);
  687|      0|		if(inner_tag_value == NULL || inner_tag_len != args->pubkey.ec.params.basePointG.len
  ------------------
  |  Branch (687:6): [True: 0, False: 0]
  |  Branch (687:33): [True: 0, False: 0]
  ------------------
  688|      0|		        || memcmp(inner_tag_value, args->pubkey.ec.params.basePointG.value, inner_tag_len) != 0)
  ------------------
  |  Branch (688:14): [True: 0, False: 0]
  ------------------
  689|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid base point G.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  690|       |
  691|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x85, &inner_tag_len);
  692|      0|		if(inner_tag_value == NULL || inner_tag_len != args->pubkey.ec.params.order.len
  ------------------
  |  Branch (692:6): [True: 0, False: 0]
  |  Branch (692:33): [True: 0, False: 0]
  ------------------
  693|      0|		        || memcmp(inner_tag_value, args->pubkey.ec.params.order.value, inner_tag_len) != 0)
  ------------------
  |  Branch (693:14): [True: 0, False: 0]
  ------------------
  694|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid order.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  695|       |
  696|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x87, &inner_tag_len);
  697|      0|		if(inner_tag_value == NULL || inner_tag_len != args->pubkey.ec.params.coFactor.len
  ------------------
  |  Branch (697:6): [True: 0, False: 0]
  |  Branch (697:33): [True: 0, False: 0]
  ------------------
  698|      0|		        || memcmp(inner_tag_value, args->pubkey.ec.params.coFactor.value, inner_tag_len) != 0)
  ------------------
  |  Branch (698:14): [True: 0, False: 0]
  ------------------
  699|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid cofactor.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  700|       |
  701|       |		/* Extract public key */
  702|      0|		inner_tag_value = sc_asn1_find_tag(card->ctx, outer_tag_value, outer_tag_len, (unsigned int) 0x86, &inner_tag_len);
  703|      0|		if(inner_tag_value == NULL || inner_tag_len != args->pubkey.ec.ecPointQ.len)
  ------------------
  |  Branch (703:6): [True: 0, False: 0]
  |  Branch (703:33): [True: 0, False: 0]
  ------------------
  704|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Card returned no or a invalid EC point Q.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  705|      0|		memcpy(args->pubkey.ec.ecPointQ.value, inner_tag_value, inner_tag_len);
  706|       |
  707|      0|		break;
  708|      0|	default:
  ------------------
  |  Branch (708:2): [True: 0, False: 0]
  ------------------
  709|      0|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unable to parse public key: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  710|      0|	}/* switch */
  711|       |
  712|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  713|      0|}
card-isoApplet.c:isoApplet_put_ec_params:
  483|      4|{
  484|      4|	u8 *p = out;
  485|      4|	int r;
  486|       |
  487|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|      4|	if(!params
  ------------------
  |  Branch (489:5): [True: 0, False: 4]
  ------------------
  490|      4|	        || !params->prime.value
  ------------------
  |  Branch (490:13): [True: 0, False: 4]
  ------------------
  491|      4|	        || !params->coefficientA.value
  ------------------
  |  Branch (491:13): [True: 0, False: 4]
  ------------------
  492|      4|	        || !params->coefficientB.value
  ------------------
  |  Branch (492:13): [True: 0, False: 4]
  ------------------
  493|      4|	        || !params->basePointG.value
  ------------------
  |  Branch (493:13): [True: 0, False: 4]
  ------------------
  494|      4|	        || !params->order.value
  ------------------
  |  Branch (494:13): [True: 0, False: 4]
  ------------------
  495|      4|	        || !params->coFactor.value)
  ------------------
  |  Branch (495:13): [True: 0, False: 4]
  ------------------
  496|      0|	{
  497|      0|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Error: EC params not present.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  498|      0|	}
  499|       |
  500|      4|	if(out == NULL || out_len == 0)
  ------------------
  |  Branch (500:5): [True: 0, False: 4]
  |  Branch (500:20): [True: 0, False: 4]
  ------------------
  501|      0|	{
  502|      0|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Error: Parameter out is NULL or outlen is zero.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  503|      0|	}
  504|       |
  505|      4|	r = sc_asn1_put_tag(0x81, params->prime.value, params->prime.len, p, out_len - (p - out), &p);
  506|      4|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  507|      4|	r = sc_asn1_put_tag(0x82, params->coefficientA.value, params->coefficientA.len, p, out_len - (p - out), &p);
  508|      4|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  509|      4|	r = sc_asn1_put_tag(0x83, params->coefficientB.value, params->coefficientB.len, p, out_len - (p - out), &p);
  510|      4|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  511|      4|	r = sc_asn1_put_tag(0x84, params->basePointG.value, params->basePointG.len, p, out_len - (p - out), &p);
  512|      4|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  513|      4|	r = sc_asn1_put_tag(0x85, params->order.value, params->order.len, p, out_len - (p - out), &p);
  514|      4|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  515|      4|	r = sc_asn1_put_tag(0x87, params->coFactor.value, params->coFactor.len, p, out_len - (p - out), &p);
  516|      4|	LOG_TEST_RET(card->ctx, r, "Error in handling TLV.");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|       |
  518|      4|	if (ptr != NULL)
  ------------------
  |  Branch (518:6): [True: 4, False: 0]
  ------------------
  519|      4|		*ptr = p;
  520|      4|	LOG_FUNC_RETURN(card->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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  521|      4|}
card-isoApplet.c:isoApplet_create_file:
  293|     57|{
  294|     57|	int r = 0;
  295|       |
  296|     57|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     57|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     57|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     57|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     57|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|       |
  298|     57|	if(file->sec_attr_len == 0)
  ------------------
  |  Branch (298:5): [True: 48, False: 9]
  ------------------
  299|     48|	{
  300|     48|		u8 access_buf[8];
  301|     48|		int idx[8], i;
  302|       |
  303|     48|		if(file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     48|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (303:6): [True: 18, False: 30]
  ------------------
  304|     18|		{
  305|     18|			const int df_idx[8] = /* These are the SC operations. */
  306|     18|			{
  307|     18|				0, /* Reserved. */
  308|     18|				SC_AC_OP_DELETE_SELF, /* b6 */
  ------------------
  |  |  174|     18|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  309|     18|				SC_AC_OP_LOCK,        /* b5 */
  ------------------
  |  |  167|     18|#define SC_AC_OP_LOCK			1
  ------------------
  310|     18|				SC_AC_OP_ACTIVATE,    /* b4 */
  ------------------
  |  |  186|     18|#define SC_AC_OP_ACTIVATE		20
  ------------------
  311|     18|				SC_AC_OP_DEACTIVATE,  /* b3 */
  ------------------
  |  |  187|     18|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  312|     18|				SC_AC_OP_CREATE_DF,   /* b2 */
  ------------------
  |  |  194|     18|#define SC_AC_OP_CREATE_DF		28
  ------------------
  313|     18|				SC_AC_OP_CREATE_EF,   /* b1 */
  ------------------
  |  |  193|     18|#define SC_AC_OP_CREATE_EF		27
  ------------------
  314|     18|				SC_AC_OP_DELETE       /* b0 */
  ------------------
  |  |  168|     18|#define SC_AC_OP_DELETE			2
  ------------------
  315|     18|			};
  316|    162|			for(i=0; i<8; i++)
  ------------------
  |  Branch (316:13): [True: 144, False: 18]
  ------------------
  317|    144|			{
  318|    144|				idx[i] = df_idx[i];
  319|    144|			}
  320|     18|		}
  321|     30|		else   /* EF */
  322|     30|		{
  323|     30|			const int ef_idx[8] =
  324|     30|			{
  325|     30|				0, /* Reserved. */
  326|     30|				SC_AC_OP_DELETE_SELF, /* b6 */
  ------------------
  |  |  174|     30|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  327|     30|				SC_AC_OP_LOCK,        /* b5 */
  ------------------
  |  |  167|     30|#define SC_AC_OP_LOCK			1
  ------------------
  328|     30|				SC_AC_OP_ACTIVATE,    /* b4 */
  ------------------
  |  |  186|     30|#define SC_AC_OP_ACTIVATE		20
  ------------------
  329|     30|				SC_AC_OP_DEACTIVATE,  /* b3 */
  ------------------
  |  |  187|     30|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  330|     30|				SC_AC_OP_WRITE,       /* b2 */
  ------------------
  |  |  190|     30|#define SC_AC_OP_WRITE			24
  ------------------
  331|     30|				SC_AC_OP_UPDATE,      /* b1 */
  ------------------
  |  |  189|     30|#define SC_AC_OP_UPDATE			23
  ------------------
  332|     30|				SC_AC_OP_READ         /* b0 */
  ------------------
  |  |  188|     30|#define SC_AC_OP_READ			22
  ------------------
  333|     30|			};
  334|    270|			for(i=0; i<8; i++)
  ------------------
  |  Branch (334:13): [True: 240, False: 30]
  ------------------
  335|    240|			{
  336|    240|				idx[i] = ef_idx[i];
  337|    240|			}
  338|     30|		}
  339|       |		/* Now idx contains the operation identifiers.
  340|       |		 * We now search for the OPs. */
  341|     48|		access_buf[0] = 0xFF; /* A security condition byte is present for every OP. (Table 19) */
  342|    384|		for(i=1; i<8; i++)
  ------------------
  |  Branch (342:12): [True: 336, False: 48]
  ------------------
  343|    336|		{
  344|    336|			const sc_acl_entry_t *entry;
  345|    336|			entry = sc_file_get_acl_entry(file, idx[i]);
  346|    336|			access_buf[i] = isoApplet_acl_to_security_condition_byte(entry);
  347|    336|		}
  348|       |
  349|     48|		r = sc_file_set_sec_attr(file, access_buf, 8);
  350|     48|		LOG_TEST_RET(card->ctx, r, "Error adding security attribute.");
  ------------------
  |  |  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: 0, False: 48]
  |  |  |  |  ------------------
  |  |  |  |  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|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|     48|	}
  352|       |
  353|     57|	r = iso_ops->create_file(card, file);
  354|     57|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 48]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  355|     57|}
card-isoApplet.c:isoApplet_acl_to_security_condition_byte:
  258|    336|{
  259|    336|	if(!entry)
  ------------------
  |  Branch (259:5): [True: 14, False: 322]
  ------------------
  260|     14|		return 0x00;
  261|    322|	switch(entry->method)
  262|    322|	{
  263|     14|	case SC_AC_CHV:
  ------------------
  |  |  151|     14|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (263:2): [True: 14, False: 308]
  ------------------
  264|     14|		return 0x90;
  265|      6|	case SC_AC_NEVER:
  ------------------
  |  |  163|      6|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (265:2): [True: 6, False: 316]
  ------------------
  266|      6|		return 0xFF;
  267|    274|	case SC_AC_NONE:
  ------------------
  |  |  150|    274|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (267:2): [True: 274, False: 48]
  ------------------
  268|    302|	default:
  ------------------
  |  Branch (268:2): [True: 28, False: 294]
  ------------------
  269|    302|		return 0x00;
  270|    322|	}
  271|    322|}
card-isoApplet.c:isoApplet_process_fci:
  405|    567|{
  406|    567|	int r;
  407|    567|	u8 *sa = NULL;
  408|       |
  409|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  410|       |
  411|    567|	r = iso_ops->process_fci(card, file, buf, buflen);
  412|    567|	LOG_TEST_RET(card->ctx, r, "Error while processing the FCI.");
  ------------------
  |  |  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: 0, False: 567]
  |  |  |  |  ------------------
  |  |  |  |  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|    567|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 567]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  413|       |	/* Construct the ACL from the sec_attr. */
  414|    567|	if(file->sec_attr && file->sec_attr_len == 8)
  ------------------
  |  Branch (414:5): [True: 155, False: 412]
  |  Branch (414:23): [True: 14, False: 141]
  ------------------
  415|     14|	{
  416|     14|		sa = file->sec_attr;
  417|     14|		if(sa[0] != 0xFF)
  ------------------
  |  Branch (417:6): [True: 14, False: 0]
  ------------------
  418|     14|		{
  419|     14|			LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  420|     14|			             "File security attribute does not contain a ACL byte for every operation.");
  421|     14|		}
  422|      0|		if(file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (422:6): [True: 0, False: 0]
  ------------------
  423|      0|		{
  424|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE_SELF, sa[1]);
  ------------------
  |  |  174|      0|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  425|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  426|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_LOCK, sa[2]);
  ------------------
  |  |  167|      0|#define SC_AC_OP_LOCK			1
  ------------------
  427|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  428|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_ACTIVATE, sa[3]);
  ------------------
  |  |  186|      0|#define SC_AC_OP_ACTIVATE		20
  ------------------
  429|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  430|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DEACTIVATE, sa[4]);
  ------------------
  |  |  187|      0|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  431|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_CREATE_DF, sa[5]);
  ------------------
  |  |  194|      0|#define SC_AC_OP_CREATE_DF		28
  ------------------
  433|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_CREATE_EF, sa[6]);
  ------------------
  |  |  193|      0|#define SC_AC_OP_CREATE_EF		27
  ------------------
  435|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE, sa[7]);
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
  437|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|      0|		}
  439|      0|		else if(file->type == SC_FILE_TYPE_INTERNAL_EF
  ------------------
  |  |  215|      0|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (439:11): [True: 0, False: 0]
  ------------------
  440|      0|		        || file->type == SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (440:14): [True: 0, False: 0]
  ------------------
  441|      0|		{
  442|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DELETE_SELF, sa[1]);
  ------------------
  |  |  174|      0|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  443|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_LOCK, sa[2]);
  ------------------
  |  |  167|      0|#define SC_AC_OP_LOCK			1
  ------------------
  445|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_ACTIVATE, sa[3]);
  ------------------
  |  |  186|      0|#define SC_AC_OP_ACTIVATE		20
  ------------------
  447|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  448|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_DEACTIVATE, sa[4]);
  ------------------
  |  |  187|      0|#define SC_AC_OP_DEACTIVATE		21
  ------------------
  449|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_WRITE, sa[5]);
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  451|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  452|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_UPDATE, sa[6]);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  453|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|      0|			r = isoApplet_add_sa_to_acl(file, SC_AC_OP_READ, sa[7]);
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
  455|      0|			LOG_TEST_RET(card->ctx, r, "Error adding ACL entry.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  456|      0|		}
  457|       |
  458|      0|	}
  459|       |
  460|    553|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    553|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    553|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    553|	int _ret = r; \
  |  |  |  |  155|    553|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 553, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    553|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 553]
  |  |  |  |  ------------------
  |  |  |  |  157|    553|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    553|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    553|	return _ret; \
  |  |  |  |  163|    553|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  461|    553|}
card-isoApplet.c:isoApplet_card_reader_lock_obtained:
 1241|  21.6k|{
 1242|  21.6k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  21.6k|#define SC_SUCCESS				0
  ------------------
 1243|       |
 1244|  21.6k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  21.6k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  21.6k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  21.6k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 21.6k]
  |  |  ------------------
  ------------------
 1245|       |
 1246|  21.6k|	if (was_reset > 0) {
  ------------------
  |  Branch (1246:6): [True: 0, False: 21.6k]
  ------------------
 1247|      0|		r = iso7816_select_aid(card, isoApplet_aid, sizeof(isoApplet_aid), NULL, NULL);
 1248|      0|	}
 1249|       |
 1250|  21.6k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  21.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  21.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  21.6k|	int _ret = r; \
  |  |  |  |  155|  21.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  21.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: 21.6k]
  |  |  |  |  ------------------
  |  |  |  |  157|  21.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  21.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|  21.6k|	return _ret; \
  |  |  |  |  163|  21.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1251|  21.6k|}

sc_get_itacns_driver:
  523|  3.69k|{
  524|  3.69k|	return sc_get_driver();
  525|  3.69k|}
card-itacns.c:sc_get_driver:
  504|  3.69k|{
  505|  3.69k|	if (!default_ops)
  ------------------
  |  Branch (505:6): [True: 1, False: 3.69k]
  ------------------
  506|      1|		default_ops = sc_get_iso7816_driver()->ops;
  507|  3.69k|	itacns_ops = *default_ops;
  508|  3.69k|	itacns_ops.match_card = itacns_match_card;
  509|  3.69k|	itacns_ops.init = itacns_init;
  510|  3.69k|	itacns_ops.finish = itacns_finish;
  511|  3.69k|	itacns_ops.set_security_env = itacns_set_security_env;
  512|  3.69k|	itacns_ops.restore_security_env = itacns_restore_security_env;
  513|  3.69k|	itacns_ops.pin_cmd = itacns_pin_cmd;
  514|  3.69k|	itacns_ops.read_binary = itacns_read_binary;
  515|  3.69k|	itacns_ops.list_files = itacns_list_files;
  516|  3.69k|	itacns_ops.select_file = itacns_select_file;
  517|  3.69k|	itacns_ops.card_ctl = itacns_card_ctl;
  518|  3.69k|	itacns_ops.get_challenge = itacns_get_challenge;
  519|  3.69k|	return &itacns_drv;
  520|  3.69k|}
card-itacns.c:itacns_match_card:
  122|    598|{
  123|    598|	int r = 0;
  124|       |
  125|       |	/* Try table first */
  126|    598|	r = _sc_match_atr(card, itacns_atrs, &card->type);
  127|    598|	if(r >= 0) return 1;
  ------------------
  |  Branch (127:5): [True: 0, False: 598]
  ------------------
  128|       |
  129|    598|	if (itacns_match_cns_card(card)) return 1;
  ------------------
  |  Branch (129:6): [True: 0, False: 598]
  ------------------
  130|    598|	if (itacns_match_cie_card(card)) return 1;
  ------------------
  |  Branch (130:6): [True: 0, False: 598]
  ------------------
  131|       |
  132|       |	/* No card type was matched. */
  133|    598|	return 0;
  134|    598|}
card-itacns.c:itacns_match_cns_card:
   85|    598|{
   86|    598|	u8 manufacturer_code;
   87|    598|	u8 manufacturer_mask;
   88|    598|	u8 fw_major;
   89|       |
   90|    598|	if (15 != card->reader->atr_info.hist_bytes_len ||
  ------------------
  |  Branch (90:6): [True: 594, False: 4]
  ------------------
   91|      4|	    0 != memcmp(card->reader->atr_info.hist_bytes+9, "CNS", 3))
  ------------------
  |  Branch (91:6): [True: 4, False: 0]
  ------------------
   92|    598|		return 0;
   93|       |
   94|      0|	card->type = SC_CARD_TYPE_ITACNS_CNS;
   95|       |
   96|      0|	manufacturer_code = card->reader->atr_info.hist_bytes[2];
   97|      0|	manufacturer_mask = card->reader->atr_info.hist_bytes[3];
   98|      0|	fw_major = card->reader->atr_info.hist_bytes[4];
   99|       |
  100|      0|	if (manufacturer_code == ITACNS_ICMAN_INFINEON &&
  ------------------
  |  |    9|      0|#define ITACNS_ICMAN_INFINEON		0x05
  ------------------
  |  Branch (100:6): [True: 0, False: 0]
  ------------------
  101|      0|	    manufacturer_mask == ITACNS_MASKMAN_IDEMIA &&
  ------------------
  |  |   11|      0|#define ITACNS_MASKMAN_IDEMIA		0x05
  ------------------
  |  Branch (101:6): [True: 0, False: 0]
  ------------------
  102|      0|	    fw_major >= 32) {
  ------------------
  |  Branch (102:6): [True: 0, False: 0]
  ------------------
  103|      0|			card->type = SC_CARD_TYPE_ITACNS_CNS_IDEMIA_2021;
  104|      0|	}
  105|       |
  106|      0|	return 1;
  107|    598|}
card-itacns.c:itacns_match_cie_card:
  110|    598|{
  111|    598|	u8 h7_to_h15[] = { 0x02, 'I', 'T', 'I', 'D', 0x20, 0x20, 0x31, 0x80, };
  112|    598|	if (15 != card->reader->atr_info.hist_bytes_len ||
  ------------------
  |  Branch (112:6): [True: 594, False: 4]
  ------------------
  113|      4|	    0 != memcmp(card->reader->atr_info.hist_bytes+6,
  ------------------
  |  Branch (113:6): [True: 4, False: 0]
  ------------------
  114|      4|			h7_to_h15, sizeof h7_to_h15))
  115|    598|		return 0;
  116|       |
  117|      0|	card->type = SC_CARD_TYPE_ITACNS_CIE_V2;
  118|      0|	return 1;
  119|    598|}

jpki_select_ap:
   46|    146|{
   47|    146|	int rc;
   48|    146|	sc_path_t path;
   49|       |
   50|    146|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    146|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    146|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    146|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    146|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 146]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   51|       |
   52|       |	/* Select JPKI application */
   53|    146|	sc_format_path(AID_JPKI, &path);
  ------------------
  |  |   27|    146|#define AID_JPKI "D392f000260100000001"
  ------------------
   54|    146|	path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    146|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
   55|    146|	rc = sc_select_file(card, &path, NULL);
   56|    146|	LOG_TEST_RET(card->ctx, rc, "select JPKI AP failed");
  ------------------
  |  |  174|    146|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    146|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    146|	int _ret = (r); \
  |  |  |  |  168|    146|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 143, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  169|    143|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    143|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    143|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    143|		return _ret; \
  |  |  |  |  172|    143|	} \
  |  |  |  |  173|    146|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   57|       |
   58|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   59|      3|}
sc_get_jpki_driver:
  388|  3.69k|{
  389|  3.69k|	return sc_get_driver();
  390|  3.69k|}
card-jpki.c:sc_get_driver:
  369|  3.69k|{
  370|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  371|       |
  372|  3.69k|	jpki_ops = *iso_drv->ops;
  373|  3.69k|	jpki_ops.match_card = jpki_match_card;
  374|  3.69k|	jpki_ops.init = jpki_init;
  375|  3.69k|	jpki_ops.finish = jpki_finish;
  376|  3.69k|	jpki_ops.select_file = jpki_select_file;
  377|  3.69k|	jpki_ops.pin_cmd = jpki_pin_cmd;
  378|  3.69k|	jpki_ops.set_security_env = jpki_set_security_env;
  379|  3.69k|	jpki_ops.compute_signature = jpki_compute_signature;
  380|  3.69k|	jpki_ops.card_reader_lock_obtained = jpki_card_reader_lock_obtained;
  381|  3.69k|	jpki_ops.logout = jpki_logout;
  382|       |
  383|  3.69k|	return &jpki_drv;
  384|  3.69k|}
card-jpki.c:jpki_match_card:
   63|    146|{
   64|    146|	int i, rc;
   65|       |
   66|    146|	i = _sc_match_atr(card, jpki_atrs, &card->type);
   67|    146|	if (i >= 0) {
  ------------------
  |  Branch (67:6): [True: 0, False: 146]
  ------------------
   68|      0|		return 1;
   69|      0|	}
   70|       |
   71|    146|	rc = jpki_select_ap(card);
   72|    146|	if (rc == SC_SUCCESS) {
  ------------------
  |  |   28|    146|#define SC_SUCCESS				0
  ------------------
  |  Branch (72:6): [True: 3, False: 143]
  ------------------
   73|      3|		card->type = SC_CARD_TYPE_JPKI_BASE;
   74|      3|		return 1;
   75|      3|	}
   76|    143|	return 0;
   77|    146|}
card-jpki.c:jpki_init:
   97|      3|{
   98|      3|	struct jpki_private_data *drvdata;
   99|      3|	sc_file_t *mf;
  100|      3|	int flags;
  101|       |
  102|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  103|       |
  104|      3|	drvdata = malloc(sizeof (struct jpki_private_data));
  105|      3|	if (!drvdata)
  ------------------
  |  Branch (105:6): [True: 0, False: 3]
  ------------------
  106|      3|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|       |
  108|      3|	memset(drvdata, 0, sizeof (struct jpki_private_data));
  109|       |
  110|       |	/* create virtual MF */
  111|      3|	mf = sc_file_new();
  112|      3|	if (!mf) {
  ------------------
  |  Branch (112:6): [True: 0, False: 3]
  ------------------
  113|      0|		free(drvdata);
  114|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  115|      0|	}
  116|      3|	sc_format_path("3f00", &mf->path);
  117|      3|	mf->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      3|#define SC_FILE_TYPE_DF			0x04
  ------------------
  118|      3|	mf->shareable = 0;
  119|      3|	mf->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      3|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  120|      3|	mf->size = 0;
  121|      3|	mf->id = 0x3f00;
  122|      3|	mf->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      3|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  123|      3|	sc_file_add_acl_entry(mf, SC_AC_OP_SELECT, SC_AC_NONE, 0);
  ------------------
  |  |  166|      3|#define SC_AC_OP_SELECT			0
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_SELECT, SC_AC_NONE, 0);
  ------------------
  |  |  150|      3|#define SC_AC_NONE			0x00000000
  ------------------
  124|      3|	sc_file_add_acl_entry(mf, SC_AC_OP_LIST_FILES, SC_AC_NONE, 0);
  ------------------
  |  |  172|      3|#define SC_AC_OP_LIST_FILES		6
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_LIST_FILES, SC_AC_NONE, 0);
  ------------------
  |  |  150|      3|#define SC_AC_NONE			0x00000000
  ------------------
  125|      3|	sc_file_add_acl_entry(mf, SC_AC_OP_LOCK, SC_AC_NEVER, 0);
  ------------------
  |  |  167|      3|#define SC_AC_OP_LOCK			1
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_LOCK, SC_AC_NEVER, 0);
  ------------------
  |  |  163|      3|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  126|      3|	sc_file_add_acl_entry(mf, SC_AC_OP_DELETE, SC_AC_NEVER, 0);
  ------------------
  |  |  168|      3|#define SC_AC_OP_DELETE			2
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_DELETE, SC_AC_NEVER, 0);
  ------------------
  |  |  163|      3|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  127|      3|	sc_file_add_acl_entry(mf, SC_AC_OP_CREATE, SC_AC_NEVER, 0);
  ------------------
  |  |  169|      3|#define SC_AC_OP_CREATE			3
  ------------------
              	sc_file_add_acl_entry(mf, SC_AC_OP_CREATE, SC_AC_NEVER, 0);
  ------------------
  |  |  163|      3|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  128|      3|	drvdata->mf = mf;
  129|      3|	drvdata->selected = SELECT_MF;
  ------------------
  |  |   24|      3|#define SELECT_MF 0
  ------------------
  130|       |
  131|      3|	card->name = "jpki";
  132|      3|	card->drv_data = drvdata;
  133|       |
  134|      3|	flags = SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  142|      3|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              	flags = SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  120|      3|#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) */
  |  |  ------------------
  |  |  |  |  118|      3|#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) */
  |  |  ------------------
  |  |  |  |  119|      3|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  135|      3|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  136|       |
  137|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  138|      3|}
card-jpki.c:jpki_finish:
   81|      3|{
   82|      3|	struct jpki_private_data *drvdata = JPKI_DRVDATA(card);
  ------------------
  |  |   36|      3|#define JPKI_DRVDATA(card) ((struct jpki_private_data *) ((card)->drv_data))
  ------------------
   83|       |
   84|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   85|      3|	if (drvdata) {
  ------------------
  |  Branch (85:6): [True: 3, False: 0]
  ------------------
   86|      3|		if (drvdata->mf) {
  ------------------
  |  Branch (86:7): [True: 3, False: 0]
  ------------------
   87|      3|			free(drvdata->mf);
   88|      3|		}
   89|      3|		free(drvdata);
   90|      3|		card->drv_data = NULL;
   91|      3|	}
   92|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|      3|}
card-jpki.c:jpki_select_file:
  143|    146|{
  144|    146|	struct jpki_private_data *drvdata = JPKI_DRVDATA(card);
  ------------------
  |  |   36|    146|#define JPKI_DRVDATA(card) ((struct jpki_private_data *) ((card)->drv_data))
  ------------------
  145|    146|	int rc;
  146|    146|	sc_apdu_t apdu;
  147|    146|	struct sc_file *file = NULL;
  148|       |
  149|    146|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    146|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    146|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    146|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    146|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 146]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|    146|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  151|    146|	       "jpki_select_file: path=%s, len=%"SC_FORMAT_LEN_SIZE_T"u",
  152|    146|	       sc_print_path(path), path->len);
  153|    146|	if (path->len == 2 && memcmp(path->value, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (153:6): [True: 0, False: 146]
  |  Branch (153:24): [True: 0, False: 0]
  ------------------
  154|      0|		drvdata->selected = SELECT_MF;
  ------------------
  |  |   24|      0|#define SELECT_MF 0
  ------------------
  155|      0|		if (file_out) {
  ------------------
  |  Branch (155:7): [True: 0, False: 0]
  ------------------
  156|      0|			sc_file_dup(file_out, drvdata->mf);
  157|      0|			if (*file_out == NULL) {
  ------------------
  |  Branch (157:8): [True: 0, False: 0]
  ------------------
  158|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|      0|			}
  160|      0|		}
  161|      0|		return 0;
  162|      0|	}
  163|       |
  164|    146|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  293|    146|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  165|    146|	switch (path->type) {
  166|      0|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (166:2): [True: 0, False: 146]
  ------------------
  167|      0|		apdu.p1 = 2;
  168|      0|		break;
  169|    146|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|    146|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (169:2): [True: 146, False: 0]
  ------------------
  170|    146|		apdu.p1 = 4;
  171|    146|		break;
  172|      0|	default:
  ------------------
  |  Branch (172:2): [True: 0, False: 146]
  ------------------
  173|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  174|    146|	}
  175|    146|	apdu.p2 = 0x0C;
  176|    146|	apdu.data = path->value;
  177|    146|	apdu.datalen = path->len;
  178|    146|	apdu.lc = path->len;
  179|       |
  180|    146|	rc = sc_transmit_apdu(card, &apdu);
  181|    146|	LOG_TEST_RET(card->ctx, rc, "APDU transmit failed");
  ------------------
  |  |  174|    146|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    146|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    146|	int _ret = (r); \
  |  |  |  |  168|    146|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 146]
  |  |  |  |  ------------------
  |  |  |  |  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|    146|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 146]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|    146|	rc = sc_check_sw(card, apdu.sw1, apdu.sw2);
  183|    146|	LOG_TEST_RET(card->ctx, rc, "SW Check failed");
  ------------------
  |  |  174|    146|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    146|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    146|	int _ret = (r); \
  |  |  |  |  168|    146|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 143, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  169|    143|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    143|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    143|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    143|		return _ret; \
  |  |  |  |  172|    143|	} \
  |  |  |  |  173|    146|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  184|      3|	if (!file_out) {
  ------------------
  |  Branch (184:6): [True: 3, False: 0]
  ------------------
  185|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  186|      3|	}
  187|       |
  188|       |	/* read certificate file size */
  189|      0|	if (path->len == 2 && (
  ------------------
  |  Branch (189:6): [True: 0, False: 0]
  ------------------
  190|      0|		    memcmp(path->value, "\x00\x0A", 2) == 0 ||
  ------------------
  |  Branch (190:7): [True: 0, False: 0]
  ------------------
  191|      0|		    memcmp(path->value, "\x00\x01", 2) == 0 ||
  ------------------
  |  Branch (191:7): [True: 0, False: 0]
  ------------------
  192|      0|		    memcmp(path->value, "\x00\x0B", 2) == 0 ||
  ------------------
  |  Branch (192:7): [True: 0, False: 0]
  ------------------
  193|      0|		    memcmp(path->value, "\x00\x02", 2) == 0 )
  ------------------
  |  Branch (193:7): [True: 0, False: 0]
  ------------------
  194|      0|		) {
  195|      0|		u8 buf[4];
  196|      0|		rc = sc_read_binary(card, 0, buf, 4, 0);
  197|      0|		LOG_TEST_RET(card->ctx, rc, "SW 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|      0|		if (rc < 4)
  ------------------
  |  Branch (198:7): [True: 0, False: 0]
  ------------------
  199|      0|			LOG_TEST_RET(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Received data too short");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  200|      0|		file = sc_file_new();
  201|      0|		if (!file) {
  ------------------
  |  Branch (201:7): [True: 0, False: 0]
  ------------------
  202|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  203|      0|		}
  204|      0|		file->path = *path;
  205|      0|		file->size = (buf[2] << 8 | buf[3]) + 4;
  206|      0|		*file_out = file;
  207|      0|	}
  208|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  209|      0|}
card-jpki.c:jpki_card_reader_lock_obtained:
  350|    146|{
  351|    146|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    146|#define SC_SUCCESS				0
  ------------------
  352|       |
  353|    146|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    146|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    146|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    146|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 146]
  |  |  ------------------
  ------------------
  354|       |
  355|    146|	if (was_reset > 0) {
  ------------------
  |  Branch (355:6): [True: 0, False: 146]
  ------------------
  356|      0|		r = jpki_select_ap(card);
  357|      0|	}
  358|       |
  359|    146|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    146|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    146|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    146|	int _ret = r; \
  |  |  |  |  155|    146|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 146, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    146|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 146]
  |  |  |  |  ------------------
  |  |  |  |  157|    146|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    146|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    146|	return _ret; \
  |  |  |  |  163|    146|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  360|    146|}

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

sc_get_masktech_driver:
  374|  3.69k|{
  375|  3.69k|	return sc_get_driver();
  376|  3.69k|}
card-masktech.c:sc_get_driver:
  355|  3.69k|{
  356|       |
  357|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (357:6): [True: 1, False: 3.69k]
  ------------------
  358|      1|		iso_ops = sc_get_iso7816_driver()->ops;
  359|       |
  360|  3.69k|	masktech_ops = *iso_ops;
  361|       |
  362|  3.69k|	masktech_ops.match_card = masktech_match_card;
  363|  3.69k|	masktech_ops.init = masktech_init;
  364|  3.69k|	masktech_ops.finish = masktech_finish;
  365|  3.69k|	masktech_ops.set_security_env = masktech_set_security_env;
  366|  3.69k|	masktech_ops.compute_signature = masktech_compute_signature;
  367|  3.69k|	masktech_ops.decipher = masktech_decipher;
  368|  3.69k|	masktech_ops.pin_cmd = masktech_pin_cmd;
  369|  3.69k|	masktech_ops.card_ctl = masktech_card_ctl;
  370|  3.69k|	return &masktech_drv;
  371|  3.69k|}
card-masktech.c:masktech_match_card:
   62|  1.44k|{
   63|       |	/* check if the ATR is in the known ATR */
   64|  1.44k|	if (_sc_match_atr(card, masktech_atrs, &card->type) < 0)
  ------------------
  |  Branch (64:6): [True: 1.44k, False: 0]
  ------------------
   65|  1.44k|		return 0;
   66|       |
   67|      0|	return 1;
   68|  1.44k|}

sc_get_mcrd_driver:
 1068|  3.69k|{
 1069|  3.69k|	return sc_get_driver();
 1070|  3.69k|}
card-mcrd.c:sc_get_driver:
 1049|  3.69k|{
 1050|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1051|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1051:6): [True: 1, False: 3.69k]
  ------------------
 1052|      1|		iso_ops = iso_drv->ops;
 1053|       |
 1054|  3.69k|	mcrd_ops = *iso_drv->ops;
 1055|  3.69k|	mcrd_ops.match_card = mcrd_match_card;
 1056|  3.69k|	mcrd_ops.init = mcrd_init;
 1057|  3.69k|	mcrd_ops.finish = mcrd_finish;
 1058|  3.69k|	mcrd_ops.select_file = mcrd_select_file;
 1059|  3.69k|	mcrd_ops.set_security_env = mcrd_set_security_env;
 1060|  3.69k|	mcrd_ops.compute_signature = mcrd_compute_signature;
 1061|  3.69k|	mcrd_ops.pin_cmd = mcrd_pin_cmd;
 1062|  3.69k|	mcrd_ops.logout = mcrd_logout;
 1063|       |
 1064|  3.69k|	return &mcrd_drv;
 1065|  3.69k|}
card-mcrd.c:mcrd_match_card:
  191|  3.65k|{
  192|  3.65k|	int i = 0;
  193|       |
  194|  3.65k|	i = _sc_match_atr(card, mcrd_atrs, &card->type);
  195|  3.65k|	if (i >= 0) {
  ------------------
  |  Branch (195:6): [True: 8, False: 3.64k]
  ------------------
  196|      8|		card->name = mcrd_atrs[i].name;
  197|      8|		return 1;
  198|      8|	}
  199|       |
  200|  3.64k|	return 0;
  201|  3.65k|}
card-mcrd.c:mcrd_init:
  204|      8|{
  205|      8|	unsigned long flags;
  206|      8|	struct mcrd_priv_data *priv = calloc(1, sizeof *priv);
  207|      8|	if (!priv)
  ------------------
  |  Branch (207:6): [True: 0, False: 8]
  ------------------
  208|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  209|      8|	priv->curpath[0] = MFID;
  ------------------
  |  |   67|      8|#define MFID 0x3F00
  ------------------
  210|      8|	priv->curpathlen = 1;
  211|      8|	card->drv_data = priv;
  212|      8|	card->cla = 0x00;
  213|      8|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  557|      8|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  214|       |
  215|      8|	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  111|      8|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  120|      8|#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) */
  |  |  ------------------
  |  |  |  |  118|      8|#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) */
  |  |  ------------------
  |  |  |  |  119|      8|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  142|      8|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  216|      8|	_sc_card_add_rsa_alg(card, 512, flags, 0);
  217|      8|	_sc_card_add_rsa_alg(card, 768, flags, 0);
  218|      8|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  219|       |
  220|      8|	if (SC_SUCCESS != sc_select_file (card, sc_get_mf_path(), NULL))
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  |  Branch (220:6): [True: 0, False: 8]
  ------------------
  221|      0|		sc_log(card->ctx, "Warning: select MF 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__
  |  |  ------------------
  ------------------
  222|       |
  223|      8|	load_special_files(card);
  224|       |
  225|      8|	return SC_SUCCESS;
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  226|      8|}
card-mcrd.c:load_special_files:
  248|      8|{
  249|      8|	sc_context_t *ctx = card->ctx;
  250|      8|	int r;
  251|      8|	unsigned int recno;
  252|      8|	struct df_info_s *dfi;
  253|      8|	struct rule_record_s *rule;
  254|      8|	struct keyd_record_s *keyd;
  255|       |
  256|       |	/* First check whether we already cached it. */
  257|      8|	dfi = get_df_info(card);
  258|      8|	if (dfi && dfi->rule_file)
  ------------------
  |  Branch (258:6): [True: 8, False: 0]
  |  Branch (258:13): [True: 0, False: 8]
  ------------------
  259|      0|		return 0;	/* yes. */
  260|      8|	clear_special_files(dfi);
  261|      8|	if (!dfi)
  ------------------
  |  Branch (261:6): [True: 0, False: 8]
  ------------------
  262|      8|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  263|       |
  264|       |	/* Read rule file. Note that we bypass our cache here. */
  265|      8|	r = select_part(card, MCRD_SEL_EF, EF_Rule, NULL);
  ------------------
  |  |   69|      8|#define EF_Rule 0x0030		/* Default ACL file. */
  ------------------
  266|      8|	LOG_TEST_RET(ctx, r, "selecting EF_Rule 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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  267|       |
  268|    393|	for (recno = 1;; recno++) {
  269|    393|		u8 recbuf[256];
  270|    393|		r = sc_read_record(card, recno, 0, recbuf, sizeof(recbuf),
  271|    393|					SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1305|    393|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  272|       |
  273|    393|		if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|    393|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (273:7): [True: 3, False: 390]
  ------------------
  274|      3|			break;
  275|    390|		if (r < 0) {
  ------------------
  |  Branch (275:7): [True: 5, False: 385]
  ------------------
  276|      5|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  277|    385|		} else {
  278|    385|			rule = malloc(sizeof *rule + (size_t)r);
  279|    385|			if (!rule)
  ------------------
  |  Branch (279:8): [True: 0, False: 385]
  ------------------
  280|    385|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  281|    385|			rule->recno = recno;
  282|    385|			rule->datalen = (size_t)r;
  283|    385|			memcpy(rule->data, recbuf, r);
  284|    385|			rule->next = dfi->rule_file;
  285|    385|			dfi->rule_file = rule;
  286|    385|		}
  287|    390|	}
  288|       |
  289|      3|	sc_log(ctx, "new EF_Rule file loaded (%d records)\n", recno - 1);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  290|       |
  291|       |	/* Read the KeyD file. Note that we bypass our cache here. */
  292|      3|	r = select_part(card, MCRD_SEL_EF, EF_KeyD, NULL);
  ------------------
  |  |   68|      3|#define EF_KeyD 0x0013		/* File with extra key information. */
  ------------------
  293|      3|	if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|      3|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (293:6): [True: 0, False: 3]
  ------------------
  294|      0|		sc_log(ctx, "no EF_KeyD file available\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__
  |  |  ------------------
  ------------------
  295|      0|		return 0;	/* That is okay. */
  296|      0|	}
  297|      3|	LOG_TEST_RET(ctx, r, "selecting EF_KeyD 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: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|       |
  299|    451|	for (recno = 1;; recno++) {
  300|    451|		u8 recbuf[256];
  301|    451|		r = sc_read_record(card, recno, 0, recbuf, sizeof(recbuf),
  302|    451|					SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1305|    451|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  303|       |
  304|    451|		if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|    451|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (304:7): [True: 0, False: 451]
  ------------------
  305|      0|			break;
  306|    451|		if (r < 0) {
  ------------------
  |  Branch (306:7): [True: 3, False: 448]
  ------------------
  307|      3|			SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  308|    448|		} else {
  309|    448|			keyd = malloc(sizeof *keyd + (size_t)r);
  310|    448|			if (!keyd)
  ------------------
  |  Branch (310:8): [True: 0, False: 448]
  ------------------
  311|    448|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  312|    448|			keyd->recno = recno;
  313|    448|			keyd->datalen = (size_t) r;
  314|    448|			memcpy(keyd->data, recbuf, r);
  315|    448|			keyd->next = dfi->keyd_file;
  316|    448|			dfi->keyd_file = keyd;
  317|    448|		}
  318|    451|	}
  319|       |
  320|      0|	sc_log(ctx, "new EF_KeyD file loaded (%d records)\n", recno - 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__
  |  |  ------------------
  ------------------
  321|       |	/* FIXME: Do we need to restore the current DF?  I guess it is
  322|       |	   not required, but we could try to do so by selecting 3fff?  */
  323|      0|	return 0;
  324|      3|}
card-mcrd.c:get_df_info:
  111|      8|{
  112|      8|	sc_context_t *ctx = card->ctx;
  113|      8|	struct mcrd_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  103|      8|#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
  ------------------
  114|      8|	struct df_info_s *dfi;
  115|       |
  116|      8|	if (priv->is_ef)
  ------------------
  |  Branch (116:6): [True: 0, False: 8]
  ------------------
  117|      0|		return NULL;
  118|       |
  119|      8|	if (!priv->curpathlen) {
  ------------------
  |  Branch (119:6): [True: 0, False: 8]
  ------------------
  120|      0|		sc_log(ctx, "no current path to find the df_info\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__
  |  |  ------------------
  ------------------
  121|      0|		return NULL;
  122|      0|	}
  123|       |
  124|      8|	for (dfi = priv->df_infos; dfi; dfi = dfi->next) {
  ------------------
  |  Branch (124:29): [True: 0, False: 8]
  ------------------
  125|      0|		if (dfi->pathlen == priv->curpathlen
  ------------------
  |  Branch (125:7): [True: 0, False: 0]
  ------------------
  126|      0|			&& !memcmp(dfi->path, priv->curpath,
  ------------------
  |  Branch (126:7): [True: 0, False: 0]
  ------------------
  127|      0|					dfi->pathlen * sizeof *dfi->path))
  128|      0|			return dfi;
  129|      0|	}
  130|       |	/* Not found, create it. */
  131|      8|	dfi = calloc(1, sizeof *dfi);
  132|      8|	if (!dfi) {
  ------------------
  |  Branch (132:6): [True: 0, False: 8]
  ------------------
  133|      0|		sc_log(ctx, "out of memory while allocating df_info\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__
  |  |  ------------------
  ------------------
  134|      0|		return NULL;
  135|      0|	}
  136|      8|	dfi->pathlen = priv->curpathlen;
  137|      8|	memcpy(dfi->path, priv->curpath, dfi->pathlen * sizeof *dfi->path);
  138|      8|	dfi->next = priv->df_infos;
  139|      8|	priv->df_infos = dfi;
  140|      8|	return dfi;
  141|      8|}
card-mcrd.c:clear_special_files:
  144|     16|{
  145|     16|	if (dfi) {
  ------------------
  |  Branch (145:6): [True: 16, False: 0]
  ------------------
  146|    401|		while (dfi->rule_file) {
  ------------------
  |  Branch (146:10): [True: 385, False: 16]
  ------------------
  147|    385|			struct rule_record_s *tmp = dfi->rule_file->next;
  148|    385|			free(dfi->rule_file);
  149|    385|			dfi->rule_file = tmp;
  150|    385|		}
  151|    464|		while (dfi->keyd_file) {
  ------------------
  |  Branch (151:10): [True: 448, False: 16]
  ------------------
  152|    448|			struct keyd_record_s *tmp = dfi->keyd_file->next;
  153|    448|			free(dfi->keyd_file);
  154|    448|			dfi->keyd_file = tmp;
  155|    448|		}
  156|     16|	}
  157|     16|}
card-mcrd.c:select_part:
  615|     19|{
  616|     19|	u8 fbuf[2];
  617|     19|	unsigned int len;
  618|     19|	int r;
  619|       |
  620|     19|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  621|     19|		"select_part (0x%04X, kind=%u)\n", fid, kind);
  622|       |
  623|     19|	if (fid == MFID) {
  ------------------
  |  |   67|     19|#define MFID 0x3F00
  ------------------
  |  Branch (623:6): [True: 8, False: 11]
  ------------------
  624|      8|		kind = MCRD_SEL_MF;	/* force this kind. */
  625|      8|		len = 0;
  626|     11|	} else {
  627|     11|		fbuf[0] = fid >> 8;
  628|     11|		fbuf[1] = fid & 0xff;
  629|     11|		len = 2;
  630|     11|	}
  631|     19|	r = do_select(card, kind, fbuf, len, file);
  632|       |
  633|     19|	return r;
  634|     19|}
card-mcrd.c:do_select:
  556|     19|{
  557|     19|	sc_apdu_t apdu;
  558|     19|	u8 resbuf[SC_MAX_APDU_BUFFER_SIZE];
  559|     19|	int r;
  560|       |
  561|     19|	u8 p2 = 0x00;
  562|     19|	if (kind == MCRD_SEL_EF) p2 = 0x04;
  ------------------
  |  Branch (562:6): [True: 11, False: 8]
  ------------------
  563|     19|	if (kind == MCRD_SEL_DF) p2 = 0x0C;
  ------------------
  |  Branch (563:6): [True: 0, False: 19]
  ------------------
  564|       |
  565|     19|	sc_format_apdu_ex(&apdu, 0x00, 0xA4, kind, p2, buf, buflen, resbuf, 256);
  566|     19|	r = sc_transmit_apdu(card, &apdu);
  567|     19|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  568|     19|	if (!file) {
  ------------------
  |  Branch (568:6): [True: 19, False: 0]
  ------------------
  569|     19|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (569:7): [True: 0, False: 19]
  ------------------
  570|      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]
  |  |  ------------------
  ------------------
  571|     19|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  572|     19|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  573|     19|	}
  574|      0|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  575|      0|	if (r)
  ------------------
  |  Branch (575:6): [True: 0, False: 0]
  ------------------
  576|      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]
  |  |  ------------------
  ------------------
  577|       |
  578|      0|	if (p2 == 0x0C) {
  ------------------
  |  Branch (578:6): [True: 0, False: 0]
  ------------------
  579|      0|		if (file) {
  ------------------
  |  Branch (579:7): [True: 0, False: 0]
  ------------------
  580|      0|			*file = sc_file_new();
  581|      0|			if (!*file)
  ------------------
  |  Branch (581:8): [True: 0, False: 0]
  ------------------
  582|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|      0|			(*file)->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  584|      0|			return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  585|      0|		}
  586|      0|	}
  587|       |
  588|      0|	if (p2 == 0x04 && apdu.resplen > 2 && apdu.resp[0] == 0x62) {
  ------------------
  |  Branch (588:6): [True: 0, False: 0]
  |  Branch (588:20): [True: 0, False: 0]
  |  Branch (588:40): [True: 0, False: 0]
  ------------------
  589|      0|		if (apdu.resp[1] > apdu.resplen - 2)
  ------------------
  |  Branch (589:7): [True: 0, False: 0]
  ------------------
  590|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  591|      0|		*file = sc_file_new();
  592|      0|		if (!*file)
  ------------------
  |  Branch (592:7): [True: 0, False: 0]
  ------------------
  593|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  594|      0|		process_fcp(card, *file, apdu.resp + 2, apdu.resp[1]);
  595|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  596|      0|	}
  597|       |
  598|      0|	if (p2 != 0x0C && apdu.resplen > 2 && apdu.resp[0] == 0x6F) {
  ------------------
  |  Branch (598:6): [True: 0, False: 0]
  |  Branch (598:20): [True: 0, False: 0]
  |  Branch (598:40): [True: 0, False: 0]
  ------------------
  599|      0|		if (apdu.resp[1] > apdu.resplen - 2)
  ------------------
  |  Branch (599:7): [True: 0, False: 0]
  ------------------
  600|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  601|      0|		*file = sc_file_new();
  602|      0|		if (!*file)
  ------------------
  |  Branch (602:7): [True: 0, False: 0]
  ------------------
  603|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  604|      0|		process_fcp(card, *file, apdu.resp + 2, apdu.resp[1]);
  605|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  606|      0|	}
  607|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  608|      0|}
card-mcrd.c:mcrd_finish:
  229|      8|{
  230|      8|	struct mcrd_priv_data *priv;
  231|       |
  232|      8|	if (card == NULL)
  ------------------
  |  Branch (232:6): [True: 0, False: 8]
  ------------------
  233|      0|		return 0;
  234|      8|	priv = DRVDATA(card);
  ------------------
  |  |  103|      8|#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
  ------------------
  235|     16|	while (priv->df_infos) {
  ------------------
  |  Branch (235:9): [True: 8, False: 8]
  ------------------
  236|      8|		struct df_info_s *tmp = priv->df_infos->next;
  237|      8|		clear_special_files(priv->df_infos);
  238|      8|		free(priv->df_infos);
  239|      8|		priv->df_infos = tmp;
  240|      8|	}
  241|      8|	free(priv);
  242|      8|	return 0;
  243|      8|}
card-mcrd.c:mcrd_select_file:
  849|      8|{
  850|      8|	struct mcrd_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  103|      8|#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
  ------------------
  851|      8|	int r = 0;
  852|       |
  853|      8|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  854|       |
  855|      8|	if (path->type == SC_PATH_TYPE_DF_NAME) {
  ------------------
  |  |  118|      8|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (855:6): [True: 0, False: 8]
  ------------------
  856|      0|		if (path->len > 16)
  ------------------
  |  Branch (856:7): [True: 0, False: 0]
  ------------------
  857|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  858|      0|		r = do_select(card, MCRD_SEL_AID, path->value, path->len, file);
  859|      0|		priv->curpathlen = 0;
  860|      8|	} else {
  861|      8|		unsigned short int pathtmp[SC_MAX_PATH_SIZE / 2];
  862|      8|		unsigned short int *pathptr;
  863|      8|		int samepath = 1;
  864|      8|		size_t pathlen, n;
  865|       |
  866|      8|		if ((path->len & 1) || path->len > sizeof(pathtmp))
  ------------------
  |  Branch (866:7): [True: 0, False: 8]
  |  Branch (866:26): [True: 0, False: 8]
  ------------------
  867|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  868|       |
  869|      8|		memset(pathtmp, 0, sizeof pathtmp);
  870|      8|		pathptr = pathtmp;
  871|     16|		for (n = 0; n < path->len; n += 2)
  ------------------
  |  Branch (871:15): [True: 8, False: 8]
  ------------------
  872|      8|			pathptr[n >> 1] =
  873|      8|				(unsigned short)((path->value[n] << 8) | path->value[n + 1]);
  874|      8|		pathlen = path->len >> 1;
  875|       |
  876|      8|		if (pathlen == priv->curpathlen && priv->is_ef != 2) {
  ------------------
  |  Branch (876:7): [True: 8, False: 0]
  |  Branch (876:38): [True: 8, False: 0]
  ------------------
  877|     16|			for (n = 0; n < pathlen; n++) {
  ------------------
  |  Branch (877:16): [True: 8, False: 8]
  ------------------
  878|      8|				if (priv->curpath[n] != pathptr[n]) {
  ------------------
  |  Branch (878:9): [True: 0, False: 8]
  ------------------
  879|      0|					samepath = 0;
  880|      0|					break;
  881|      0|				}
  882|      8|			}
  883|      8|		} else if (priv->curpathlen < pathlen && priv->is_ef != 2) {
  ------------------
  |  Branch (883:14): [True: 0, False: 0]
  |  Branch (883:44): [True: 0, False: 0]
  ------------------
  884|      0|			for (n = 0; n < priv->curpathlen; n++) {
  ------------------
  |  Branch (884:16): [True: 0, False: 0]
  ------------------
  885|      0|				if (priv->curpath[n] != pathptr[n]) {
  ------------------
  |  Branch (885:9): [True: 0, False: 0]
  ------------------
  886|      0|					samepath = 0;
  887|      0|					break;
  888|      0|				}
  889|      0|			}
  890|      0|			pathptr = pathptr + n;
  891|      0|			pathlen = pathlen - n;
  892|      0|		}
  893|       |
  894|      8|		if (samepath != 1 || priv->is_ef == 0 || priv->is_ef == 1) {
  ------------------
  |  Branch (894:7): [True: 0, False: 8]
  |  Branch (894:24): [True: 8, False: 0]
  |  Branch (894:44): [True: 0, False: 0]
  ------------------
  895|      8|			if (path->type == SC_PATH_TYPE_PATH)
  ------------------
  |  |  119|      8|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (895:8): [True: 8, False: 0]
  ------------------
  896|      8|				r = select_file_by_path(card, pathptr, pathlen, file);
  897|      0|			else {	/* SC_PATH_TYPE_FILEID */
  898|      0|				r = select_file_by_fid(card, pathptr, pathlen, file);
  899|      0|			}
  900|      8|		}
  901|      8|	}
  902|       |
  903|      8|	return r;
  904|      8|}
card-mcrd.c:select_file_by_path:
  688|      8|{
  689|      8|	struct mcrd_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  103|      8|#define DRVDATA(card) ((struct mcrd_priv_data *) ((card)->drv_data))
  ------------------
  690|      8|	int r;
  691|      8|	size_t i;
  692|       |
  693|      8|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  694|       |
  695|      8|	if (!(!priv->curpathlen || priv->curpath[0] == MFID))
  ------------------
  |  |   67|      8|#define MFID 0x3F00
  ------------------
  |  Branch (695:8): [True: 0, False: 8]
  |  Branch (695:29): [True: 8, False: 0]
  ------------------
  696|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  697|       |
  698|      8|	if (pathlen && *pathptr == 0x3FFF) {
  ------------------
  |  Branch (698:6): [True: 8, False: 0]
  |  Branch (698:17): [True: 0, False: 8]
  ------------------
  699|      0|		pathlen--;
  700|      0|		pathptr++;
  701|      0|	}
  702|       |
  703|      8|	if (!pathlen || pathlen >= MAX_CURPATH)
  ------------------
  |  |   71|      8|#define MAX_CURPATH 10
  ------------------
  |  Branch (703:6): [True: 0, False: 8]
  |  Branch (703:18): [True: 0, False: 8]
  ------------------
  704|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  705|      8|	else if (pathlen == 1 && pathptr[0] == MFID) {
  ------------------
  |  |   67|      8|#define MFID 0x3F00
  ------------------
  |  Branch (705:11): [True: 8, False: 0]
  |  Branch (705:27): [True: 8, False: 0]
  ------------------
  706|       |		/* MF requested: clear the cache and select it. */
  707|      8|		priv->curpathlen = 0;
  708|      8|		r = select_part(card, MCRD_SEL_MF, pathptr[0], file);
  709|      8|		LOG_TEST_RET(card->ctx, r, "unable to select MF");
  ------------------
  |  |  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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  710|      8|		priv->curpath[0] = pathptr[0];
  711|      8|		priv->curpathlen = 1;
  712|      8|		priv->is_ef = 0;
  713|      8|	} else if (pathlen > 1 && pathptr[0] == MFID) {
  ------------------
  |  |   67|      0|#define MFID 0x3F00
  ------------------
  |  Branch (713:13): [True: 0, False: 0]
  |  Branch (713:28): [True: 0, False: 0]
  ------------------
  714|       |		/* Absolute addressing, check cache to avoid
  715|       |		   unnecessary selects. */
  716|      0|		for (i = 0; (i < pathlen && i < priv->curpathlen
  ------------------
  |  Branch (716:16): [True: 0, False: 0]
  |  Branch (716:31): [True: 0, False: 0]
  ------------------
  717|      0|				&& pathptr[i] == priv->curpath[i]); i++) ;
  ------------------
  |  Branch (717:8): [True: 0, False: 0]
  ------------------
  718|      0|		if (!priv->curpathlen) {
  ------------------
  |  Branch (718:7): [True: 0, False: 0]
  ------------------
  719|       |			/* Need to do all selects starting at the root. */
  720|      0|			priv->curpathlen = 0;
  721|      0|			priv->is_ef = 0;
  722|      0|			r = select_down(card, pathptr, pathlen, 0, file);
  723|      0|		} else if (i == pathlen && i < priv->curpathlen) {
  ------------------
  |  Branch (723:14): [True: 0, False: 0]
  |  Branch (723:30): [True: 0, False: 0]
  ------------------
  724|       |			/* Go upwards; we do it the easy way and start
  725|       |			   at the root.  However we know that the target is a DF. */
  726|      0|			priv->curpathlen = 0;
  727|      0|			priv->is_ef = 0;
  728|      0|			r = select_down(card, pathptr, pathlen, 1, file);
  729|      0|		} else if (i == pathlen && i == priv->curpathlen) {
  ------------------
  |  Branch (729:14): [True: 0, False: 0]
  |  Branch (729:30): [True: 0, False: 0]
  ------------------
  730|       |			/* Already selected. */
  731|      0|			if (!file)
  ------------------
  |  Branch (731:8): [True: 0, False: 0]
  ------------------
  732|      0|				r = 0;	/* The caller did not request the fci. */
  733|      0|			else {
  734|       |				/* This EF or DF was already selected, but
  735|       |				   we need to get the FCI, so we have
  736|       |				   to select again. */
  737|      0|				if (!(priv->curpathlen > 1))
  ------------------
  |  Branch (737:9): [True: 0, False: 0]
  ------------------
  738|      0|					return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  739|      0|				priv->curpathlen--;
  740|      0|				priv->is_ef = 0;
  741|      0|				r = select_down(card, pathptr + pathlen - 1, 1,
  742|      0|						0, file);
  743|      0|			}
  744|      0|		} else {
  745|       |			/* We have to append something.  For now we
  746|       |			   simply start at the root. (fixme) */
  747|      0|			priv->curpathlen = 0;
  748|      0|			priv->is_ef = 0;
  749|      0|			r = select_down(card, pathptr, pathlen, 0, file);
  750|      0|		}
  751|      0|	} else {
  752|       |		/* Relative addressing. */
  753|      0|		if (!priv->curpathlen) {
  ------------------
  |  Branch (753:7): [True: 0, False: 0]
  ------------------
  754|       |			/* Relative addressing without a current path. So we
  755|       |			   select the MF first. */
  756|      0|			r = select_part(card, MCRD_SEL_MF, pathptr[0], file);
  757|      0|			LOG_TEST_RET(card->ctx, r, "unable to select MF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  758|      0|			priv->curpath[0] = pathptr[0];
  759|      0|			priv->curpathlen = 1;
  760|      0|			priv->is_ef = 0;
  761|      0|		}
  762|      0|		if (priv->is_ef) {
  ------------------
  |  Branch (762:7): [True: 0, False: 0]
  ------------------
  763|      0|			if(!(priv->curpathlen > 1))
  ------------------
  |  Branch (763:7): [True: 0, False: 0]
  ------------------
  764|      0|				return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  765|      0|			priv->curpathlen--;
  766|      0|			priv->is_ef = 0;
  767|      0|		}
  768|       |		/* Free the previously allocated file so we do not leak memory here */
  769|      0|		if (file) {
  ------------------
  |  Branch (769:7): [True: 0, False: 0]
  ------------------
  770|      0|			sc_file_free(*file);
  771|      0|			*file = NULL;
  772|      0|		}
  773|      0|		r = select_down(card, pathptr, pathlen, 0, file);
  774|      0|	}
  775|      8|	return r;
  776|      8|}

sc_get_muscle_driver:
  903|  3.69k|{
  904|  3.69k|	return sc_get_driver();
  905|  3.69k|}
card-muscle.c:sc_get_driver:
  871|  3.69k|{
  872|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  873|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (873:6): [True: 1, False: 3.69k]
  ------------------
  874|      1|		iso_ops = iso_drv->ops;
  875|       |
  876|  3.69k|	muscle_ops = *iso_drv->ops;
  877|  3.69k|	muscle_ops.check_sw = muscle_check_sw;
  878|  3.69k|	muscle_ops.pin_cmd = muscle_pin_cmd;
  879|  3.69k|	muscle_ops.match_card = muscle_match_card;
  880|  3.69k|	muscle_ops.init = muscle_init;
  881|  3.69k|	muscle_ops.finish = muscle_finish;
  882|       |
  883|  3.69k|	muscle_ops.get_challenge = muscle_get_challenge;
  884|       |
  885|  3.69k|	muscle_ops.set_security_env = muscle_set_security_env;
  886|  3.69k|	muscle_ops.restore_security_env = muscle_restore_security_env;
  887|  3.69k|	muscle_ops.compute_signature = muscle_compute_signature;
  888|  3.69k|	muscle_ops.decipher = muscle_decipher;
  889|  3.69k|	muscle_ops.card_ctl = muscle_card_ctl;
  890|  3.69k|	muscle_ops.read_binary = muscle_read_binary;
  891|  3.69k|	muscle_ops.update_binary = muscle_update_binary;
  892|  3.69k|	muscle_ops.create_file = muscle_create_file;
  893|  3.69k|	muscle_ops.select_file = muscle_select_file;
  894|  3.69k|	muscle_ops.delete_file = muscle_delete_file;
  895|  3.69k|	muscle_ops.list_files = muscle_list_files;
  896|  3.69k|	muscle_ops.card_reader_lock_obtained = muscle_card_reader_lock_obtained;
  897|  3.69k|	muscle_ops.logout = muscle_logout;
  898|       |
  899|  3.69k|	return &muscle_drv;
  900|  3.69k|}
card-muscle.c:muscle_check_sw:
  809|   125k|static int muscle_check_sw(sc_card_t * card, unsigned int sw1, unsigned int sw2) {
  810|   125k|	if(sw1 == 0x9C) {
  ------------------
  |  Branch (810:5): [True: 9, False: 125k]
  ------------------
  811|      9|		switch(sw2) {
  ------------------
  |  Branch (811:10): [True: 4, False: 5]
  ------------------
  812|      0|			case 0x01: /* SW_NO_MEMORY_LEFT */
  ------------------
  |  Branch (812:4): [True: 0, False: 9]
  ------------------
  813|      0|				return SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      0|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  814|      4|			case 0x02: /* SW_AUTH_FAILED */
  ------------------
  |  Branch (814:4): [True: 4, False: 5]
  ------------------
  815|      4|				return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      4|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  816|      0|			case 0x03: /* SW_OPERATION_NOT_ALLOWED */
  ------------------
  |  Branch (816:4): [True: 0, False: 9]
  ------------------
  817|      0|				return SC_ERROR_NOT_ALLOWED;
  ------------------
  |  |   59|      0|#define SC_ERROR_NOT_ALLOWED			-1209
  ------------------
  818|      0|			case 0x05: /* SW_UNSUPPORTED_FEATURE */
  ------------------
  |  Branch (818:4): [True: 0, False: 9]
  ------------------
  819|      0|				return SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|      0|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
  820|      0|			case 0x06: /* SW_UNAUTHORIZED */
  ------------------
  |  Branch (820:4): [True: 0, False: 9]
  ------------------
  821|      0|				return SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  822|      0|			case 0x07: /* SW_OBJECT_NOT_FOUND */
  ------------------
  |  Branch (822:4): [True: 0, False: 9]
  ------------------
  823|      0|				return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  824|      0|			case 0x08: /* SW_OBJECT_EXISTS */
  ------------------
  |  Branch (824:4): [True: 0, False: 9]
  ------------------
  825|      0|				return SC_ERROR_FILE_ALREADY_EXISTS;
  ------------------
  |  |   65|      0|#define SC_ERROR_FILE_ALREADY_EXISTS		-1215
  ------------------
  826|      0|			case 0x09: /* SW_INCORRECT_ALG */
  ------------------
  |  Branch (826:4): [True: 0, False: 9]
  ------------------
  827|      0|				return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  828|      0|			case 0x0B: /* SW_SIGNATURE_INVALID */
  ------------------
  |  Branch (828:4): [True: 0, False: 9]
  ------------------
  829|      0|				return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|      0|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  830|      0|			case 0x0C: /* SW_IDENTITY_BLOCKED */
  ------------------
  |  Branch (830:4): [True: 0, False: 9]
  ------------------
  831|      0|				return SC_ERROR_AUTH_METHOD_BLOCKED;
  ------------------
  |  |   62|      0|#define SC_ERROR_AUTH_METHOD_BLOCKED		-1212
  ------------------
  832|      0|			case 0x0F: /* SW_INVALID_PARAMETER */
  ------------------
  |  Branch (832:4): [True: 0, False: 9]
  ------------------
  833|      0|			case 0x10: /* SW_INCORRECT_P1 */
  ------------------
  |  Branch (833:4): [True: 0, False: 9]
  ------------------
  834|      0|			case 0x11: /* SW_INCORRECT_P2 */
  ------------------
  |  Branch (834:4): [True: 0, False: 9]
  ------------------
  835|      0|				return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  836|      9|		}
  837|      9|	}
  838|   125k|	return iso_ops->check_sw(card, sw1, sw2);
  839|   125k|}
card-muscle.c:muscle_pin_cmd:
  553|      2|{
  554|      2|	muscle_private_t* priv = MUSCLE_DATA(card);
  ------------------
  |  |   57|      2|#define MUSCLE_DATA(card) ( (muscle_private_t*)card->drv_data )
  ------------------
  555|      2|	const int bufferLength = MSC_MAX_PIN_COMMAND_LENGTH;
  ------------------
  |  |   32|      2|#define MSC_MAX_PIN_COMMAND_LENGTH ((1 + MSC_MAX_PIN_LENGTH) * 2)
  |  |  ------------------
  |  |  |  |   31|      2|#define MSC_MAX_PIN_LENGTH 8
  |  |  ------------------
  ------------------
  556|      2|	u8 buffer[MSC_MAX_PIN_COMMAND_LENGTH];
  557|      2|	switch(cmd->cmd) {
  558|      0|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  422|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (558:2): [True: 0, False: 2]
  ------------------
  559|      0|		switch(cmd->pin_type) {
  560|      0|		case SC_AC_CHV: {
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (560:3): [True: 0, False: 0]
  ------------------
  561|      0|			sc_apdu_t apdu;
  562|      0|			int r;
  563|      0|			r = msc_verify_pin_apdu(card, &apdu, buffer, bufferLength, cmd->pin_reference, cmd->pin1.data, cmd->pin1.len);
  564|      0|			if (r < 0)
  ------------------
  |  Branch (564:8): [True: 0, False: 0]
  ------------------
  565|      0|				return r;
  566|      0|			cmd->apdu = &apdu;
  567|      0|			cmd->pin1.offset = 5;
  568|      0|			r = iso_ops->pin_cmd(card, cmd);
  569|      0|			if(r >= 0)
  ------------------
  |  Branch (569:7): [True: 0, False: 0]
  ------------------
  570|      0|				priv->verifiedPins |= (1 << cmd->pin_reference);
  571|      0|			return r;
  572|      0|		}
  573|      0|		case SC_AC_TERM:
  ------------------
  |  |  152|      0|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (573:3): [True: 0, False: 0]
  ------------------
  574|      0|		case SC_AC_PRO:
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (574:3): [True: 0, False: 0]
  ------------------
  575|      0|		case SC_AC_AUT:
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (575:3): [True: 0, False: 0]
  ------------------
  576|      0|		case SC_AC_NONE:
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (576:3): [True: 0, False: 0]
  ------------------
  577|      0|		default:
  ------------------
  |  Branch (577:3): [True: 0, False: 0]
  ------------------
  578|      0|			sc_log(card->ctx,  "Unsupported authentication method\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__
  |  |  ------------------
  ------------------
  579|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  580|      0|		}
  581|      0|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (581:2): [True: 0, False: 2]
  ------------------
  582|      0|		switch(cmd->pin_type) {
  583|      0|		case SC_AC_CHV: {
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (583:3): [True: 0, False: 0]
  ------------------
  584|      0|			sc_apdu_t apdu;
  585|      0|			int r;
  586|      0|			r = msc_change_pin_apdu(card, &apdu, buffer, bufferLength, cmd->pin_reference, cmd->pin1.data, cmd->pin1.len, cmd->pin2.data, cmd->pin2.len);
  587|      0|			if (r < 0)
  ------------------
  |  Branch (587:8): [True: 0, False: 0]
  ------------------
  588|      0|				return r;
  589|      0|			cmd->apdu = &apdu;
  590|      0|			return iso_ops->pin_cmd(card, cmd);
  591|      0|		}
  592|      0|		case SC_AC_TERM:
  ------------------
  |  |  152|      0|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (592:3): [True: 0, False: 0]
  ------------------
  593|      0|		case SC_AC_PRO:
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (593:3): [True: 0, False: 0]
  ------------------
  594|      0|		case SC_AC_AUT:
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (594:3): [True: 0, False: 0]
  ------------------
  595|      0|		case SC_AC_NONE:
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (595:3): [True: 0, False: 0]
  ------------------
  596|      0|		default:
  ------------------
  |  Branch (596:3): [True: 0, False: 0]
  ------------------
  597|      0|			sc_log(card->ctx,  "Unsupported authentication method\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__
  |  |  ------------------
  ------------------
  598|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  599|      0|		}
  600|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (600:2): [True: 0, False: 2]
  ------------------
  601|      0|	switch(cmd->pin_type) {
  602|      0|		case SC_AC_CHV: {
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (602:3): [True: 0, False: 0]
  ------------------
  603|      0|			sc_apdu_t apdu;
  604|      0|			int r;
  605|      0|			r = msc_unblock_pin_apdu(card, &apdu, buffer, bufferLength, cmd->pin_reference, cmd->pin1.data, cmd->pin1.len);
  606|      0|			if (r < 0)
  ------------------
  |  Branch (606:8): [True: 0, False: 0]
  ------------------
  607|      0|				return r;
  608|      0|			cmd->apdu = &apdu;
  609|      0|			return iso_ops->pin_cmd(card, cmd);
  610|      0|		}
  611|      0|		case SC_AC_TERM:
  ------------------
  |  |  152|      0|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (611:3): [True: 0, False: 0]
  ------------------
  612|      0|		case SC_AC_PRO:
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (612:3): [True: 0, False: 0]
  ------------------
  613|      0|		case SC_AC_AUT:
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (613:3): [True: 0, False: 0]
  ------------------
  614|      0|		case SC_AC_NONE:
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (614:3): [True: 0, False: 0]
  ------------------
  615|      0|		default:
  ------------------
  |  Branch (615:3): [True: 0, False: 0]
  ------------------
  616|      0|			sc_log(card->ctx,  "Unsupported authentication method\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__
  |  |  ------------------
  ------------------
  617|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  618|      0|		}
  619|      2|	default:
  ------------------
  |  Branch (619:2): [True: 2, False: 0]
  ------------------
  620|      2|		sc_log(card->ctx,  "Unsupported command\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  621|      2|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      2|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  622|       |
  623|      2|	}
  624|       |
  625|      2|}
card-muscle.c:muscle_match_card:
   79|  1.35k|{
   80|  1.35k|	sc_apdu_t apdu;
   81|  1.35k|	u8 response[64];
   82|  1.35k|	int r;
   83|       |
   84|  1.35k|	if (msc_select_applet(card, muscleAppletId, sizeof muscleAppletId) == 1) {
  ------------------
  |  Branch (84:6): [True: 295, False: 1.05k]
  ------------------
   85|       |		/* Muscle applet is present, check the protocol version to be sure */
   86|    295|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x3C, 0x00, 0x00);
  ------------------
  |  |  301|    295|#define SC_APDU_CASE_2			0x22
  ------------------
   87|    295|		apdu.cla = 0xB0;
   88|    295|		apdu.le = 64;
   89|    295|		apdu.resplen = 64;
   90|    295|		apdu.resp = response;
   91|    295|		r = sc_transmit_apdu(card, &apdu);
   92|    295|		if (r == SC_SUCCESS && apdu.resplen > 1 && response[0] == 0x01) {
  ------------------
  |  |   28|    590|#define SC_SUCCESS				0
  ------------------
  |  Branch (92:7): [True: 289, False: 6]
  |  Branch (92:26): [True: 149, False: 140]
  |  Branch (92:46): [True: 8, False: 141]
  ------------------
   93|      8|			card->type = SC_CARD_TYPE_MUSCLE_V1;
   94|    287|		} else {
   95|    287|			card->type = SC_CARD_TYPE_MUSCLE_GENERIC;
   96|    287|		}
   97|    295|		return 1;
   98|    295|	}
   99|  1.05k|	return 0;
  100|  1.35k|}
card-muscle.c:muscle_init:
  464|    295|{
  465|    295|	muscle_private_t *priv;
  466|    295|	int r;
  467|       |
  468|    295|	card->name = "MuscleApplet";
  469|    295|	card->drv_data = malloc(sizeof(muscle_private_t));
  470|    295|	if(!card->drv_data) {
  ------------------
  |  Branch (470:5): [True: 0, False: 295]
  ------------------
  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|    295|	memset(card->drv_data, 0, sizeof(muscle_private_t));
  474|    295|	priv = MUSCLE_DATA(card);
  ------------------
  |  |   57|    295|#define MUSCLE_DATA(card) ( (muscle_private_t*)card->drv_data )
  ------------------
  475|    295|	priv->verifiedPins = 0;
  476|    295|	priv->fs = mscfs_new();
  477|    295|	if(!priv->fs) {
  ------------------
  |  Branch (477:5): [True: 0, False: 295]
  ------------------
  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|    295|	priv->fs->udata = card;
  482|    295|	priv->fs->listFile = _listFile;
  483|       |
  484|    295|	card->cla = 0xB0;
  485|       |
  486|    295|	card->flags |= SC_CARD_FLAG_RNG;
  ------------------
  |  |  543|    295|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  487|    295|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|    295|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  488|       |
  489|       |	/* Card type detection */
  490|    295|	r = _sc_match_atr(card, muscle_atrs, &card->type);
  491|    295|	if (r < 0) {
  ------------------
  |  Branch (491:6): [True: 295, False: 0]
  ------------------
  492|    295|		sc_log(card->ctx, "Failed to match the ATRs");
  ------------------
  |  |   71|    295|#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|    295|	}
  494|    295|	if(card->type == SC_CARD_TYPE_MUSCLE_ETOKEN_72K) {
  ------------------
  |  Branch (494:5): [True: 0, False: 295]
  ------------------
  495|      0|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  496|      0|	}
  497|    295|	if(card->type == SC_CARD_TYPE_MUSCLE_JCOP241) {
  ------------------
  |  Branch (497:5): [True: 0, False: 295]
  ------------------
  498|      0|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  499|      0|	}
  500|    295|	if (!(card->caps & SC_CARD_CAP_APDU_EXT)) {
  ------------------
  |  |  554|    295|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (500:6): [True: 295, False: 0]
  ------------------
  501|    295|		card->max_recv_size = 255;
  502|    295|		card->max_send_size = 255;
  503|    295|	}
  504|    295|	if(card->type == SC_CARD_TYPE_MUSCLE_JCOP242R2_NO_EXT_APDU) {
  ------------------
  |  Branch (504:5): [True: 0, False: 295]
  ------------------
  505|       |	        /* Tyfone JCOP v242R2 card that doesn't support extended APDUs */
  506|      0|	}
  507|       |
  508|       |
  509|       |	/* FIXME: Card type detection */
  510|    295|	if (1) {
  ------------------
  |  Branch (510:6): [True: 295, Folded]
  ------------------
  511|    295|		unsigned long flags;
  512|       |
  513|    295|		flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  111|    295|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  514|    295|		flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  142|    295|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  515|    295|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    295|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  516|       |
  517|    295|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  518|    295|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  519|    295|	}
  520|    295|	return SC_SUCCESS;
  ------------------
  |  |   28|    295|#define SC_SUCCESS				0
  ------------------
  521|    295|}
card-muscle.c:_listFile:
  458|   125k|{
  459|   125k|	int next = reset ? 0x00 : 0x01;
  ------------------
  |  Branch (459:13): [True: 404, False: 124k]
  ------------------
  460|   125k|	return msc_list_objects( (sc_card_t*)udata, next, file);
  461|   125k|}
card-muscle.c:muscle_finish:
   68|    295|{
   69|    295|	muscle_private_t *priv = MUSCLE_DATA(card);
  ------------------
  |  |   57|    295|#define MUSCLE_DATA(card) ( (muscle_private_t*)card->drv_data )
  ------------------
   70|    295|	mscfs_free(priv->fs);
   71|    295|	free(priv);
   72|    295|	return 0;
   73|    295|}
card-muscle.c:muscle_card_ctl:
  674|    332|{
  675|    332|	switch(request) {
  676|     25|	case SC_CARDCTL_MUSCLE_GENERATE_KEY:
  ------------------
  |  Branch (676:2): [True: 25, False: 307]
  ------------------
  677|     25|		return muscle_card_generate_key(card, (sc_cardctl_muscle_gen_key_info_t*) data);
  678|      9|	case SC_CARDCTL_MUSCLE_EXTRACT_KEY:
  ------------------
  |  Branch (678:2): [True: 9, False: 323]
  ------------------
  679|      9|		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: 332]
  ------------------
  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: 332]
  ------------------
  683|      0|		return muscle_card_verified_pins(card, (sc_cardctl_muscle_verified_pins_info_t*) data);
  684|    298|	default:
  ------------------
  |  Branch (684:2): [True: 298, False: 34]
  ------------------
  685|    298|		return SC_ERROR_NOT_SUPPORTED; /* Unsupported.. whatever it is */
  ------------------
  |  |   89|    298|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  686|    332|	}
  687|    332|}
card-muscle.c:muscle_card_generate_key:
  658|     25|{
  659|     25|	return msc_generate_keypair(card,
  660|     25|		info->privateKeyLocation,
  661|     25|		info->publicKeyLocation,
  662|     25|		info->keyType,
  663|     25|		info->keySize,
  664|     25|		0);
  665|     25|}
card-muscle.c:muscle_card_extract_key:
  628|      9|{
  629|       |	/* CURRENTLY DONT SUPPORT EXTRACTING PRIVATE KEYS... */
  630|      9|	switch(info->keyType) {
  631|      9|	case 1: /* RSA */
  ------------------
  |  Branch (631:2): [True: 9, False: 0]
  ------------------
  632|      9|		return msc_extract_rsa_public_key(card,
  633|      9|			info->keyLocation,
  634|      9|			&info->modLength,
  635|      9|			&info->modValue,
  636|      9|			&info->expLength,
  637|      9|			&info->expValue);
  638|      0|	default:
  ------------------
  |  Branch (638:2): [True: 0, False: 9]
  ------------------
  639|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  640|      9|	}
  641|      9|}
card-muscle.c:muscle_read_binary:
  199|    171|{
  200|    171|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|    171|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  201|    171|	int r;
  202|    171|	msc_id objectId;
  203|    171|	u8* oid = objectId.id;
  204|    171|	mscfs_file_t *file;
  205|       |
  206|    171|	r = mscfs_check_selection(fs, -1);
  207|    171|	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: 171]
  ------------------
  208|    171|	file = &fs->cache.array[fs->currentFileIndex];
  209|    171|	objectId = file->objectId;
  210|       |	/* memcpy(objectId.id, file->objectId.id, 4); */
  211|    171|	if(!file->ef) {
  ------------------
  |  Branch (211:5): [True: 0, False: 171]
  ------------------
  212|      0|		oid[0] = oid[2];
  213|      0|		oid[1] = oid[3];
  214|      0|		oid[2] = oid[3] = 0;
  215|      0|	}
  216|    171|	r = msc_read_object(card, objectId, idx, buf, count);
  217|    171|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    171|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    171|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    171|	int _ret = r; \
  |  |  |  |  155|    171|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 38, False: 133]
  |  |  |  |  ------------------
  |  |  |  |  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|     38|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 38, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     38|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    133|	} else { \
  |  |  |  |  159|    133|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    133|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    133|	} \
  |  |  |  |  162|    171|	return _ret; \
  |  |  |  |  163|    171|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  218|    171|}
card-muscle.c:muscle_update_binary:
  221|  1.28k|{
  222|  1.28k|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|  1.28k|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  223|  1.28k|	int r;
  224|  1.28k|	mscfs_file_t *file;
  225|  1.28k|	msc_id objectId;
  226|  1.28k|	u8* oid = objectId.id;
  227|       |
  228|  1.28k|	r = mscfs_check_selection(fs, -1);
  229|  1.28k|	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 (229:5): [True: 0, False: 1.28k]
  ------------------
  230|  1.28k|	file = &fs->cache.array[fs->currentFileIndex];
  231|       |
  232|  1.28k|	objectId = file->objectId;
  233|       |	/* memcpy(objectId.id, file->objectId.id, 4); */
  234|  1.28k|	if(!file->ef) {
  ------------------
  |  Branch (234:5): [True: 1.28k, False: 0]
  ------------------
  235|  1.28k|		oid[0] = oid[2];
  236|  1.28k|		oid[1] = oid[3];
  237|  1.28k|		oid[2] = oid[3] = 0;
  238|  1.28k|	}
  239|  1.28k|	if(file->size < idx + count) {
  ------------------
  |  Branch (239:5): [True: 0, False: 1.28k]
  ------------------
  240|      0|		size_t newFileSize = idx + count;
  241|      0|		u8* buffer = malloc(newFileSize);
  242|      0|		if(buffer == NULL) 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 (242:6): [True: 0, False: 0]
  ------------------
  243|       |
  244|      0|		r = msc_read_object(card, objectId, 0, buffer, file->size);
  245|       |		/* TODO: RETRIEVE ACLS */
  246|      0|		if(r < 0) goto update_bin_free_buffer;
  ------------------
  |  Branch (246:6): [True: 0, False: 0]
  ------------------
  247|      0|		r = msc_delete_object(card, objectId, 0);
  248|      0|		if(r < 0) goto update_bin_free_buffer;
  ------------------
  |  Branch (248:6): [True: 0, False: 0]
  ------------------
  249|      0|		r = msc_create_object(card, objectId, newFileSize, 0,0,0);
  250|      0|		if(r < 0) goto update_bin_free_buffer;
  ------------------
  |  Branch (250:6): [True: 0, False: 0]
  ------------------
  251|      0|		memcpy(buffer + idx, buf, count);
  252|      0|		r = msc_update_object(card, objectId, 0, buffer, newFileSize);
  253|      0|		if(r < 0) goto update_bin_free_buffer;
  ------------------
  |  Branch (253:6): [True: 0, False: 0]
  ------------------
  254|      0|		file->size = newFileSize;
  255|      0|update_bin_free_buffer:
  256|      0|		free(buffer);
  257|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  258|  1.28k|	} else {
  259|  1.28k|		r = msc_update_object(card, objectId, idx, buf, count);
  260|  1.28k|	}
  261|       |	/* mscfs_clear_cache(fs); */
  262|  1.28k|	return r;
  263|  1.28k|}
card-muscle.c:muscle_create_file:
  176|      3|{
  177|      3|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|      3|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  178|      3|	size_t objectSize = file->size;
  179|      3|	unsigned short read_perm = 0, write_perm = 0, delete_perm = 0;
  180|      3|	msc_id objectId;
  181|      3|	int r;
  182|      3|	if(file->type == SC_FILE_TYPE_DF)
  ------------------
  |  |  214|      3|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (182:5): [True: 3, False: 0]
  ------------------
  183|      3|		return muscle_create_directory(card, file);
  184|      0|	if(file->type != SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (184:5): [True: 0, False: 0]
  ------------------
  185|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  186|      0|	if(file->id == 0) /* No null name files */
  ------------------
  |  Branch (186:5): [True: 0, False: 0]
  ------------------
  187|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  188|       |
  189|      0|	muscle_parse_acls(file, &read_perm, &write_perm, &delete_perm);
  190|       |
  191|      0|	mscfs_lookup_local(fs, file->id, &objectId);
  192|      0|	r = msc_create_object(card, objectId, objectSize, read_perm, write_perm, delete_perm);
  193|      0|	mscfs_clear_cache(fs);
  194|      0|	if(r >= 0) return 0;
  ------------------
  |  Branch (194:5): [True: 0, False: 0]
  ------------------
  195|      0|	return r;
  196|      0|}
card-muscle.c:muscle_create_directory:
  147|      3|{
  148|      3|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|      3|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  149|      3|	msc_id objectId;
  150|      3|	u8* oid = objectId.id;
  151|      3|	unsigned id = file->id;
  152|      3|	unsigned short read_perm = 0, write_perm = 0, delete_perm = 0;
  153|      3|	size_t objectSize;
  154|      3|	int r;
  155|      3|	if(id == 0) /* No null name files */
  ------------------
  |  Branch (155:5): [True: 0, False: 3]
  ------------------
  156|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  157|       |
  158|       |	/* No nesting directories */
  159|      3|	if(fs->currentPath[0] != 0x3F || fs->currentPath[1] != 0x00)
  ------------------
  |  Branch (159:5): [True: 0, False: 3]
  |  Branch (159:35): [True: 0, False: 3]
  ------------------
  160|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  161|      3|	oid[0] = ((id & 0xFF00) >> 8) & 0xFF;
  162|      3|	oid[1] = id & 0xFF;
  163|      3|	oid[2] = oid[3] = 0;
  164|       |
  165|      3|	objectSize = file->size;
  166|       |
  167|      3|	muscle_parse_acls(file, &read_perm, &write_perm, &delete_perm);
  168|      3|	r = msc_create_object(card, objectId, objectSize, read_perm, write_perm, delete_perm);
  169|      3|	mscfs_clear_cache(fs);
  170|      3|	if(r >= 0) return 0;
  ------------------
  |  Branch (170:5): [True: 3, False: 0]
  ------------------
  171|      0|	return r;
  172|      3|}
card-muscle.c:muscle_parse_acls:
  138|      3|{
  139|      3|	if (read_perm == NULL || write_perm == NULL || delete_perm == NULL)
  ------------------
  |  Branch (139:6): [True: 0, False: 3]
  |  Branch (139:27): [True: 0, False: 3]
  |  Branch (139:49): [True: 0, False: 3]
  ------------------
  140|      0|		return;
  141|      3|	*read_perm =  muscle_parse_singleAcl(sc_file_get_acl_entry(file, SC_AC_OP_READ));
  ------------------
  |  |  188|      3|#define SC_AC_OP_READ			22
  ------------------
  142|      3|	*write_perm =  muscle_parse_singleAcl(sc_file_get_acl_entry(file, SC_AC_OP_UPDATE));
  ------------------
  |  |  189|      3|#define SC_AC_OP_UPDATE			23
  ------------------
  143|      3|	*delete_perm =  muscle_parse_singleAcl(sc_file_get_acl_entry(file, SC_AC_OP_DELETE));
  ------------------
  |  |  168|      3|#define SC_AC_OP_DELETE			2
  ------------------
  144|      3|}
card-muscle.c:muscle_parse_singleAcl:
  108|      9|{
  109|      9|	unsigned short acl_entry = 0;
  110|     18|	while(acl) {
  ------------------
  |  Branch (110:8): [True: 9, False: 9]
  ------------------
  111|      9|		int key = acl->key_ref;
  112|      9|		int method = acl->method;
  113|      9|		switch(method) {
  114|      0|		case SC_AC_NEVER:
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (114:3): [True: 0, False: 9]
  ------------------
  115|      0|			return 0xFFFF;
  116|       |		/* Ignore... other items overwrite these */
  117|      9|		case SC_AC_NONE:
  ------------------
  |  |  150|      9|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (117:3): [True: 9, False: 0]
  ------------------
  118|      9|		case SC_AC_UNKNOWN:
  ------------------
  |  |  162|      9|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  |  Branch (118:3): [True: 0, False: 9]
  ------------------
  119|      9|			break;
  120|      0|		case SC_AC_CHV:
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (120:3): [True: 0, False: 9]
  ------------------
  121|       |			/* Ignore shift with more bits that acl_entry has */
  122|      0|			if ((size_t) key < sizeof(acl_entry) * 8)
  ------------------
  |  Branch (122:8): [True: 0, False: 0]
  ------------------
  123|      0|				acl_entry |= (1u << key); /* Assuming key 0 == SO */
  124|      0|			break;
  125|      0|		case SC_AC_AUT:
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (125:3): [True: 0, False: 9]
  ------------------
  126|      0|		case SC_AC_TERM:
  ------------------
  |  |  152|      0|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (126:3): [True: 0, False: 9]
  ------------------
  127|      0|		case SC_AC_PRO:
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (127:3): [True: 0, False: 9]
  ------------------
  128|      0|		default:
  ------------------
  |  Branch (128:3): [True: 0, False: 9]
  ------------------
  129|       |			/* Ignored */
  130|      0|			break;
  131|      9|		}
  132|      9|		acl = acl->next;
  133|      9|	}
  134|      9|	return acl_entry;
  135|      9|}
card-muscle.c:muscle_select_file:
  434|  1.34k|{
  435|  1.34k|	int r;
  436|       |
  437|  1.34k|	if (card == NULL || path_in == NULL)
  ------------------
  |  Branch (437:6): [True: 0, False: 1.34k]
  |  Branch (437:22): [True: 0, False: 1.34k]
  ------------------
  438|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  439|       |
  440|  1.34k|	switch (path_in->type) {
  441|    108|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|    108|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (441:2): [True: 108, False: 1.23k]
  ------------------
  442|    108|		r = select_item(card, path_in, file_out, 1);
  443|    108|		break;
  444|     93|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|     93|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (444:2): [True: 93, False: 1.24k]
  ------------------
  445|     93|		r = select_item(card, path_in, file_out, 0);
  446|     93|		break;
  447|  1.14k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|  1.14k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (447:2): [True: 1.14k, False: 201]
  ------------------
  448|  1.14k|		r = select_item(card, path_in, file_out, -1);
  449|  1.14k|		break;
  450|      0|	default:
  ------------------
  |  Branch (450:2): [True: 0, False: 1.34k]
  ------------------
  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|  1.34k|	}
  453|  1.34k|	if(r > 0) r = 0;
  ------------------
  |  Branch (453:5): [True: 0, False: 1.34k]
  ------------------
  454|  1.34k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,r);
  ------------------
  |  |  153|  1.34k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  1.34k|	int _ret = r; \
  |  |  155|  1.34k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1.34k, False: 0]
  |  |  ------------------
  |  |  156|  1.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|    706|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 706, False: 635]
  |  |  ------------------
  |  |  157|  1.34k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  1.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|  1.34k|	return _ret; \
  |  |  163|  1.34k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  455|  1.34k|}
card-muscle.c:select_item:
  370|  1.34k|{
  371|  1.34k|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|  1.34k|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  372|  1.34k|	mscfs_file_t *file_data = NULL;
  373|  1.34k|	size_t pathlen = path_in->len;
  374|  1.34k|	int r = 0;
  375|  1.34k|	int objectIndex;
  376|  1.34k|	u8* oid;
  377|       |
  378|  1.34k|	r = mscfs_check_cache(fs);
  379|  1.34k|	if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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: 327, False: 0]
  |  |  ------------------
  |  |  156|    327|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    327|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 327, False: 0]
  |  |  ------------------
  |  |  157|    327|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    327|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    327|	return _ret; \
  |  |  163|    327|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (379:5): [True: 327, False: 1.01k]
  ------------------
  380|  1.01k|	r = mscfs_loadFileInfo(fs, path_in->value, path_in->len, &file_data, &objectIndex);
  381|  1.01k|	if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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: 376, False: 0]
  |  |  ------------------
  |  |  156|    376|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    376|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 376, False: 0]
  |  |  ------------------
  |  |  157|    376|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    376|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    376|	return _ret; \
  |  |  163|    376|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (381:5): [True: 376, False: 638]
  ------------------
  382|       |
  383|       |	/* Check if its the right type */
  384|    638|	if(requiredType >= 0 && requiredType != file_data->ef) {
  ------------------
  |  Branch (384:5): [True: 9, False: 629]
  |  Branch (384:26): [True: 2, False: 7]
  ------------------
  385|      2|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  386|      2|	}
  387|    636|	oid = file_data->objectId.id;
  388|       |	/* Is it a file or directory */
  389|    636|	if(file_data->ef) {
  ------------------
  |  Branch (389:5): [True: 265, False: 371]
  ------------------
  390|    265|		fs->currentPath[0] = oid[0];
  391|    265|		fs->currentPath[1] = oid[1];
  392|    265|		fs->currentFile[0] = oid[2];
  393|    265|		fs->currentFile[1] = oid[3];
  394|    371|	} else {
  395|    371|		if(pathlen < 2) {
  ------------------
  |  Branch (395:6): [True: 1, False: 370]
  ------------------
  396|      1|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  397|      1|		}
  398|    370|		fs->currentPath[0] = oid[pathlen - 2];
  399|    370|		fs->currentPath[1] = oid[pathlen - 1];
  400|    370|		fs->currentFile[0] = 0;
  401|    370|		fs->currentFile[1] = 0;
  402|    370|	}
  403|       |
  404|    635|	fs->currentFileIndex = objectIndex;
  405|    635|	if(file_out) {
  ------------------
  |  Branch (405:5): [True: 399, False: 236]
  ------------------
  406|    399|		sc_file_t *file;
  407|    399|		file = sc_file_new();
  408|    399|		file->path = *path_in;
  409|    399|		file->size = file_data->size;
  410|    399|		file->id = (oid[2] << 8) | oid[3];
  411|    399|		if(!file_data->ef) {
  ------------------
  |  Branch (411:6): [True: 139, False: 260]
  ------------------
  412|    139|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    139|#define SC_FILE_TYPE_DF			0x04
  ------------------
  413|    260|		} else {
  414|    260|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|    260|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  415|    260|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|    260|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  416|    260|		}
  417|       |
  418|       |		/* Setup ACLS */
  419|    399|		if(file_data->ef) {
  ------------------
  |  Branch (419:6): [True: 260, False: 139]
  ------------------
  420|    260|			muscle_load_file_acls(file, file_data);
  421|    260|		} else {
  422|    139|			muscle_load_dir_acls(file, file_data);
  423|       |			/* Setup directory acls... */
  424|    139|		}
  425|       |
  426|    399|		file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|    399|#define SC_FILE_MAGIC			0x14426950
  ------------------
  427|    399|		*file_out = file;
  428|    399|	}
  429|    635|	return 0;
  430|    636|}
card-muscle.c:muscle_load_file_acls:
  353|    260|{
  354|    260|	muscle_load_single_acl(file, SC_AC_OP_READ, file_data->read);
  ------------------
  |  |  188|    260|#define SC_AC_OP_READ			22
  ------------------
  355|    260|	muscle_load_single_acl(file, SC_AC_OP_WRITE, file_data->write);
  ------------------
  |  |  190|    260|#define SC_AC_OP_WRITE			24
  ------------------
  356|    260|	muscle_load_single_acl(file, SC_AC_OP_UPDATE, file_data->write);
  ------------------
  |  |  189|    260|#define SC_AC_OP_UPDATE			23
  ------------------
  357|    260|	muscle_load_single_acl(file, SC_AC_OP_DELETE, file_data->delete);
  ------------------
  |  |  168|    260|#define SC_AC_OP_DELETE			2
  ------------------
  358|    260|}
card-muscle.c:muscle_load_single_acl:
  338|  1.73k|{
  339|  1.73k|	int key;
  340|       |	/* Everybody by default.... */
  341|  1.73k|	sc_file_add_acl_entry(file, operation, SC_AC_NONE, 0);
  ------------------
  |  |  150|  1.73k|#define SC_AC_NONE			0x00000000
  ------------------
  342|  1.73k|	if(acl == 0xFFFF) {
  ------------------
  |  Branch (342:5): [True: 141, False: 1.59k]
  ------------------
  343|    141|		sc_file_add_acl_entry(file, operation, SC_AC_NEVER, 0);
  ------------------
  |  |  163|    141|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  344|    141|		return;
  345|    141|	}
  346|  27.0k|	for(key = 0; key < 16; key++) {
  ------------------
  |  Branch (346:15): [True: 25.5k, False: 1.59k]
  ------------------
  347|  25.5k|		if(acl >> key & 1) {
  ------------------
  |  Branch (347:6): [True: 5.81k, False: 19.6k]
  ------------------
  348|  5.81k|			sc_file_add_acl_entry(file, operation, SC_AC_CHV, key);
  ------------------
  |  |  151|  5.81k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  349|  5.81k|		}
  350|  25.5k|	}
  351|  1.59k|}
card-muscle.c:muscle_load_dir_acls:
  360|    139|{
  361|    139|	muscle_load_single_acl(file, SC_AC_OP_SELECT, 0);
  ------------------
  |  |  166|    139|#define SC_AC_OP_SELECT			0
  ------------------
  362|    139|	muscle_load_single_acl(file, SC_AC_OP_LIST_FILES, 0);
  ------------------
  |  |  172|    139|#define SC_AC_OP_LIST_FILES		6
  ------------------
  363|    139|	muscle_load_single_acl(file, SC_AC_OP_LOCK, 0xFFFF);
  ------------------
  |  |  167|    139|#define SC_AC_OP_LOCK			1
  ------------------
  364|    139|	muscle_load_single_acl(file, SC_AC_OP_DELETE, file_data->delete);
  ------------------
  |  |  168|    139|#define SC_AC_OP_DELETE			2
  ------------------
  365|    139|	muscle_load_single_acl(file, SC_AC_OP_CREATE, file_data->write);
  ------------------
  |  |  169|    139|#define SC_AC_OP_CREATE			3
  ------------------
  366|    139|}
card-muscle.c:muscle_delete_file:
  320|     89|{
  321|     89|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|     89|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  322|     89|	mscfs_file_t *file_data = NULL;
  323|     89|	int r = 0;
  324|       |
  325|     89|	r = mscfs_loadFileInfo(fs, path_in->value, path_in->len, &file_data, NULL);
  326|     89|	if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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]
  |  |  ------------------
  ------------------
  |  Branch (326:5): [True: 5, False: 84]
  ------------------
  327|   113k|	for(int x = 0; x < fs->cache.size; x++) {
  ------------------
  |  Branch (327:17): [True: 113k, False: 84]
  ------------------
  328|   113k|		mscfs_file_t *file = &fs->cache.array[x];
  329|   113k|		file->deleteFile = 0;
  330|   113k|	}
  331|     84|	r = muscle_delete_mscfs_file(card, file_data);
  332|     84|	mscfs_clear_cache(fs);
  333|     84|	if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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]
  |  |  ------------------
  ------------------
  |  Branch (333:5): [True: 4, False: 80]
  ------------------
  334|     80|	return 0;
  335|     84|}
card-muscle.c:muscle_delete_mscfs_file:
  267|   102k|{
  268|   102k|	mscfs_t *fs = MUSCLE_FS(card);
  ------------------
  |  |   58|   102k|#define MUSCLE_FS(card) ( ((muscle_private_t*)card->drv_data)->fs )
  ------------------
  269|   102k|	msc_id id = file_data->objectId;
  270|   102k|	u8* oid = id.id;
  271|   102k|	int r;
  272|   102k|	file_data->deleteFile = 1;
  273|       |
  274|   102k|	if(!file_data->ef) {
  ------------------
  |  Branch (274:5): [True: 98.7k, False: 4.17k]
  ------------------
  275|  98.7k|		int x;
  276|  98.7k|		mscfs_file_t *childFile;
  277|       |		/* Delete children */
  278|  98.7k|		r = mscfs_check_cache(fs);
  279|  98.7k|		if(r < 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]
  |  |  ------------------
  ------------------
  |  Branch (279:6): [True: 0, False: 98.7k]
  ------------------
  280|       |
  281|  98.7k|		sc_log(card->ctx,
  ------------------
  |  |   71|  98.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__
  |  |  ------------------
  ------------------
  282|  98.7k|			"DELETING Children of: %02X%02X%02X%02X\n",
  283|  98.7k|			oid[0],oid[1],oid[2],oid[3]);
  284|   492M|		for(x = 0; x < fs->cache.size; x++) {
  ------------------
  |  Branch (284:14): [True: 492M, False: 98.5k]
  ------------------
  285|   492M|			msc_id objectId;
  286|   492M|			childFile = &fs->cache.array[x];
  287|   492M|			objectId = childFile->objectId;
  288|       |
  289|   492M|			if(0 == memcmp(oid + 2, objectId.id, 2) && !childFile->deleteFile) {
  ------------------
  |  Branch (289:7): [True: 435M, False: 56.8M]
  |  Branch (289:47): [True: 102k, False: 435M]
  ------------------
  290|   102k|				sc_log(card->ctx,
  ------------------
  |  |   71|   102k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  291|   102k|					"DELETING: %02X%02X%02X%02X\n",
  292|   102k|					objectId.id[0],objectId.id[1],
  293|   102k|					objectId.id[2],objectId.id[3]);
  294|   102k|				r = muscle_delete_mscfs_file(card, childFile);
  295|   102k|				if(r < 0) SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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|    201|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 201, False: 0]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  |  Branch (295:8): [True: 201, False: 102k]
  ------------------
  296|       |
  297|   102k|			}
  298|   492M|		}
  299|  98.5k|		oid[0] = oid[2];
  300|  98.5k|		oid[1] = oid[3];
  301|  98.5k|		oid[2] = oid[3] = 0;
  302|       |		/* ??? objectId = objectId >> 16; */
  303|  98.5k|	}
  304|   102k|	r = msc_delete_object(card, id, 1);
  305|       |	/* Check if its the root... this file generally is virtual
  306|       |	 * So don't return an error if it fails */
  307|   102k|	if((0 == memcmp(oid, "\x3F\x00\x00\x00", 4))
  ------------------
  |  Branch (307:5): [True: 96.3k, False: 6.35k]
  ------------------
  308|  6.35k|		|| (0 == memcmp(oid, "\x3F\x00\x3F\x00", 4)))
  ------------------
  |  Branch (308:6): [True: 59, False: 6.29k]
  ------------------
  309|  96.3k|		return 0;
  310|       |
  311|  6.29k|	if(r < 0) {
  ------------------
  |  Branch (311:5): [True: 4, False: 6.29k]
  ------------------
  312|      4|		printf("ID: %02X%02X%02X%02X\n",
  313|      4|					oid[0],oid[1],oid[2],oid[3]);
  314|      4|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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]
  |  |  ------------------
  ------------------
  315|      4|	}
  316|  6.29k|	return 0;
  317|  6.29k|}
card-muscle.c:muscle_card_reader_lock_obtained:
  842|   208k|{
  843|   208k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|   208k|#define SC_SUCCESS				0
  ------------------
  844|       |
  845|   208k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|   208k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|   208k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|   208k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 208k]
  |  |  ------------------
  ------------------
  846|       |
  847|   208k|	if (was_reset > 0) {
  ------------------
  |  Branch (847:6): [True: 0, False: 208k]
  ------------------
  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|   208k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|   208k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   208k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   208k|	int _ret = r; \
  |  |  |  |  155|   208k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 208k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   208k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 208k]
  |  |  |  |  ------------------
  |  |  |  |  157|   208k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   208k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|   208k|	return _ret; \
  |  |  |  |  163|   208k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  854|   208k|}

sc_get_myeid_driver:
 2145|  3.69k|{
 2146|  3.69k|	return sc_get_driver();
 2147|  3.69k|}
card-myeid.c:sc_get_driver:
 2110|  3.69k|{
 2111|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2112|       |
 2113|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2113:6): [True: 1, False: 3.69k]
  ------------------
 2114|      1|		iso_ops = iso_drv->ops;
 2115|       |
 2116|  3.69k|	myeid_ops			= *iso_drv->ops;
 2117|  3.69k|	myeid_ops.match_card		= myeid_match_card;
 2118|  3.69k|	myeid_ops.init			= myeid_init;
 2119|  3.69k|	myeid_ops.finish		= myeid_finish;
 2120|       |	/* no record oriented file services */
 2121|  3.69k|	myeid_ops.read_record		= NULL;
 2122|  3.69k|	myeid_ops.write_record		= NULL;
 2123|  3.69k|	myeid_ops.append_record		= NULL;
 2124|       |	myeid_ops.update_record		= NULL;
 2125|  3.69k|	myeid_ops.select_file		= myeid_select_file;
 2126|  3.69k|	myeid_ops.get_response		= iso_ops->get_response;
 2127|  3.69k|	myeid_ops.logout		= myeid_logout;
 2128|  3.69k|	myeid_ops.create_file		= myeid_create_file;
 2129|  3.69k|	myeid_ops.delete_file		= myeid_delete_file;
 2130|  3.69k|	myeid_ops.list_files		= myeid_list_files;
 2131|  3.69k|	myeid_ops.set_security_env	= myeid_set_security_env;
 2132|  3.69k|	myeid_ops.compute_signature	= myeid_compute_signature;
 2133|  3.69k|	myeid_ops.decipher		= myeid_decipher;
 2134|  3.69k|	myeid_ops.process_fci		= myeid_process_fci;
 2135|  3.69k|	myeid_ops.card_ctl		= myeid_card_ctl;
 2136|  3.69k|	myeid_ops.pin_cmd		= myeid_pin_cmd;
 2137|  3.69k|	myeid_ops.wrap			= myeid_wrap_key;
 2138|  3.69k|	myeid_ops.unwrap		= myeid_unwrap_key;
 2139|  3.69k|	myeid_ops.encrypt_sym		= myeid_encrypt_sym;
 2140|  3.69k|	myeid_ops.decrypt_sym		= myeid_decrypt_sym;
 2141|  3.69k|	return &myeid_drv;
 2142|  3.69k|}
card-myeid.c:myeid_match_card:
  122|  2.27k|{
  123|  2.27k|	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|  2.27k|	if (len >= 5) {
  ------------------
  |  Branch (126:6): [True: 1.27k, False: 1.00k]
  ------------------
  127|  1.27k|		if (!memcmp(&card->reader->atr_info.hist_bytes[len - 5], "MyEID", 5)) {
  ------------------
  |  Branch (127:7): [True: 828, False: 444]
  ------------------
  128|    828|			sc_log(card->ctx, "Matched MyEID card");
  ------------------
  |  |   71|    828|#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|    828|			card->type = SC_CARD_TYPE_MYEID_GENERIC;
  130|    828|			return 1;
  131|    828|		}
  132|       |		/* The software implementation of MyEID is identified by OsEID bytes */
  133|    444|		if (!memcmp(&card->reader->atr_info.hist_bytes[len - 5], "OsEID", 5)) {
  ------------------
  |  Branch (133:7): [True: 4, False: 440]
  ------------------
  134|      4|			sc_log(card->ctx, "Matched OsEID card");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  135|      4|			card->type = SC_CARD_TYPE_MYEID_OSEID;
  136|      4|			return 1;
  137|      4|		}
  138|    444|	}
  139|  1.44k|	return 0;
  140|  2.27k|}
card-myeid.c:myeid_init:
  171|    832|{
  172|    832|	unsigned long flags = 0, ext_flags = 0;
  173|    832|	myeid_private_data_t *priv;
  174|    832|	u8 appletInfo[20];
  175|    832|	size_t appletInfoLen;
  176|    832|	myeid_card_caps_t card_caps;
  177|    832|	static struct sc_aid myeid_aid = { "\xA0\x00\x00\x00\x63\x50\x4B\x43\x53\x2D\x31\x35", 0x0C };
  178|    832|	int rv = 0;
  179|    832|	void *old_drv_data = card->drv_data;
  180|       |
  181|    832|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    832|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    832|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    832|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    832|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 832]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|       |
  183|    832|	switch (card->type) {
  184|      4|	case SC_CARD_TYPE_MYEID_OSEID:
  ------------------
  |  Branch (184:2): [True: 4, False: 828]
  ------------------
  185|      4|		card->name = oseid_card_name;
  186|      4|		break;
  187|    828|	case SC_CARD_TYPE_MYEID_GENERIC:
  ------------------
  |  Branch (187:2): [True: 828, False: 4]
  ------------------
  188|    828|		card->name = myeid_card_name;
  189|    828|		break;
  190|      0|	default:
  ------------------
  |  Branch (190:2): [True: 0, False: 832]
  ------------------
  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|    832|	}
  193|       |
  194|    832|	priv = calloc(1, sizeof(myeid_private_data_t));
  195|       |
  196|    832|	if (!priv)
  ------------------
  |  Branch (196:6): [True: 0, False: 832]
  ------------------
  197|    832|		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|    832|	rv = myeid_load_options (card->ctx, priv);
  200|    832|	LOG_TEST_GOTO_ERR(card->ctx, rv, "Unable to read options from opensc.conf");
  ------------------
  |  |  184|    832|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    832|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    832|	int _ret = (r); \
  |  |  |  |  178|    832|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 832]
  |  |  |  |  ------------------
  |  |  |  |  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|    832|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 832]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|       |
  202|    832|	priv->card_state = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|    832|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  203|    832|	card->drv_data = priv;
  204|       |
  205|       |	/* Ensure that the MyEID applet is selected. */
  206|    832|	rv = iso7816_select_aid(card, myeid_aid.value, myeid_aid.len, NULL, NULL);
  207|    832|	LOG_TEST_GOTO_ERR(card->ctx, rv, "Failed to select MyEID applet.");
  ------------------
  |  |  184|    832|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    832|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    832|	int _ret = (r); \
  |  |  |  |  178|    832|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 2, False: 830]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      2|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      2|		goto err; \
  |  |  |  |  182|      2|	} \
  |  |  |  |  183|    832|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 830]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  208|       |
  209|       |	/* find out MyEID version */
  210|       |
  211|    830|	appletInfoLen = 20;
  212|       |
  213|    830|	if (0 > myeid_get_info(card, appletInfo, appletInfoLen))
  ------------------
  |  Branch (213:6): [True: 331, False: 499]
  ------------------
  214|    830|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_CARD, "Failed to get MyEID applet information.");
  ------------------
  |  |  184|    331|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    331|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    331|	int _ret = (r); \
  |  |  |  |  178|    331|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 331, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    331|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    331|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    331|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    331|		goto err; \
  |  |  |  |  182|    331|	} \
  |  |  |  |  183|    331|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|       |
  216|    499|	priv->change_counter = appletInfo[19] | appletInfo[18] << 8;
  217|       |
  218|    499|	memset(&card_caps, 0, sizeof(myeid_card_caps_t));
  219|    499|	card_caps.max_ecc_key_length = 256;
  220|    499|	card_caps.max_rsa_key_length = 2048;
  221|       |
  222|    499|	if (card->version.fw_major >= 40) {
  ------------------
  |  Branch (222:6): [True: 480, False: 19]
  ------------------
  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|    480|	    if (myeid_get_card_caps(card, &card_caps) != SC_SUCCESS) {
  ------------------
  |  |   28|    480|#define SC_SUCCESS				0
  ------------------
  |  Branch (225:10): [True: 185, False: 295]
  ------------------
  226|    185|			sc_log(card->ctx, "Failed to get card capabilities. Using default max ECC key length 256.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  227|    185|	    }
  228|    480|	}
  229|       |
  230|    499|	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  111|    499|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    499|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  231|    499|	if (priv->disable_hw_pkcs1_padding == 0)
  ------------------
  |  Branch (231:6): [True: 499, False: 0]
  ------------------
  232|    499|		flags |= SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  120|    499|#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) */
  |  |  ------------------
  |  |  |  |  118|    499|#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) */
  |  |  ------------------
  |  |  |  |  119|    499|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  233|    499|	flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  142|    499|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  234|       |
  235|    499|	_sc_card_add_rsa_alg(card,  512, flags, 0);
  236|    499|	_sc_card_add_rsa_alg(card,  768, flags, 0);
  237|    499|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
  238|    499|	_sc_card_add_rsa_alg(card, 1536, flags, 0);
  239|    499|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
  240|       |
  241|    499|	if (card_caps.card_supported_features & MYEID_CARD_CAP_RSA) {
  ------------------
  |  |   50|    499|#define MYEID_CARD_CAP_RSA		0x01
  ------------------
  |  Branch (241:6): [True: 282, False: 217]
  ------------------
  242|    282|		if (card_caps.max_rsa_key_length >= 3072)
  ------------------
  |  Branch (242:7): [True: 235, False: 47]
  ------------------
  243|    235|			_sc_card_add_rsa_alg(card, 3072, flags, 0);
  244|    282|		if (card_caps.max_rsa_key_length >= 4096)
  ------------------
  |  Branch (244:7): [True: 235, False: 47]
  ------------------
  245|    235|			_sc_card_add_rsa_alg(card, 4096, flags, 0);
  246|    282|	}
  247|       |
  248|       |	/* show ECC algorithms if the applet version of the inserted card supports them */
  249|    499|	if (card->version.fw_major >= 35) {
  ------------------
  |  Branch (249:6): [True: 487, False: 12]
  ------------------
  250|    487|		int i;
  251|       |
  252|    487|		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  183|    487|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  182|    487|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    487|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  253|    487|		flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  184|    487|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|    487|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  254|    487|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  210|    487|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  211|    487|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
  255|       |
  256|  2.43k|		for (i=0; ec_curves[i].curve_name != NULL; i++) {
  ------------------
  |  Branch (256:13): [True: 1.94k, False: 487]
  ------------------
  257|  1.94k|			if (card_caps.max_ecc_key_length >= ec_curves[i].size)
  ------------------
  |  Branch (257:8): [True: 1.55k, False: 398]
  ------------------
  258|  1.55k|				_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].curve_oid);
  259|  1.94k|		}
  260|    487|	}
  261|       |
  262|       |	/* show supported symmetric algorithms */
  263|    499|	flags = 0;
  264|    499|	if (card_caps.card_supported_features & MYEID_CARD_CAP_3DES) {
  ------------------
  |  |   51|    499|#define MYEID_CARD_CAP_3DES		0x02
  ------------------
  |  Branch (264:6): [True: 281, False: 218]
  ------------------
  265|    281|		if (card_caps.max_des_key_length >= 64)
  ------------------
  |  Branch (265:7): [True: 265, False: 16]
  ------------------
  266|    265|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_DES, 64, flags);
  ------------------
  |  |   85|    265|#define SC_ALGORITHM_DES		64
  ------------------
  267|    281|		if (card_caps.max_des_key_length >= 128)
  ------------------
  |  Branch (267:7): [True: 264, False: 17]
  ------------------
  268|    264|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_3DES, 128, flags);
  ------------------
  |  |   86|    264|#define SC_ALGORITHM_3DES		65
  ------------------
  269|    281|		if (card_caps.max_des_key_length >= 192)
  ------------------
  |  Branch (269:7): [True: 240, False: 41]
  ------------------
  270|    240|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_3DES, 192, flags);
  ------------------
  |  |   86|    240|#define SC_ALGORITHM_3DES		65
  ------------------
  271|    281|	}
  272|    499|	if (card_caps.card_supported_features & MYEID_CARD_CAP_AES) {
  ------------------
  |  |   52|    499|#define MYEID_CARD_CAP_AES		0x04
  ------------------
  |  Branch (272:6): [True: 282, False: 217]
  ------------------
  273|    282|		if (card_caps.max_aes_key_length >= 128)
  ------------------
  |  Branch (273:7): [True: 282, False: 0]
  ------------------
  274|    282|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_AES, 128, flags);
  ------------------
  |  |   88|    282|#define SC_ALGORITHM_AES		67
  ------------------
  275|    282|		if (card_caps.max_aes_key_length >= 256)
  ------------------
  |  Branch (275:7): [True: 282, False: 0]
  ------------------
  276|    282|			_sc_card_add_symmetric_alg(card, SC_ALGORITHM_AES, 256, flags);
  ------------------
  |  |   88|    282|#define SC_ALGORITHM_AES		67
  ------------------
  277|    282|	}
  278|       |
  279|       |	/* State that we have an RNG */
  280|    499|	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  557|    499|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG | SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|    499|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  281|       |
  282|    499|	if ((card->version.fw_major == 40 && card->version.fw_minor >= 10 )
  ------------------
  |  Branch (282:7): [True: 0, False: 499]
  |  Branch (282:39): [True: 0, False: 0]
  ------------------
  283|    499|		|| card->version.fw_major >= 41)
  ------------------
  |  Branch (283:6): [True: 480, False: 19]
  ------------------
  284|    480|		card->caps |= SC_CARD_CAP_WRAP_KEY | SC_CARD_CAP_UNWRAP_KEY
  ------------------
  |  |  579|    480|#define SC_CARD_CAP_WRAP_KEY			0x00000800
  ------------------
              		card->caps |= SC_CARD_CAP_WRAP_KEY | SC_CARD_CAP_UNWRAP_KEY
  ------------------
  |  |  581|    480|#define SC_CARD_CAP_UNWRAP_KEY			0x00001000
  ------------------
  285|    480|			   | SC_CARD_CAP_ONCARD_SESSION_OBJECTS;
  ------------------
  |  |  576|    480|#define SC_CARD_CAP_ONCARD_SESSION_OBJECTS	0x00000400
  ------------------
  286|       |
  287|    499|	if (card->version.fw_major >= 45)
  ------------------
  |  Branch (287:6): [True: 480, False: 19]
  ------------------
  288|    480|		priv->cap_chaining = 1;
  289|    499|	if (card->version.fw_major >= 40)
  ------------------
  |  Branch (289:6): [True: 480, False: 19]
  ------------------
  290|    480|		card->max_recv_size = 256;
  291|     19|	else
  292|     19|		card->max_recv_size = 255;
  293|    499|	card->max_send_size = 255;
  294|       |
  295|    499|	rv = SC_SUCCESS;
  ------------------
  |  |   28|    499|#define SC_SUCCESS				0
  ------------------
  296|       |
  297|    832|err:
  298|    832|	if (rv < 0) {
  ------------------
  |  Branch (298:6): [True: 2, False: 830]
  ------------------
  299|      2|		free(priv);
  300|      2|		card->drv_data = old_drv_data;
  301|      2|	}
  302|       |
  303|    832|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    832|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    832|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    832|	int _ret = r; \
  |  |  |  |  155|    832|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 832, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    832|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 830]
  |  |  |  |  ------------------
  |  |  |  |  157|    832|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    832|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    832|	return _ret; \
  |  |  |  |  163|    832|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  304|    832|}
card-myeid.c:myeid_load_options:
  143|    832|{
  144|    832|	int r;
  145|    832|	size_t i, j;
  146|    832|	scconf_block **found_blocks, *block;
  147|       |
  148|    832|	if (!ctx || !priv) {
  ------------------
  |  Branch (148:6): [True: 0, False: 832]
  |  Branch (148:14): [True: 0, False: 832]
  ------------------
  149|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  150|      0|		goto err;
  151|      0|	}
  152|    832|	priv->disable_hw_pkcs1_padding = 0;
  153|  1.66k|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (153:14): [True: 832, False: 832]
  ------------------
  154|    832|		found_blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  155|    832|				"card_driver", "myeid");
  156|    832|		if (!found_blocks)
  ------------------
  |  Branch (156:7): [True: 0, False: 832]
  ------------------
  157|      0|			continue;
  158|    832|		for (j = 0, block = found_blocks[j]; block; j++, block = found_blocks[j]) {
  ------------------
  |  Branch (158:40): [True: 0, False: 832]
  ------------------
  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|    832|		free(found_blocks);
  163|    832|	}
  164|    832|	r = SC_SUCCESS;
  ------------------
  |  |   28|    832|#define SC_SUCCESS				0
  ------------------
  165|       |
  166|    832|err:
  167|    832|	return r;
  168|    832|}
card-myeid.c:myeid_get_info:
 1702|  62.0k|{
 1703|  62.0k|	sc_apdu_t apdu;
 1704|  62.0k|	int r;
 1705|       |
 1706|  62.0k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  62.0k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  62.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  62.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  62.0k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 62.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1707|       |
 1708|  62.0k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0xA0);
  ------------------
  |  |  292|  62.0k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1709|  62.0k|	apdu.resp    = rbuf;
 1710|  62.0k|	apdu.resplen = buflen;
 1711|  62.0k|	apdu.le      = buflen;
 1712|       |
 1713|  62.0k|	r = sc_transmit_apdu(card, &apdu);
 1714|  62.0k|	LOG_TEST_RET(card->ctx, r,  "APDU transmit failed");
  ------------------
  |  |  174|  62.0k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  62.0k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  62.0k|	int _ret = (r); \
  |  |  |  |  168|  62.0k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.18k, False: 60.8k]
  |  |  |  |  ------------------
  |  |  |  |  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|  62.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 60.8k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1715|       |
 1716|  60.8k|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1716:6): [True: 54.7k, False: 6.12k]
  |  Branch (1716:26): [True: 347, False: 5.77k]
  ------------------
 1717|  55.0k|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  55.0k|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1718|       |
 1719|  5.77k|	if (apdu.resplen != 20)
  ------------------
  |  Branch (1719:6): [True: 4.16k, False: 1.60k]
  ------------------
 1720|  4.16k|	{
 1721|  4.16k|		sc_log(card->ctx, "Unexpected response to GET DATA (applet info)");
  ------------------
  |  |   71|  4.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__
  |  |  ------------------
  ------------------
 1722|  4.16k|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|  4.16k|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1723|  4.16k|	}
 1724|       |
 1725|       |	/* store the applet version */
 1726|  1.60k|	card->version.fw_major = rbuf[5] * 10 + rbuf[6];
 1727|  1.60k|	card->version.fw_minor = rbuf[7];
 1728|       |	/* add version to name */
 1729|  1.60k|	snprintf(card_name_buf, sizeof(card_name_buf),
 1730|  1.60k|			"%s %d.%d.%d", card->name, rbuf[5], rbuf[6], rbuf[7]);
 1731|  1.60k|	card->name = card_name_buf;
 1732|       |
 1733|  1.60k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.60k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.60k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.60k|	int _ret = r; \
  |  |  |  |  155|  1.60k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.60k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.60k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.60k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.60k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.60k|	} else { \
  |  |  |  |  159|      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.60k|	return _ret; \
  |  |  |  |  163|  1.60k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1734|  1.60k|}
card-myeid.c:myeid_get_card_caps:
 1785|    480|{
 1786|    480|	sc_apdu_t apdu;
 1787|    480|	int r;
 1788|    480|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1789|       |
 1790|    480|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    480|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1791|       |
 1792|    480|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0xAA);
  ------------------
  |  |  292|    480|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1793|    480|	apdu.resp    = rbuf;
 1794|    480|	apdu.resplen = sizeof(myeid_card_caps_t);
 1795|    480|	apdu.le      = sizeof(myeid_card_caps_t);
 1796|       |
 1797|    480|	r = sc_transmit_apdu(card, &apdu);
 1798|    480|	LOG_TEST_RET(card->ctx, r,  "APDU transmit failed");
  ------------------
  |  |  174|    480|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    480|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    480|	int _ret = (r); \
  |  |  |  |  168|    480|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 480]
  |  |  |  |  ------------------
  |  |  |  |  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|    480|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 480]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1799|       |
 1800|    480|	if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1800:6): [True: 59, False: 421]
  |  Branch (1800:26): [True: 32, False: 389]
  ------------------
 1801|     91|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     91|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1802|       |
 1803|    389|	if (apdu.resplen < 11) {
  ------------------
  |  Branch (1803:6): [True: 94, False: 295]
  ------------------
 1804|     94|		sc_log(card->ctx, "Unexpected response to GET DATA (MyEIC card capabilities)");
  ------------------
  |  |   71|     94|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1805|     94|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     94|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1806|     94|	}
 1807|       |
 1808|    295|	card_caps->card_caps_ver = rbuf[0];
 1809|       |	/* the card returns big endian values */
 1810|    295|	card_caps->card_supported_features = (unsigned short) rbuf[1] << 8 | rbuf[2];
 1811|    295|	card_caps->max_rsa_key_length = (unsigned short) rbuf[3] << 8 | rbuf[4];
 1812|    295|	card_caps->max_des_key_length = (unsigned short) rbuf[5] << 8 | rbuf[6];
 1813|    295|	card_caps->max_aes_key_length = (unsigned short) rbuf[7] << 8 | rbuf[8];
 1814|    295|	card_caps->max_ecc_key_length = (unsigned short) rbuf[9] << 8 | rbuf[10];
 1815|       |
 1816|    295|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1817|    295|}
card-myeid.c:myeid_finish:
 1855|    830|{
 1856|    830|	struct myeid_private_data *priv = (struct myeid_private_data *) card->drv_data;
 1857|    830|	free(priv);
 1858|    830|	return SC_SUCCESS;
  ------------------
  |  |   28|    830|#define SC_SUCCESS				0
  ------------------
 1859|    830|}
card-myeid.c:myeid_select_file:
  392|   114k|{
  393|   114k|	int r;
  394|       |
  395|   114k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|   114k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   114k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   114k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   114k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 114k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  396|   114k|	r = iso_ops->select_file(card, in_path, file);
  397|       |
  398|   114k|	if (r == 0 && file != NULL && *file != NULL)
  ------------------
  |  Branch (398:6): [True: 13.9k, False: 100k]
  |  Branch (398:16): [True: 11.0k, False: 2.90k]
  |  Branch (398:32): [True: 11.0k, False: 0]
  ------------------
  399|  11.0k|		parse_sec_attr(*file, (*file)->sec_attr, (*file)->sec_attr_len);
  400|       |
  401|   114k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|   114k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   114k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   114k|	int _ret = r; \
  |  |  |  |  155|   114k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 114k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   114k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|   100k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 100k, False: 13.9k]
  |  |  |  |  ------------------
  |  |  |  |  157|   114k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   114k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|   114k|	return _ret; \
  |  |  |  |  163|   114k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  402|   114k|}
card-myeid.c:parse_sec_attr:
  350|  11.0k|{
  351|  11.0k|	int i;
  352|  11.0k|	const int df_ops[4] =
  353|  11.0k|		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  169|  11.0k|#define SC_AC_OP_CREATE			3
  ------------------
              		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  169|  11.0k|#define SC_AC_OP_CREATE			3
  ------------------
              		{ SC_AC_OP_CREATE, SC_AC_OP_CREATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  168|  11.0k|#define SC_AC_OP_DELETE			2
  ------------------
  354|  11.0k|	const int ef_ops[4] =
  355|  11.0k|		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  188|  11.0k|#define SC_AC_OP_READ			22
  ------------------
              		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  189|  11.0k|#define SC_AC_OP_UPDATE			23
  ------------------
              		{ SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, -1 };
  ------------------
  |  |  168|  11.0k|#define SC_AC_OP_DELETE			2
  ------------------
  356|  11.0k|	const int key_ops[4] =
  357|  11.0k|		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  173|  11.0k|#define SC_AC_OP_CRYPTO			7
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  189|  11.0k|#define SC_AC_OP_UPDATE			23
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  168|  11.0k|#define SC_AC_OP_DELETE			2
  ------------------
              		{ SC_AC_OP_CRYPTO, SC_AC_OP_UPDATE, SC_AC_OP_DELETE, SC_AC_OP_GENERATE };
  ------------------
  |  |  192|  11.0k|#define SC_AC_OP_GENERATE		26
  ------------------
  358|       |
  359|  11.0k|	const int *ops;
  360|       |
  361|  11.0k|	if (len < 2)
  ------------------
  |  Branch (361:6): [True: 4.10k, False: 6.92k]
  ------------------
  362|  4.10k|		return;
  363|       |
  364|  6.92k|	switch (file->type) {
  365|  3.12k|	case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|  3.12k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (365:2): [True: 3.12k, False: 3.80k]
  ------------------
  366|  3.12k|		ops = ef_ops;
  367|  3.12k|		break;
  368|     93|	case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|     93|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (368:2): [True: 93, False: 6.83k]
  ------------------
  369|     93|		ops = key_ops;
  370|     93|		break;
  371|  2.36k|	case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|  2.36k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (371:2): [True: 2.36k, False: 4.56k]
  ------------------
  372|  2.36k|		ops = df_ops;
  373|  2.36k|		break;
  374|  1.35k|	default:
  ------------------
  |  Branch (374:2): [True: 1.35k, False: 5.57k]
  ------------------
  375|  1.35k|		ops = key_ops;
  376|  1.35k|		break;
  377|  6.92k|	}
  378|       |
  379|  34.6k|	for (i = 0; i < 4; i++)
  ------------------
  |  Branch (379:14): [True: 27.6k, False: 6.92k]
  ------------------
  380|  27.6k|	{
  381|  27.6k|		if (ops[i] == -1)
  ------------------
  |  Branch (381:7): [True: 5.48k, False: 22.2k]
  ------------------
  382|  5.48k|			continue;
  383|  22.2k|		if ((i & 1) == 0)
  ------------------
  |  Branch (383:7): [True: 13.8k, False: 8.36k]
  ------------------
  384|  13.8k|			add_acl_entry(file, ops[i], (u8)(buf[i / 2] >> 4));
  385|  8.36k|		else
  386|  8.36k|			add_acl_entry(file, ops[i], (u8)(buf[i / 2] & 0x0F));
  387|  22.2k|	}
  388|  6.92k|}
card-myeid.c:add_acl_entry:
  330|  22.2k|{
  331|  22.2k|	unsigned int method, key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  22.2k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  332|       |
  333|  22.2k|	switch (byte)
  334|  22.2k|	{
  335|  4.86k|	case 0:
  ------------------
  |  Branch (335:2): [True: 4.86k, False: 17.3k]
  ------------------
  336|  4.86k|		method = SC_AC_NONE;
  ------------------
  |  |  150|  4.86k|#define SC_AC_NONE			0x00000000
  ------------------
  337|  4.86k|		break;
  338|    982|	case 15:
  ------------------
  |  Branch (338:2): [True: 982, False: 21.2k]
  ------------------
  339|    982|		method = SC_AC_NEVER;
  ------------------
  |  |  163|    982|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  340|    982|		break;
  341|  16.3k|	default:
  ------------------
  |  Branch (341:2): [True: 16.3k, False: 5.84k]
  ------------------
  342|  16.3k|		method = SC_AC_CHV;
  ------------------
  |  |  151|  16.3k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  343|  16.3k|		key_ref = byte;
  344|  16.3k|		break;
  345|  22.2k|	}
  346|  22.2k|	sc_file_add_acl_entry(file, op, method, key_ref);
  347|  22.2k|}
card-myeid.c:myeid_create_file:
  617|  1.60k|{
  618|  1.60k|	sc_apdu_t apdu;
  619|  1.60k|	u8 sbuf[45];
  620|  1.60k|	size_t buflen = sizeof sbuf;
  621|  1.60k|	int r;
  622|       |
  623|  1.60k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.60k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.60k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.60k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.60k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.60k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  624|       |
  625|  1.60k|	r = encode_file_structure(card, file, sbuf, &buflen);
  626|  1.60k|	if (r)
  ------------------
  |  Branch (626:6): [True: 5, False: 1.60k]
  ------------------
  627|  1.60k|	  LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  628|       |
  629|  1.60k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|  1.60k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  630|  1.60k|	apdu.data = sbuf;
  631|  1.60k|	apdu.datalen = buflen;
  632|  1.60k|	apdu.lc = buflen;
  633|       |
  634|  1.60k|	r = sc_transmit_apdu(card, &apdu);
  635|  1.60k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.60k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.60k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.60k|	int _ret = (r); \
  |  |  |  |  168|  1.60k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 1.60k]
  |  |  |  |  ------------------
  |  |  |  |  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.60k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.60k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|  1.60k|	if (apdu.sw1 == 0x6A && apdu.sw2 == 0x89)
  ------------------
  |  Branch (636:6): [True: 14, False: 1.58k]
  |  Branch (636:26): [True: 0, False: 14]
  ------------------
  637|  1.60k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_FILE_ALREADY_EXISTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_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|       |
  639|  1.60k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  640|  1.60k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.60k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.60k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.60k|	int _ret = r; \
  |  |  |  |  155|  1.60k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.60k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.60k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 1.52k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.60k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.60k|	} else { \
  |  |  |  |  159|      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.60k|	return _ret; \
  |  |  |  |  163|  1.60k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  641|  1.60k|}
card-myeid.c:encode_file_structure:
  485|  1.60k|{
  486|  1.60k|	const sc_acl_entry_t *read, *update, *delete, *generate;
  487|  1.60k|	size_t i;
  488|       |
  489|  1.60k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.60k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.60k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.60k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.60k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.60k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  490|       |
  491|  1.60k|	if (!buf || !outlen || *outlen < 45)
  ------------------
  |  Branch (491:6): [True: 0, False: 1.60k]
  |  Branch (491:14): [True: 0, False: 1.60k]
  |  Branch (491:25): [True: 0, False: 1.60k]
  ------------------
  492|  1.60k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  493|       |
  494|       |	/* PrivateKey
  495|       |	 * 0E0000019 6217 81020400 820111 83024B01 8603000000 85028000 8A0100 RESULT 6984
  496|       |	 *	   6217 81020400 820111 83024B01 8603000000 85021000 8A0100 */
  497|  1.60k|	memset(buf, 0x0, *outlen);
  498|       |
  499|  1.60k|	buf[0] = 0x62;
  500|  1.60k|	buf[1] = 0x17;
  501|       |	/* File size */
  502|  1.60k|	buf[2] = (SC_FILE_TYPE_WORKING_EF == file->type ? 0x80 : 0x81);
  ------------------
  |  |  216|  1.60k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (502:12): [True: 1.30k, False: 305]
  ------------------
  503|  1.60k|	buf[3] = 0x02;
  504|  1.60k|	buf[4] = (file->size >> 8) & 0xFF;
  505|  1.60k|	buf[5] = file->size & 0xFF;
  506|       |
  507|       |	/* File Description tag */
  508|  1.60k|	buf[6] = 0x82;
  509|  1.60k|	buf[7] = 0x01;
  510|  1.60k|	buf[8] = 0x01;
  511|       |
  512|       |	/* File Identifier tag */
  513|  1.60k|	buf[9]  = 0x83;
  514|  1.60k|	buf[10] = 0x02;
  515|  1.60k|	buf[11] = (file->id >> 8) & 0xFF;
  516|  1.60k|	buf[12] = file->id & 0xFF;
  517|       |
  518|       |	/* Security Attributes Tag */
  519|  1.60k|	buf[13] = 0x86;
  520|  1.60k|	buf[14] = 0x03;
  521|  1.60k|	buf[15] = 0xFF;
  522|  1.60k|	buf[16] = 0xFF;
  523|  1.60k|	buf[17] = 0xFF;
  524|       |
  525|  1.60k|	if (file->sec_attr_len == 3 && file->sec_attr)   {
  ------------------
  |  Branch (525:6): [True: 109, False: 1.50k]
  |  Branch (525:33): [True: 109, False: 0]
  ------------------
  526|    109|		buf[15] = file->sec_attr[0];
  527|    109|		buf[16] = file->sec_attr[1];
  528|    109|		buf[17] = file->sec_attr[2];
  529|       |
  530|    109|		sc_log(card->ctx, "id (%X), sec_attr %X %X %X", file->id,
  ------------------
  |  |   71|    109|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  531|    109|				file->sec_attr[0],file->sec_attr[1],file->sec_attr[2]);
  532|    109|	}
  533|  1.50k|	else   {
  534|  1.50k|		delete = sc_file_get_acl_entry(file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|  1.50k|#define SC_AC_OP_DELETE			2
  ------------------
  535|       |
  536|  1.50k|		sc_log(card->ctx, "id (%X), type (%X)", file->id, file->type);
  ------------------
  |  |   71|  1.50k|#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|       |
  538|  1.50k|		switch (file->type) {
  539|  1.24k|		case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|  1.24k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (539:3): [True: 1.24k, False: 256]
  ------------------
  540|       |
  541|  1.24k|			read = sc_file_get_acl_entry(file, SC_AC_OP_READ);
  ------------------
  |  |  188|  1.24k|#define SC_AC_OP_READ			22
  ------------------
  542|  1.24k|			update = sc_file_get_acl_entry(file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|  1.24k|#define SC_AC_OP_UPDATE			23
  ------------------
  543|       |
  544|  1.24k|			buf[15] = (acl_to_byte(read) << 4) | acl_to_byte(update);
  545|  1.24k|			buf[16] = (acl_to_byte(delete)<< 4) | 0x0F;
  546|  1.24k|			break;
  547|     55|		case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|     55|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (547:3): [True: 55, False: 1.44k]
  ------------------
  548|       |
  549|     55|			read = sc_file_get_acl_entry(file, SC_AC_OP_CRYPTO);
  ------------------
  |  |  173|     55|#define SC_AC_OP_CRYPTO			7
  ------------------
  550|     55|			update = sc_file_get_acl_entry(file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     55|#define SC_AC_OP_UPDATE			23
  ------------------
  551|     55|			generate = sc_file_get_acl_entry(file, SC_AC_OP_GENERATE);
  ------------------
  |  |  192|     55|#define SC_AC_OP_GENERATE		26
  ------------------
  552|       |
  553|     55|			buf[15] = (acl_to_byte(read) << 4) | acl_to_byte(update);
  554|     55|			buf[16] = (acl_to_byte(delete)<< 4) | acl_to_byte(generate);
  555|     55|			break;
  556|    196|		case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|    196|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (556:3): [True: 196, False: 1.30k]
  ------------------
  557|       |
  558|    196|			update = sc_file_get_acl_entry(file, SC_AC_OP_CREATE);
  ------------------
  |  |  169|    196|#define SC_AC_OP_CREATE			3
  ------------------
  559|       |
  560|    196|			buf[15] = (acl_to_byte(update) << 4) | acl_to_byte(update);
  561|    196|			buf[16] = (acl_to_byte(delete) << 4) | 0x0F;
  562|    196|			break;
  563|      5|		default:
  ------------------
  |  Branch (563:3): [True: 5, False: 1.49k]
  ------------------
  564|      5|			break;
  565|  1.50k|		}
  566|  1.50k|	}
  567|       |
  568|       |	/* Proprietary Information */
  569|  1.60k|	buf[18] = 0x85;
  570|  1.60k|	buf[19] = 0x02;
  571|  1.60k|	if (file->prop_attr_len == 2 && file->prop_attr != NULL)
  ------------------
  |  Branch (571:6): [True: 243, False: 1.36k]
  |  Branch (571:34): [True: 243, False: 0]
  ------------------
  572|    243|	    memcpy(&buf[20], file->prop_attr, 2);
  573|  1.36k|	else
  574|  1.36k|	{
  575|  1.36k|		buf[20] = 0x00;
  576|  1.36k|		buf[21] = 0x00;
  577|  1.36k|	}
  578|       |
  579|       |	/* Life Cycle Status tag */
  580|  1.60k|	buf[22] = 0x8A;
  581|  1.60k|	buf[23] = 0x01;
  582|  1.60k|	buf[24] = 0x0; /* RFU */
  583|       |
  584|  1.60k|	switch (file->type)
  585|  1.60k|	{
  586|  1.30k|	case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|  1.30k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (586:2): [True: 1.30k, False: 305]
  ------------------
  587|  1.30k|		break;
  588|       |
  589|    102|	case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|    102|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (589:2): [True: 102, False: 1.50k]
  ------------------
  590|    102|		buf[8] = file->ef_structure; /* RSA or EC */
  591|    102|		break;
  592|       |
  593|    198|	case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|    198|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (593:2): [True: 198, False: 1.41k]
  ------------------
  594|    198|		buf[8] = 0x38;
  595|    198|		if(file->namelen > 0 && file->namelen <= 16)
  ------------------
  |  Branch (595:6): [True: 48, False: 150]
  |  Branch (595:27): [True: 48, False: 0]
  ------------------
  596|     48|		{
  597|     48|			buf[25] = 0x84;
  598|     48|			buf[26] = (u8)file->namelen;
  599|       |
  600|    495|			for(i=0;i < file->namelen;i++)
  ------------------
  |  Branch (600:12): [True: 447, False: 48]
  ------------------
  601|    447|				buf[i + 27] = file->name[i];
  602|       |
  603|     48|			buf[1] = 27 + file->namelen;
  604|     48|		}
  605|    198|		break;
  606|      5|	default:
  ------------------
  |  Branch (606:2): [True: 5, False: 1.60k]
  ------------------
  607|      5|		sc_log(card->ctx, "Unknown file type\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  608|      5|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      5|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  609|  1.60k|	}
  610|       |
  611|  1.60k|	*outlen = buf[1]+2;
  612|       |
  613|  1.60k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.60k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.60k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.60k|	int _ret = r; \
  |  |  |  |  155|  1.60k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.60k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.60k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.60k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.60k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.60k|	} else { \
  |  |  |  |  159|      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.60k|	return _ret; \
  |  |  |  |  163|  1.60k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  614|  1.60k|}
card-myeid.c:acl_to_byte:
  309|  4.54k|{
  310|  4.54k|	if (NULL == e)
  ------------------
  |  Branch (310:6): [True: 3, False: 4.53k]
  ------------------
  311|      3|		return 0x00;
  312|  4.53k|	switch (e->method) {
  ------------------
  |  Branch (312:10): [True: 4.44k, False: 96]
  ------------------
  313|  2.88k|	case SC_AC_NONE:
  ------------------
  |  |  150|  2.88k|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (313:2): [True: 2.88k, False: 1.65k]
  ------------------
  314|  2.88k|		return 0x00;
  315|  1.48k|	case SC_AC_CHV:
  ------------------
  |  |  151|  1.48k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (315:2): [True: 1.48k, False: 3.05k]
  ------------------
  316|  1.49k|	case SC_AC_TERM:
  ------------------
  |  |  152|  1.49k|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (316:2): [True: 15, False: 4.52k]
  ------------------
  317|  1.51k|	case SC_AC_AUT:
  ------------------
  |  |  154|  1.51k|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (317:2): [True: 12, False: 4.52k]
  ------------------
  318|  1.51k|		if (e->key_ref == SC_AC_KEY_REF_NONE)
  ------------------
  |  |  204|  1.51k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (318:7): [True: 0, False: 1.51k]
  ------------------
  319|      0|			return 0x00;
  320|  1.51k|		if (e->key_ref < 1 || e->key_ref > 14)
  ------------------
  |  Branch (320:7): [True: 47, False: 1.46k]
  |  Branch (320:25): [True: 19, False: 1.44k]
  ------------------
  321|     66|			return 0x00;
  322|  1.44k|		return e->key_ref;
  323|     50|	case SC_AC_NEVER:
  ------------------
  |  |  163|     50|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (323:2): [True: 50, False: 4.48k]
  ------------------
  324|     50|		return 0x0F;
  325|  4.53k|	}
  326|     96|	return 0x00;
  327|  4.53k|}
card-myeid.c:myeid_delete_file:
  644|     12|{
  645|     12|	int r;
  646|     12|	struct sc_apdu apdu;
  647|       |
  648|     12|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     12|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  649|     12|	if (path->type != SC_PATH_TYPE_FILE_ID && path->len != 2)
  ------------------
  |  |  117|     24|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (649:6): [True: 0, False: 12]
  |  Branch (649:44): [True: 0, False: 0]
  ------------------
  650|      0|	{
  651|      0|		sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_ID\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__
  |  |  ------------------
  ------------------
  652|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|      0|	}
  654|     12|	r = sc_select_file(card, path, NULL);
  655|     12|	LOG_TEST_RET(card->ctx, r, "Unable to select file to be deleted");
  ------------------
  |  |  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: 3, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  656|       |
  657|      9|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE4, 0x00, 0x00);
  ------------------
  |  |  291|      9|#define SC_APDU_CASE_1			0x01
  ------------------
  658|      9|	apdu.cla = 0xA0;
  659|       |
  660|      9|	r = sc_transmit_apdu(card, &apdu);
  661|      9|	LOG_TEST_RET(card->ctx, r, "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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|       |
  663|      9|	LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  664|      9|}
card-myeid.c:myeid_process_fci:
  442|  10.6k|{
  443|  10.6k|	myeid_private_data_t *priv = (myeid_private_data_t *) card->drv_data;
  444|  10.6k|	size_t taglen = 0;
  445|  10.6k|	const u8 *tag = NULL;
  446|  10.6k|	int r;
  447|       |
  448|  10.6k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  10.6k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  10.6k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  10.6k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  10.6k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 10.6k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  449|  10.6k|	r = iso_ops->process_fci(card, file, buf, buflen);
  450|  10.6k|	if (r < 0)
  ------------------
  |  Branch (450:6): [True: 0, False: 10.6k]
  ------------------
  451|  10.6k|	 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|  10.6k|	if(file->type == SC_FILE_EF_UNKNOWN)
  ------------------
  |  |  220|  10.6k|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  |  Branch (453:5): [True: 4.23k, False: 6.44k]
  ------------------
  454|  4.23k|	{
  455|  4.23k|		tag = sc_asn1_find_tag(NULL, buf, buflen, 0x82, &taglen);
  456|  4.23k|		if (tag != NULL && taglen > 0 && *tag == 17)
  ------------------
  |  Branch (456:7): [True: 1.86k, False: 2.36k]
  |  Branch (456:22): [True: 1.70k, False: 159]
  |  Branch (456:36): [True: 58, False: 1.65k]
  ------------------
  457|     58|		{
  458|     58|			file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     58|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  459|     58|		}
  460|  4.23k|	}
  461|  10.6k|	if(file->sec_attr_len >= 3)
  ------------------
  |  Branch (461:5): [True: 6.86k, False: 3.80k]
  ------------------
  462|  6.86k|	{
  463|  6.86k|		sc_log(card->ctx, "id (%X) sec_attr (%X %X %X)", file->id,
  ------------------
  |  |   71|  6.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__
  |  |  ------------------
  ------------------
  464|  6.86k|			file->sec_attr[0],file->sec_attr[1],file->sec_attr[2]);
  465|  6.86k|	}
  466|       |
  467|  10.6k|	priv->card_state = file->status;
  468|  10.6k|	switch (file->status) {
  469|  4.68k|		case SC_FILE_STATUS_CREATION:
  ------------------
  |  |  240|  4.68k|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (469:3): [True: 4.68k, False: 5.99k]
  ------------------
  470|  4.68k|			file->acl_inactive = 1;
  471|  4.68k|			sc_log(card->ctx, "File id (%X) status SC_FILE_STATUS_CREATION", file->id);
  ------------------
  |  |   71|  4.68k|#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|  4.68k|			break;
  473|    237|		case SC_FILE_STATUS_ACTIVATED:
  ------------------
  |  |  236|    237|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  |  Branch (473:3): [True: 237, False: 10.4k]
  ------------------
  474|    237|			sc_log(card->ctx, "File id (%X) status SC_FILE_STATUS_ACTIVATED", file->id);
  ------------------
  |  |   71|    237|#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|    237|			break;
  476|  5.75k|		default:
  ------------------
  |  Branch (476:3): [True: 5.75k, False: 4.92k]
  ------------------
  477|  5.75k|			sc_log(card->ctx, "File id (%X) unusual status (0x%X)", file->id, file->status);
  ------------------
  |  |   71|  5.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__
  |  |  ------------------
  ------------------
  478|  10.6k|	}
  479|       |
  480|  10.6k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  10.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  10.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  10.6k|	int _ret = r; \
  |  |  |  |  155|  10.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 10.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  10.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: 10.6k]
  |  |  |  |  ------------------
  |  |  |  |  157|  10.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  10.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|  10.6k|	return _ret; \
  |  |  |  |  163|  10.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|  10.6k|}
card-myeid.c:myeid_card_ctl:
 1820|  65.2k|{
 1821|  65.2k|	int r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  65.2k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1822|  65.2k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  65.2k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  65.2k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  65.2k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  65.2k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 65.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1823|       |
 1824|  65.2k|	switch(cmd) {
  ------------------
  |  Branch (1824:9): [True: 65.2k, False: 6]
  ------------------
 1825|    660|	case SC_CARDCTL_MYEID_PUTDATA:
  ------------------
  |  Branch (1825:2): [True: 660, False: 64.5k]
  ------------------
 1826|    660|		r = myeid_putdata(card,
 1827|    660|			(struct sc_cardctl_myeid_data_obj*) ptr);
 1828|    660|		break;
 1829|     58|	case SC_CARDCTL_MYEID_GETDATA:
  ------------------
  |  Branch (1829:2): [True: 58, False: 65.1k]
  ------------------
 1830|     58|		r = myeid_getdata(card,
 1831|     58|			(struct sc_cardctl_myeid_data_obj*) ptr);
 1832|     58|		break;
 1833|    132|	case SC_CARDCTL_MYEID_GENERATE_STORE_KEY:
  ------------------
  |  Branch (1833:2): [True: 132, False: 65.0k]
  ------------------
 1834|    132|		r = myeid_generate_store_key(card,
 1835|    132|			(struct sc_cardctl_myeid_gen_store_key_info *) ptr);
 1836|    132|		break;
 1837|    684|	case SC_CARDCTL_MYEID_ACTIVATE_CARD:
  ------------------
  |  Branch (1837:2): [True: 684, False: 64.5k]
  ------------------
 1838|    684|		r = myeid_activate_card(card);
 1839|    684|		break;
 1840|    655|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1840:2): [True: 655, False: 64.5k]
  ------------------
 1841|    655|		r = myeid_get_serialnr(card, (sc_serial_number_t *)ptr);
 1842|    655|		break;
 1843|  60.5k|	case SC_CARDCTL_GET_CHANGE_COUNTER:
  ------------------
  |  Branch (1843:2): [True: 60.5k, False: 4.66k]
  ------------------
 1844|  60.5k|		r = myeid_get_change_counter(card, (size_t *)ptr);
 1845|  60.5k|		break;
 1846|     27|	case SC_CARDCTL_GET_DEFAULT_KEY:
  ------------------
  |  Branch (1846:2): [True: 27, False: 65.1k]
  ------------------
 1847|  2.46k|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1847:2): [True: 2.44k, False: 62.7k]
  ------------------
 1848|  2.46k|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1848:2): [True: 0, False: 65.2k]
  ------------------
 1849|  2.46k|		break;
 1850|  65.2k|	}
 1851|  65.2k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  65.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  65.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  65.2k|	int _ret = r; \
  |  |  |  |  155|  65.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 65.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  65.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|  63.5k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 63.5k, False: 1.60k]
  |  |  |  |  ------------------
  |  |  |  |  157|  65.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  65.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|  65.2k|	return _ret; \
  |  |  |  |  163|  65.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1852|  65.2k|}
card-myeid.c:myeid_putdata:
 1476|    660|{
 1477|    660|	int r;
 1478|    660|	struct sc_apdu apdu;
 1479|       |
 1480|    660|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    660|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    660|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    660|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    660|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 660]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1481|       |
 1482|    660|	memset(&apdu, 0, sizeof(apdu));
 1483|    660|	apdu.cse     = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|    660|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1484|    660|	apdu.cla     = 0x00;
 1485|    660|	apdu.ins     = 0xDA;
 1486|    660|	apdu.p1      = data_obj->P1;
 1487|    660|	apdu.p2      = data_obj->P2;
 1488|    660|	apdu.lc      = data_obj->DataLen;
 1489|    660|	apdu.datalen = data_obj->DataLen;
 1490|    660|	apdu.data    = data_obj->Data;
 1491|       |
 1492|    660|	r = sc_transmit_apdu(card, &apdu);
 1493|    660|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    660|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    660|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    660|	int _ret = (r); \
  |  |  |  |  168|    660|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 660]
  |  |  |  |  ------------------
  |  |  |  |  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|    660|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 660]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1494|       |
 1495|    660|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1496|    660|	LOG_TEST_RET(card->ctx, r, "PUT_DATA returned error");
  ------------------
  |  |  174|    660|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    660|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    660|	int _ret = (r); \
  |  |  |  |  168|    660|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 374, False: 286]
  |  |  |  |  ------------------
  |  |  |  |  169|    374|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    374|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    374|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    374|		return _ret; \
  |  |  |  |  172|    374|	} \
  |  |  |  |  173|    660|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 286]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1497|       |
 1498|    286|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    286|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    286|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    286|	int _ret = r; \
  |  |  |  |  155|    286|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 286, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    286|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 286]
  |  |  |  |  ------------------
  |  |  |  |  157|    286|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    286|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    286|	return _ret; \
  |  |  |  |  163|    286|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1499|    286|}
card-myeid.c:myeid_getdata:
 1503|     58|{
 1504|     58|	int r;
 1505|     58|	struct sc_apdu apdu;
 1506|       |
 1507|     58|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     58|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1508|       |
 1509|     58|	memset(&apdu, 0, sizeof(apdu));
 1510|     58|	apdu.cse     = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|     58|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1511|     58|	apdu.cla     = 0x00;
 1512|     58|	apdu.ins     = 0xCA;		/* GET DATA */
 1513|     58|	apdu.p1      = data_obj->P1;
 1514|     58|	apdu.p2      = data_obj->P2;
 1515|     58|	apdu.lc      = 0;
 1516|     58|	apdu.datalen = 0;
 1517|     58|	apdu.data    = data_obj->Data;
 1518|       |
 1519|     58|	apdu.le      = card->max_recv_size;
 1520|     58|	apdu.resp    = data_obj->Data;
 1521|     58|	apdu.resplen = data_obj->DataLen;
 1522|       |
 1523|     58|	r = sc_transmit_apdu(card, &apdu);
 1524|     58|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 3, False: 55]
  |  |  |  |  ------------------
  |  |  |  |  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|     58|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 55]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1525|       |
 1526|     55|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1527|     55|	LOG_TEST_RET(card->ctx, r, "GET_DATA returned error");
  ------------------
  |  |  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: 2, False: 53]
  |  |  |  |  ------------------
  |  |  |  |  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|     55|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1528|       |
 1529|     53|	if (apdu.resplen > data_obj->DataLen)
  ------------------
  |  Branch (1529:6): [True: 0, False: 53]
  ------------------
 1530|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 1531|     53|	else
 1532|     53|		data_obj->DataLen = apdu.resplen;
 1533|       |
 1534|     53|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1535|     53|}
card-myeid.c:myeid_generate_store_key:
 1597|    132|{
 1598|    132|	struct	sc_apdu apdu;
 1599|    132|	u8	sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1600|    132|	int	r=0,len;
 1601|       |
 1602|    132|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    132|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    132|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    132|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    132|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 132]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1603|       |	/* Setup key-generation parameters */
 1604|    132|	if (data->op_type == OP_TYPE_GENERATE)
  ------------------
  |  |  529|    132|#define OP_TYPE_GENERATE	0
  ------------------
  |  Branch (1604:6): [True: 69, False: 63]
  ------------------
 1605|     69|	{
 1606|     69|		len = 0;
 1607|     69|		memset(&apdu, 0, sizeof(apdu));
 1608|       |
 1609|     69|		if(data->key_type == SC_CARDCTL_MYEID_KEY_RSA)
  ------------------
  |  Branch (1609:6): [True: 39, False: 30]
  ------------------
 1610|     39|		{
 1611|     39|		    sbuf[len++] = 0x30;
 1612|     39|		    sbuf[len++] = 0x05;
 1613|     39|		    sbuf[len++] = 0x81;
 1614|     39|		    sbuf[len++] = data->pubexp_len;
 1615|       |
 1616|     39|		    memcpy(sbuf + len, data->pubexp, data->pubexp_len);
 1617|     39|		    len += data->pubexp_len;
 1618|     39|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x46, 0x00, 0x00);
  ------------------
  |  |  293|     39|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1619|     39|			apdu.data    = sbuf;
 1620|     39|		}
 1621|     30|		else if(data->key_type == SC_CARDCTL_MYEID_KEY_EC) {
  ------------------
  |  Branch (1621:11): [True: 30, False: 0]
  ------------------
 1622|       |
 1623|     30|			sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x46, 0x00, 0x00);
  ------------------
  |  |  291|     30|#define SC_APDU_CASE_1			0x01
  ------------------
 1624|       |
 1625|     30|			apdu.data    = NULL;
 1626|     30|			apdu.resp	 = sbuf;
 1627|     30|			apdu.resplen = 0x00;
 1628|     30|			apdu.le		 = 0x00;
 1629|     30|		}
 1630|       |
 1631|     69|		apdu.cla     = 0x00;
 1632|     69|		apdu.datalen = len;
 1633|     69|		apdu.lc	     = len;
 1634|       |
 1635|     69|		r = sc_transmit_apdu(card, &apdu);
 1636|     69|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     69|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     69|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     69|	int _ret = (r); \
  |  |  |  |  168|     69|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 69]
  |  |  |  |  ------------------
  |  |  |  |  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|     69|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 69]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1637|       |
 1638|     69|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1639|     69|		LOG_TEST_RET(card->ctx, r, "GENERATE_KEY returned error");
  ------------------
  |  |  174|     69|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     69|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     69|	int _ret = (r); \
  |  |  |  |  168|     69|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 65]
  |  |  |  |  ------------------
  |  |  |  |  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|     69|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1640|     69|	}
 1641|     63|	else
 1642|     63|	{
 1643|     63|		if(data->key_type == SC_CARDCTL_MYEID_KEY_RSA)
  ------------------
  |  Branch (1643:6): [True: 0, False: 63]
  ------------------
 1644|      0|		{
 1645|      0|			if((r=myeid_loadkey(card, LOAD_KEY_PRIME_P,
  ------------------
  |  |   37|      0|#define LOAD_KEY_PRIME_P		0x0083
  ------------------
  |  Branch (1645:7): [True: 0, False: 0]
  ------------------
 1646|      0|				data->primep, data->primep_len)) >= 0 &&
 1647|      0|			(r=myeid_loadkey(card, LOAD_KEY_PRIME_Q,
  ------------------
  |  |   38|      0|#define LOAD_KEY_PRIME_Q		0x0084
  ------------------
  |  Branch (1647:4): [True: 0, False: 0]
  ------------------
 1648|      0|				data->primeq, data->primeq_len)) >= 0 &&
 1649|      0|			(r=myeid_loadkey(card, LOAD_KEY_DP1,
  ------------------
  |  |   39|      0|#define LOAD_KEY_DP1			0x0085
  ------------------
  |  Branch (1649:4): [True: 0, False: 0]
  ------------------
 1650|      0|				data->dp1, data->dp1_len)) >= 0 &&
 1651|      0|			(r=myeid_loadkey(card, LOAD_KEY_DQ1,
  ------------------
  |  |   40|      0|#define LOAD_KEY_DQ1			0x0086
  ------------------
  |  Branch (1651:4): [True: 0, False: 0]
  ------------------
 1652|      0|				data->dq1, data->dq1_len)) >= 0 &&
 1653|      0|			(r=myeid_loadkey(card, LOAD_KEY_INVQ,
  ------------------
  |  |   41|      0|#define LOAD_KEY_INVQ			0x0087
  ------------------
  |  Branch (1653:4): [True: 0, False: 0]
  ------------------
 1654|      0|				data->invq, data->invq_len)) >= 0 &&
 1655|      0|			(r=myeid_loadkey(card, LOAD_KEY_MODULUS,
  ------------------
  |  |   35|      0|#define LOAD_KEY_MODULUS		0x0080
  ------------------
  |  Branch (1655:4): [True: 0, False: 0]
  ------------------
 1656|      0|				data->mod, data->key_len_bits)) >= 0 &&
 1657|      0|			(r=myeid_loadkey(card, LOAD_KEY_PUBLIC_EXPONENT,
  ------------------
  |  |   36|      0|#define LOAD_KEY_PUBLIC_EXPONENT	0x0081
  ------------------
  |  Branch (1657:4): [True: 0, False: 0]
  ------------------
 1658|      0|				data->pubexp, data->pubexp_len)) >= 0)
 1659|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1660|      0|		}
 1661|     63|		else if(data->key_type == SC_CARDCTL_MYEID_KEY_EC) {
  ------------------
  |  Branch (1661:11): [True: 0, False: 63]
  ------------------
 1662|      0|			if((r = myeid_loadkey(card, LOAD_KEY_EC_PRIVATE, data->d,
  ------------------
  |  |   43|      0|#define LOAD_KEY_EC_PRIVATE		0x1087
  ------------------
  |  Branch (1662:7): [True: 0, False: 0]
  ------------------
 1663|      0|					data->d_len)) >= 0 &&
 1664|      0|				(r = myeid_loadkey(card, LOAD_KEY_EC_PUBLIC, data->ecpublic_point,
  ------------------
  |  |   42|      0|#define LOAD_KEY_EC_PUBLIC		0x1086
  ------------------
  |  Branch (1664:5): [True: 0, False: 0]
  ------------------
 1665|      0|					data->ecpublic_point_len)) >= 0)
 1666|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1667|      0|		}
 1668|     63|		else if(data->key_type == SC_CARDCTL_MYEID_KEY_AES ||
  ------------------
  |  Branch (1668:11): [True: 27, False: 36]
  ------------------
 1669|     49|			data->key_type == SC_CARDCTL_MYEID_KEY_DES) {
  ------------------
  |  Branch (1669:4): [True: 22, False: 14]
  ------------------
 1670|     49|			if((r = myeid_loadkey(card, LOAD_KEY_SYMMETRIC, data->d,
  ------------------
  |  |   44|     49|#define LOAD_KEY_SYMMETRIC		0x20a0
  ------------------
  |  Branch (1670:7): [True: 44, False: 5]
  ------------------
 1671|     49|					data->d_len)) >= 0)
 1672|     49|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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: 44, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     44|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 44]
  |  |  |  |  ------------------
  |  |  |  |  157|     44|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     44|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     44|	return _ret; \
  |  |  |  |  163|     44|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1673|     49|		}
 1674|     63|	}
 1675|       |
 1676|     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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 79]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1677|     84|}
card-myeid.c:myeid_loadkey:
 1538|     49|{
 1539|     49|	myeid_private_data_t *priv = (myeid_private_data_t *) card->drv_data;
 1540|     49|	sc_apdu_t apdu;
 1541|     49|	u8 sbuf[MYEID_MAX_EXT_APDU_BUFFER_SIZE];
 1542|     49|	int r;
 1543|       |
 1544|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|     49|	if (value_len == 0 || value == NULL)
  ------------------
  |  Branch (1545:6): [True: 0, False: 49]
  |  Branch (1545:24): [True: 0, False: 49]
  ------------------
 1546|      0|		return 0;
 1547|       |
 1548|     49|	if (mode == LOAD_KEY_MODULUS && value_len == 256 && !priv->cap_chaining)
  ------------------
  |  |   35|     98|#define LOAD_KEY_MODULUS		0x0080
  ------------------
  |  Branch (1548:6): [True: 0, False: 49]
  |  Branch (1548:34): [True: 0, False: 0]
  |  Branch (1548:54): [True: 0, False: 0]
  ------------------
 1549|      0|	{
 1550|      0|		mode = 0x88;
 1551|      0|		memset(&apdu, 0, sizeof(apdu));
 1552|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDA, 0x01, mode);
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1553|       |
 1554|      0|		apdu.cla     = 0x00;
 1555|      0|		apdu.data    = value;
 1556|      0|		apdu.datalen = 128;
 1557|      0|		apdu.lc	     = 128;
 1558|       |
 1559|      0|		r = sc_transmit_apdu(card, &apdu);
 1560|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1561|       |
 1562|      0|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1563|      0|		LOG_TEST_RET(card->ctx, r, "LOAD KEY returned 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1564|       |
 1565|      0|		mode = 0x89;
 1566|      0|		value += 128;
 1567|      0|		value_len -= 128;
 1568|      0|	}
 1569|     49|	else if ((mode & 0xff00) == 0 && mode != LOAD_KEY_PUBLIC_EXPONENT &&
  ------------------
  |  |   36|     49|#define LOAD_KEY_PUBLIC_EXPONENT	0x0081
  ------------------
  |  Branch (1569:11): [True: 0, False: 49]
  |  Branch (1569:35): [True: 0, False: 0]
  ------------------
 1570|      0|		 value[0] != 0x00)
  ------------------
  |  Branch (1570:4): [True: 0, False: 0]
  ------------------
 1571|      0|	{
 1572|       |		/* RSA components needing leading zero byte */
 1573|      0|		sbuf[0] = 0x0;
 1574|      0|		memcpy(&sbuf[1], value, value_len);
 1575|      0|		value = sbuf;
 1576|      0|		value_len ++;
 1577|      0|	}
 1578|       |
 1579|     49|	memset(&apdu, 0, sizeof(apdu));
 1580|     49|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xDA, 0x01, mode & 0xFF);
  ------------------
  |  |  293|     49|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1581|     49|	apdu.flags   = SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     49|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 1582|     49|	apdu.cla     = 0x00;
 1583|     49|	apdu.data    = value;
 1584|     49|	apdu.datalen = value_len;
 1585|     49|	apdu.lc	     = value_len;
 1586|       |
 1587|     49|	r = sc_transmit_apdu(card, &apdu);
 1588|     49|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 0, False: 49]
  |  |  |  |  ------------------
  |  |  |  |  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|     49|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1589|       |
 1590|     49|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1591|     49|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|      5|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5, False: 44]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1592|     49|}
card-myeid.c:myeid_activate_card:
 1680|    684|{
 1681|    684|	int r;
 1682|    684|	u8 sbuf[] ="\xA0\x00\x00\x00\x63\x50\x4B\x43\x53\x2D\x31\x35";
 1683|    684|	sc_apdu_t apdu;
 1684|       |
 1685|    684|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    684|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    684|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    684|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    684|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 684]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1686|    684|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x44, 0x04, 0x00);
  ------------------
  |  |  293|    684|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1687|    684|	apdu.cla     = 0x00;
 1688|    684|	apdu.data    = sbuf;
 1689|    684|	apdu.datalen = 0x0C;
 1690|    684|	apdu.lc	     = 0x0C;
 1691|       |
 1692|    684|	r = sc_transmit_apdu(card, &apdu);
 1693|    684|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    684|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    684|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    684|	int _ret = (r); \
  |  |  |  |  168|    684|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 684]
  |  |  |  |  ------------------
  |  |  |  |  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|    684|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 684]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1694|       |
 1695|    684|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1696|    684|	LOG_TEST_RET(card->ctx, r, "ACTIVATE_APPLET returned error");
  ------------------
  |  |  174|    684|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    684|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    684|	int _ret = (r); \
  |  |  |  |  168|    684|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 646, False: 38]
  |  |  |  |  ------------------
  |  |  |  |  169|    646|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    646|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    646|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    646|		return _ret; \
  |  |  |  |  172|    646|	} \
  |  |  |  |  173|    684|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 38]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1697|       |
 1698|     38|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1699|     38|}
card-myeid.c:myeid_get_serialnr:
 1737|    655|{
 1738|    655|	int r;
 1739|    655|	u8  rbuf[256];
 1740|       |
 1741|    655|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    655|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    655|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    655|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    655|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 655]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1742|       |
 1743|       |	/* if number cached, get it
 1744|       |	if(card->serialnr.value) {
 1745|       |		memcpy(serial, &card->serialnr, sizeof(*serial));
 1746|       |		LOG_FUNC_RETURN(card->ctx, r);
 1747|       |	}*/
 1748|       |
 1749|       |	/* get number from card */
 1750|    655|	r = myeid_get_info(card, rbuf, sizeof(rbuf));
 1751|    655|	LOG_TEST_RET(card->ctx, r,  "Get applet info failed");
  ------------------
  |  |  174|    655|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    655|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    655|	int _ret = (r); \
  |  |  |  |  168|    655|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 323, False: 332]
  |  |  |  |  ------------------
  |  |  |  |  169|    323|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    323|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    323|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    323|		return _ret; \
  |  |  |  |  172|    323|	} \
  |  |  |  |  173|    655|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 332]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1752|       |
 1753|       |	/* cache serial number */
 1754|    332|	memcpy(card->serialnr.value, &rbuf[8], 10);
 1755|    332|	card->serialnr.len = 10;
 1756|       |
 1757|       |	/* copy and return serial number */
 1758|    332|	memcpy(serial, &card->serialnr, sizeof(*serial));
 1759|       |
 1760|    332|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    332|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    332|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    332|	int _ret = r; \
  |  |  |  |  155|    332|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 332, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    332|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 332]
  |  |  |  |  ------------------
  |  |  |  |  157|    332|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    332|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    332|	return _ret; \
  |  |  |  |  163|    332|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1761|    332|}
card-myeid.c:myeid_get_change_counter:
 1765|  60.5k|{
 1766|  60.5k|	int r;
 1767|  60.5k|	u8 rbuf[256];
 1768|       |
 1769|  60.5k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  60.5k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  60.5k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  60.5k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  60.5k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 60.5k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1770|       |
 1771|       |	/* get change counter from card */
 1772|  60.5k|	r = myeid_get_info(card, rbuf, sizeof(rbuf));
 1773|  60.5k|	LOG_TEST_RET(card->ctx, r, "Get applet info failed");
  ------------------
  |  |  174|  60.5k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  60.5k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  60.5k|	int _ret = (r); \
  |  |  |  |  168|  60.5k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 59.7k, False: 776]
  |  |  |  |  ------------------
  |  |  |  |  169|  59.7k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|  59.7k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  59.7k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  59.7k|		return _ret; \
  |  |  |  |  172|  59.7k|	} \
  |  |  |  |  173|  60.5k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 776]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1774|       |
 1775|    776|	*change_counter = rbuf[18] * 256 + rbuf[19];
 1776|       |
 1777|    776|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    776|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    776|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    776|	int _ret = r; \
  |  |  |  |  155|    776|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 776, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    776|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 776]
  |  |  |  |  ------------------
  |  |  |  |  157|    776|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    776|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    776|	return _ret; \
  |  |  |  |  163|    776|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1778|    776|}
card-myeid.c:myeid_pin_cmd:
  667|    352|{
  668|    352|	myeid_private_data_t *priv = (myeid_private_data_t *) card->drv_data;
  669|       |
  670|    352|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  671|       |
  672|    352|	sc_log(card->ctx, "ref (%d), pin1 len(%zu), pin2 len (%zu)\n",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  673|    352|			data->pin_reference, data->pin1.len, data->pin2.len);
  674|       |
  675|    352|	if(data->pin1.len > 8 || data->pin2.len > 8)
  ------------------
  |  Branch (675:5): [True: 0, False: 352]
  |  Branch (675:27): [True: 0, False: 352]
  ------------------
  676|    352|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|       |
  678|    352|	data->pin1.pad_length = data->pin2.pad_length = 8;
  679|    352|	data->pin1.pad_char = data->pin2.pad_char = 0xFF;
  680|       |
  681|    352|	if (data->cmd == SC_PIN_CMD_VERIFY && priv->card_state == SC_FILE_STATUS_CREATION) {
  ------------------
  |  |  422|    704|#define SC_PIN_CMD_VERIFY	0
  ------------------
              	if (data->cmd == SC_PIN_CMD_VERIFY && priv->card_state == SC_FILE_STATUS_CREATION) {
  ------------------
  |  |  240|     18|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (681:6): [True: 18, False: 334]
  |  Branch (681:40): [True: 10, False: 8]
  ------------------
  682|     10|		sc_log(card->ctx, "Card in creation state, no need to verify");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  683|     10|		return SC_SUCCESS;
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
  684|     10|	}
  685|       |
  686|    342|	LOG_FUNC_RETURN(card->ctx, iso_ops->pin_cmd(card, data));
  ------------------
  |  |  164|    342|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    342|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    342|	int _ret = r; \
  |  |  |  |  155|    342|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 342, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    342|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     93|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 93, False: 249]
  |  |  |  |  ------------------
  |  |  |  |  157|    342|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    342|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    342|	return _ret; \
  |  |  |  |  163|    342|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  687|    342|}

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

sc_get_nqApplet_driver:
  471|  3.69k|{
  472|  3.69k|	sc_card_driver_t *iso_driver = sc_get_iso7816_driver();
  473|       |
  474|  3.69k|	if (iso_operations == NULL) {
  ------------------
  |  Branch (474:6): [True: 1, False: 3.69k]
  ------------------
  475|      1|		iso_operations = iso_driver->ops;
  476|      1|	}
  477|       |
  478|  3.69k|	nqapplet_operations = *iso_driver->ops;
  479|       |
  480|       |	/* supported operations */
  481|  3.69k|	nqapplet_operations.match_card = nqapplet_match_card;
  482|  3.69k|	nqapplet_operations.init = nqapplet_init;
  483|  3.69k|	nqapplet_operations.finish = nqapplet_finish;
  484|  3.69k|	nqapplet_operations.get_response = nqapplet_get_response;
  485|  3.69k|	nqapplet_operations.get_challenge = nqapplet_get_challenge;
  486|  3.69k|	nqapplet_operations.logout = nqapplet_logout;
  487|  3.69k|	nqapplet_operations.set_security_env = nqapplet_set_security_env;
  488|  3.69k|	nqapplet_operations.decipher = nqapplet_decipher;
  489|  3.69k|	nqapplet_operations.compute_signature = nqapplet_compute_signature;
  490|  3.69k|	nqapplet_operations.check_sw = nqapplet_check_sw;
  491|  3.69k|	nqapplet_operations.get_data = nqapplet_get_data;
  492|  3.69k|	nqapplet_operations.select_file = nqapplet_select_file;
  493|  3.69k|	nqapplet_operations.card_ctl = nqapplet_card_ctl;
  494|  3.69k|	nqapplet_operations.pin_cmd = nqapplet_pin_cmd;
  495|       |
  496|       |	/* unsupported operations */
  497|  3.69k|	nqapplet_operations.read_binary = NULL;
  498|  3.69k|	nqapplet_operations.write_binary = NULL;
  499|  3.69k|	nqapplet_operations.update_binary = NULL;
  500|  3.69k|	nqapplet_operations.erase_binary = NULL;
  501|  3.69k|	nqapplet_operations.read_record = NULL;
  502|  3.69k|	nqapplet_operations.write_record = NULL;
  503|  3.69k|	nqapplet_operations.append_record = NULL;
  504|  3.69k|	nqapplet_operations.update_record = NULL;
  505|       |
  506|  3.69k|	nqapplet_operations.verify = NULL;
  507|  3.69k|	nqapplet_operations.restore_security_env = NULL;
  508|  3.69k|	nqapplet_operations.change_reference_data = NULL;
  509|  3.69k|	nqapplet_operations.reset_retry_counter = NULL;
  510|  3.69k|	nqapplet_operations.create_file = NULL;
  511|  3.69k|	nqapplet_operations.delete_file = NULL;
  512|  3.69k|	nqapplet_operations.list_files = NULL;
  513|  3.69k|	nqapplet_operations.process_fci = NULL;
  514|  3.69k|	nqapplet_operations.construct_fci = NULL;
  515|  3.69k|	nqapplet_operations.put_data = NULL;
  516|  3.69k|	nqapplet_operations.delete_record = NULL;
  517|  3.69k|	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|  3.69k|	return &nqapplet_driver;
  526|  3.69k|}
card-nqApplet.c:nqapplet_match_card:
  143|    142|{
  144|    142|	int rv = _sc_match_atr(card, nqapplet_atrs, &card->type);
  145|    142|	return (rv >= 0);
  146|    142|}

sc_get_oberthur_driver:
 2334|  3.69k|{
 2335|  3.69k|	return sc_get_driver();
 2336|  3.69k|}
card-oberthur.c:sc_get_driver:
 2303|  3.69k|{
 2304|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2304:6): [True: 1, False: 3.69k]
  ------------------
 2305|      1|		iso_ops = sc_get_iso7816_driver()->ops;
 2306|       |
 2307|  3.69k|	auth_ops = *iso_ops;
 2308|  3.69k|	auth_ops.match_card = auth_match_card;
 2309|  3.69k|	auth_ops.init = auth_init;
 2310|  3.69k|	auth_ops.finish = auth_finish;
 2311|  3.69k|	auth_ops.select_file = auth_select_file;
 2312|  3.69k|	auth_ops.list_files = auth_list_files;
 2313|  3.69k|	auth_ops.delete_file = auth_delete_file;
 2314|  3.69k|	auth_ops.create_file = auth_create_file;
 2315|  3.69k|	auth_ops.read_binary = auth_read_binary;
 2316|  3.69k|	auth_ops.update_binary = auth_update_binary;
 2317|  3.69k|	auth_ops.read_record = auth_read_record;
 2318|  3.69k|	auth_ops.delete_record = auth_delete_record;
 2319|  3.69k|	auth_ops.card_ctl = auth_card_ctl;
 2320|  3.69k|	auth_ops.set_security_env = auth_set_security_env;
 2321|  3.69k|	auth_ops.restore_security_env = auth_restore_security_env;
 2322|  3.69k|	auth_ops.compute_signature = auth_compute_signature;
 2323|  3.69k|	auth_ops.decipher = auth_decipher;
 2324|  3.69k|	auth_ops.process_fci = auth_process_fci;
 2325|  3.69k|	auth_ops.pin_cmd = auth_pin_cmd;
 2326|  3.69k|	auth_ops.logout = auth_logout;
 2327|  3.69k|	auth_ops.check_sw = auth_check_sw;
 2328|  3.69k|	return &auth_drv;
 2329|  3.69k|}
card-oberthur.c:auth_match_card:
  204|  3.30k|{
  205|  3.30k|	if (_sc_match_atr(card, oberthur_atrs, &card->type) < 0)
  ------------------
  |  Branch (205:6): [True: 2.83k, False: 470]
  ------------------
  206|  2.83k|		return 0;
  207|    470|	else
  208|    470|		return 1;
  209|  3.30k|}
card-oberthur.c:auth_init:
  214|    470|{
  215|    470|	struct auth_private_data *data;
  216|    470|	struct sc_path path;
  217|    470|	unsigned long flags;
  218|    470|	int rv = 0;
  219|       |
  220|    470|	data = calloc(1, sizeof(struct auth_private_data));
  221|    470|	if (!data)
  ------------------
  |  Branch (221:6): [True: 0, False: 470]
  ------------------
  222|    470|		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|    470|	card->cla = 0x00;
  225|    470|	card->drv_data = data;
  226|       |
  227|    470|	card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|    470|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  228|    470|	card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  564|    470|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  229|       |
  230|    470|	if (auth_select_aid(card)) {
  ------------------
  |  Branch (230:6): [True: 6, False: 464]
  ------------------
  231|      6|		sc_log(card->ctx, "Failed to initialize %s", card->name);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  232|      6|		rv = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|      6|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  233|      6|		LOG_TEST_GOTO_ERR(card->ctx, SC_ERROR_INVALID_CARD, "Failed to initialize");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|      6|	}
  235|       |
  236|    464|	sc_format_path("3F00", &path);
  237|    464|	rv = auth_select_file(card, &path, NULL);
  238|       |
  239|    470|err:
  240|    470|	if (rv == SC_SUCCESS) {
  ------------------
  |  |   28|    470|#define SC_SUCCESS				0
  ------------------
  |  Branch (240:6): [True: 464, False: 6]
  ------------------
  241|    464|		flags = SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_PAD_ISO9796;
  ------------------
  |  |  120|    464|#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) */
  |  |  ------------------
  |  |  |  |  118|    464|#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) */
  |  |  ------------------
  |  |  |  |  119|    464|#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;
  ------------------
  |  |  115|    464|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  242|    464|		flags |= SC_ALGORITHM_RSA_HASH_NONE;
  ------------------
  |  |  142|    464|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  243|    464|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    464|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  244|       |
  245|    464|		_sc_card_add_rsa_alg(card, 512, flags, 0);
  246|    464|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  247|    464|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  248|    464|	} else {
  249|      6|		free(card->drv_data);
  250|      6|		card->drv_data = NULL;
  251|      6|	}
  252|       |
  253|    470|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    470|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    470|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    470|	int _ret = r; \
  |  |  |  |  155|    470|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 470, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    470|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 464]
  |  |  |  |  ------------------
  |  |  |  |  157|    470|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    470|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    470|	return _ret; \
  |  |  |  |  163|    470|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  254|    470|}
card-oberthur.c:auth_select_aid:
  145|    470|{
  146|    470|	struct sc_apdu apdu;
  147|    470|	unsigned char apdu_resp[SC_MAX_APDU_BUFFER_SIZE];
  148|    470|	struct auth_private_data *data = (struct auth_private_data *)card->drv_data;
  149|    470|	int rv, ii;
  150|    470|	struct sc_path tmp_path;
  151|       |
  152|       |	/* Select Card Manager (to deselect previously selected application) */
  153|    470|	rv = gp_select_card_manager(card);
  154|    470|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    470|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    470|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    470|	int _ret = (r); \
  |  |  |  |  168|    470|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 470]
  |  |  |  |  ------------------
  |  |  |  |  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|    470|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 470]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  155|       |
  156|       |	/* Get smart card serial number */
  157|    470|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0x9F, 0x7F);
  ------------------
  |  |  292|    470|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  158|    470|	apdu.cla = 0x80;
  159|    470|	apdu.le = 0x2D;
  160|    470|	apdu.resplen = 0x30;
  161|    470|	apdu.resp = apdu_resp;
  162|       |
  163|    470|	rv = sc_transmit_apdu(card, &apdu);
  164|    470|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    470|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    470|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    470|	int _ret = (r); \
  |  |  |  |  168|    470|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 470]
  |  |  |  |  ------------------
  |  |  |  |  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|    470|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 470]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|    470|	if (apdu.resplen < 20) {
  ------------------
  |  Branch (165:6): [True: 2, False: 468]
  ------------------
  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|    468|	card->serialnr.len = 4;
  169|    468|	memcpy(card->serialnr.value, apdu.resp+15, 4);
  170|       |
  171|  2.34k|	for (ii=0, data->sn = 0; ii < 4; ii++)
  ------------------
  |  Branch (171:27): [True: 1.87k, False: 468]
  ------------------
  172|  1.87k|		data->sn += (long int)(*(apdu.resp + 15 + ii)) << (3-ii)*8;
  173|       |
  174|    468|	sc_log(card->ctx, "serial number %li/0x%lX", data->sn, data->sn);
  ------------------
  |  |   71|    468|#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|    468|	memset(&tmp_path, 0, sizeof(struct sc_path));
  177|    468|	tmp_path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    468|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  178|    468|	memcpy(tmp_path.value, aidAuthentIC_V5, lenAidAuthentIC_V5);
  179|    468|	tmp_path.len = lenAidAuthentIC_V5;
  180|       |
  181|    468|	rv = iso_ops->select_file(card, &tmp_path, NULL);
  182|    468|	LOG_TEST_RET(card->ctx, rv, "select parent failed");
  ------------------
  |  |  174|    468|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    468|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    468|	int _ret = (r); \
  |  |  |  |  168|    468|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 465]
  |  |  |  |  ------------------
  |  |  |  |  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|    468|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 465]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  183|       |
  184|    465|	sc_format_path("3F00", &tmp_path);
  185|    465|	sc_file_free(auth_current_df);
  186|    465|	auth_current_df = NULL;
  187|    465|	rv = iso_ops->select_file(card, &tmp_path, &auth_current_df);
  188|    465|	LOG_TEST_RET(card->ctx, rv, "select parent failed");
  ------------------
  |  |  174|    465|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    465|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    465|	int _ret = (r); \
  |  |  |  |  168|    465|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 464]
  |  |  |  |  ------------------
  |  |  |  |  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|    465|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 464]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|       |
  190|    464|	sc_file_free(auth_current_ef);
  191|    464|	auth_current_ef = NULL;
  192|    464|	sc_file_dup(&auth_current_ef, auth_current_df);
  193|       |
  194|    464|	memcpy(data->aid, aidAuthentIC_V5, lenAidAuthentIC_V5);
  195|    464|	data->aid_len = lenAidAuthentIC_V5;
  196|    464|	card->name = nameAidAuthentIC_V5;
  197|       |
  198|    464|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    464|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    464|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    464|	int _ret = r; \
  |  |  |  |  155|    464|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 464, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    464|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 464]
  |  |  |  |  ------------------
  |  |  |  |  157|    464|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    464|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    464|	return _ret; \
  |  |  |  |  163|    464|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|    464|}
card-oberthur.c:auth_finish:
  137|    464|{
  138|    464|	free(card->drv_data);
  139|    464|	return SC_SUCCESS;
  ------------------
  |  |   28|    464|#define SC_SUCCESS				0
  ------------------
  140|    464|}
card-oberthur.c:auth_select_file:
  445|  92.7k|{
  446|  92.7k|	struct sc_path path;
  447|  92.7k|	struct sc_file *tmp_file = NULL;
  448|  92.7k|	size_t offs, ii;
  449|  92.7k|	int rv;
  450|       |
  451|  92.7k|	if (card == NULL || in_path == NULL)
  ------------------
  |  Branch (451:6): [True: 0, False: 92.7k]
  |  Branch (451:22): [True: 0, False: 92.7k]
  ------------------
  452|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  453|       |
  454|  92.7k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  92.7k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  92.7k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  92.7k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  92.7k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 92.7k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  455|       |
  456|  92.7k|	memcpy(&path, in_path, sizeof(struct sc_path));
  457|       |
  458|  92.7k|	if (!auth_current_df)
  ------------------
  |  Branch (458:6): [True: 0, False: 92.7k]
  ------------------
  459|      0|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  460|       |
  461|  92.7k|	sc_log(card->ctx, "in_path; type=%d, path=%s, out %p",
  ------------------
  |  |   71|  92.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__
  |  |  ------------------
  ------------------
  462|  92.7k|			in_path->type, sc_print_path(in_path), file_out);
  463|  92.7k|	sc_log(card->ctx, "current path; type=%d, path=%s",
  ------------------
  |  |   71|  92.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__
  |  |  ------------------
  ------------------
  464|  92.7k|			auth_current_df->path.type, sc_print_path(&auth_current_df->path));
  465|  92.7k|	if (auth_current_ef)
  ------------------
  |  Branch (465:6): [True: 29.0k, False: 63.6k]
  ------------------
  466|  29.0k|		sc_log(card->ctx, "current file; type=%d, path=%s",
  ------------------
  |  |   71|  29.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__
  |  |  ------------------
  ------------------
  467|  92.7k|				auth_current_ef->path.type, sc_print_path(&auth_current_ef->path));
  468|       |
  469|  92.7k|	if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
  ------------------
  |  |  123|   185k|#define SC_PATH_TYPE_PARENT		5
  ------------------
              	if (path.type == SC_PATH_TYPE_PARENT || path.type == SC_PATH_TYPE_FILE_ID) {
  ------------------
  |  |  117|  84.8k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (469:6): [True: 7.87k, False: 84.8k]
  |  Branch (469:42): [True: 29.5k, False: 55.2k]
  ------------------
  470|  37.4k|		sc_file_free(auth_current_ef);
  471|  37.4k|		auth_current_ef = NULL;
  472|       |
  473|  37.4k|		rv = iso_ops->select_file(card, &path, &tmp_file);
  474|  37.4k|		LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|  37.4k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  37.4k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  37.4k|	int _ret = (r); \
  |  |  |  |  168|  37.4k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 28.9k, False: 8.51k]
  |  |  |  |  ------------------
  |  |  |  |  169|  28.9k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.9k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  28.9k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  28.9k|		return _ret; \
  |  |  |  |  172|  28.9k|	} \
  |  |  |  |  173|  37.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8.51k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  475|  8.51k|		if (!tmp_file)
  ------------------
  |  Branch (475:7): [True: 0, False: 8.51k]
  ------------------
  476|      0|			return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  477|       |
  478|  8.51k|		if (path.type == SC_PATH_TYPE_PARENT) {
  ------------------
  |  |  123|  8.51k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (478:7): [True: 2.13k, False: 6.38k]
  ------------------
  479|  2.13k|			memcpy(&tmp_file->path, &auth_current_df->path, sizeof(struct sc_path));
  480|  2.13k|			if (tmp_file->path.len > 2)
  ------------------
  |  Branch (480:8): [True: 740, False: 1.39k]
  ------------------
  481|    740|				tmp_file->path.len -= 2;
  482|       |
  483|  2.13k|			sc_file_free(auth_current_df);
  484|  2.13k|			auth_current_df = NULL;
  485|  2.13k|			sc_file_dup(&auth_current_df, tmp_file);
  486|  6.38k|		} else {
  487|  6.38k|			if (tmp_file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|  6.38k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (487:8): [True: 1.04k, False: 5.33k]
  ------------------
  488|  1.04k|				sc_concatenate_path(&tmp_file->path, &auth_current_df->path, &path);
  489|       |
  490|  1.04k|				sc_file_free(auth_current_df);
  491|  1.04k|				auth_current_df = NULL;
  492|  1.04k|				sc_file_dup(&auth_current_df, tmp_file);
  493|  5.33k|			} else {
  494|  5.33k|				sc_file_free(auth_current_ef);
  495|  5.33k|				auth_current_ef = NULL;
  496|       |
  497|  5.33k|				sc_file_dup(&auth_current_ef, tmp_file);
  498|  5.33k|				sc_concatenate_path(&auth_current_ef->path, &auth_current_df->path, &path);
  499|  5.33k|			}
  500|  6.38k|		}
  501|  8.51k|		if (file_out) {
  ------------------
  |  Branch (501:7): [True: 4.68k, False: 3.83k]
  ------------------
  502|  4.68k|			sc_file_free(*file_out);
  503|  4.68k|			sc_file_dup(file_out, tmp_file);
  504|  4.68k|		}
  505|       |
  506|  8.51k|		sc_file_free(tmp_file);
  507|  55.2k|	} else if (path.type == SC_PATH_TYPE_DF_NAME) {
  ------------------
  |  |  118|  55.2k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (507:13): [True: 912, False: 54.3k]
  ------------------
  508|    912|		rv = iso_ops->select_file(card, &path, NULL);
  509|    912|		if (rv) {
  ------------------
  |  Branch (509:7): [True: 880, False: 32]
  ------------------
  510|    880|			sc_file_free(auth_current_ef);
  511|    880|			auth_current_ef = NULL;
  512|    880|		}
  513|    912|		LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|    912|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    912|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    912|	int _ret = (r); \
  |  |  |  |  168|    912|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 880, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  169|    880|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    880|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    880|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    880|		return _ret; \
  |  |  |  |  172|    880|	} \
  |  |  |  |  173|    912|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  514|  54.3k|	} else {
  515|  96.4k|		for (offs = 0; offs < path.len && offs < auth_current_df->path.len; offs += 2)
  ------------------
  |  Branch (515:18): [True: 72.6k, False: 23.8k]
  |  Branch (515:37): [True: 48.6k, False: 24.0k]
  ------------------
  516|  48.6k|			if (path.value[offs] != auth_current_df->path.value[offs] ||
  ------------------
  |  Branch (516:8): [True: 5.69k, False: 42.9k]
  ------------------
  517|  42.9k|					path.value[offs + 1] != auth_current_df->path.value[offs + 1])
  ------------------
  |  Branch (517:6): [True: 823, False: 42.1k]
  ------------------
  518|  6.51k|				break;
  519|       |
  520|  54.3k|		sc_log(card->ctx, "offs %"SC_FORMAT_LEN_SIZE_T"u", offs);
  ------------------
  |  |   71|  54.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__
  |  |  ------------------
  ------------------
  521|  54.3k|		if (offs && offs < auth_current_df->path.len) {
  ------------------
  |  Branch (521:7): [True: 31.8k, False: 22.5k]
  |  Branch (521:15): [True: 6.42k, False: 25.4k]
  ------------------
  522|  6.42k|			size_t deep = auth_current_df->path.len - offs;
  523|       |
  524|  6.42k|			sc_log(card->ctx, "deep %"SC_FORMAT_LEN_SIZE_T"u",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  525|  6.42k|			       deep);
  526|  7.16k|			for (ii = 0; ii < deep; ii += 2) {
  ------------------
  |  Branch (526:17): [True: 6.47k, False: 689]
  ------------------
  527|  6.47k|				struct sc_path tmp_path;
  528|       |
  529|  6.47k|				memcpy(&tmp_path, &auth_current_df->path,  sizeof(struct sc_path));
  530|  6.47k|				tmp_path.type = SC_PATH_TYPE_PARENT;
  ------------------
  |  |  123|  6.47k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  531|       |
  532|  6.47k|				if (file_out) {
  ------------------
  |  Branch (532:9): [True: 6.27k, False: 193]
  ------------------
  533|  6.27k|					sc_file_free(*file_out);
  534|  6.27k|					*file_out = NULL;
  535|  6.27k|				}
  536|       |
  537|  6.47k|				rv = auth_select_file (card, &tmp_path, file_out);
  538|  6.47k|				LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|  6.47k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  6.47k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  6.47k|	int _ret = (r); \
  |  |  |  |  168|  6.47k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5.73k, False: 740]
  |  |  |  |  ------------------
  |  |  |  |  169|  5.73k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.73k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  5.73k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  5.73k|		return _ret; \
  |  |  |  |  172|  5.73k|	} \
  |  |  |  |  173|  6.47k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 740]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|  6.47k|			}
  540|  6.42k|		}
  541|       |
  542|  48.6k|		if (path.len > offs) {
  ------------------
  |  Branch (542:7): [True: 24.8k, False: 23.8k]
  ------------------
  543|  24.8k|			struct sc_path tmp_path;
  544|       |
  545|  24.8k|			memset(&tmp_path, 0, sizeof(struct sc_path));
  546|  24.8k|			tmp_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  24.8k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  547|  24.8k|			tmp_path.len = 2;
  548|       |
  549|  29.1k|			for (ii = 0; ii < path.len - offs; ii += 2) {
  ------------------
  |  Branch (549:17): [True: 27.0k, False: 2.09k]
  ------------------
  550|  27.0k|				memcpy(tmp_path.value, path.value + offs + ii, 2);
  551|       |
  552|  27.0k|				if (file_out) {
  ------------------
  |  Branch (552:9): [True: 26.1k, False: 984]
  ------------------
  553|  26.1k|					sc_file_free(*file_out);
  554|  26.1k|					*file_out = NULL;
  555|  26.1k|				}
  556|       |
  557|  27.0k|				rv = auth_select_file(card, &tmp_path, file_out);
  558|  27.0k|				LOG_TEST_RET(card->ctx, rv, "select file failed");
  ------------------
  |  |  174|  27.0k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  27.0k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  27.0k|	int _ret = (r); \
  |  |  |  |  168|  27.0k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 22.7k, False: 4.37k]
  |  |  |  |  ------------------
  |  |  |  |  169|  22.7k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.7k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  22.7k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  22.7k|		return _ret; \
  |  |  |  |  172|  22.7k|	} \
  |  |  |  |  173|  27.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  559|  27.0k|			}
  560|  24.8k|		} else if (path.len - offs == 0 && file_out) {
  ------------------
  |  Branch (560:14): [True: 23.8k, False: 0]
  |  Branch (560:38): [True: 23.2k, False: 609]
  ------------------
  561|  23.2k|			if (sc_compare_path(&path, &auth_current_df->path) && file_out) {
  ------------------
  |  Branch (561:8): [True: 784, False: 22.4k]
  |  Branch (561:58): [True: 784, False: 0]
  ------------------
  562|    784|				sc_file_free(*file_out);
  563|    784|				sc_file_dup(file_out, auth_current_df);
  564|  22.4k|			} else  if (auth_current_ef && file_out) {
  ------------------
  |  Branch (564:16): [True: 20.4k, False: 1.94k]
  |  Branch (564:35): [True: 20.4k, False: 0]
  ------------------
  565|  20.4k|				sc_file_free(*file_out);
  566|  20.4k|				sc_file_dup(file_out, auth_current_ef);
  567|  20.4k|			} else {
  568|  1.94k|				LOG_TEST_RET(card->ctx, SC_ERROR_INTERNAL, "No current EF");
  ------------------
  |  |  174|  1.94k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.94k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.94k|	int _ret = (r); \
  |  |  |  |  168|  1.94k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.94k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.94k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.94k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.94k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.94k|		return _ret; \
  |  |  |  |  172|  1.94k|	} \
  |  |  |  |  173|  1.94k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  569|  1.94k|			}
  570|  23.2k|		}
  571|  48.6k|	}
  572|       |
  573|  32.5k|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|  32.5k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  32.5k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  32.5k|	int _ret = r; \
  |  |  |  |  155|  32.5k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 32.5k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  32.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 32.5k]
  |  |  |  |  ------------------
  |  |  |  |  157|  32.5k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  32.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|  32.5k|	return _ret; \
  |  |  |  |  163|  32.5k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  574|  32.5k|}
card-oberthur.c:auth_list_files:
  579|  2.00k|{
  580|  2.00k|	struct sc_apdu apdu;
  581|  2.00k|	unsigned char rbuf[SC_MAX_APDU_BUFFER_SIZE];
  582|  2.00k|	int rv;
  583|       |
  584|  2.00k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.00k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.00k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.00k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.00k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.00k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  585|  2.00k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0x34, 0, 0);
  ------------------
  |  |  292|  2.00k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  586|  2.00k|	apdu.cla = 0x80;
  587|  2.00k|	apdu.le = 0x40;
  588|  2.00k|	apdu.resplen = sizeof(rbuf);
  589|  2.00k|	apdu.resp = rbuf;
  590|       |
  591|  2.00k|	rv = sc_transmit_apdu(card, &apdu);
  592|  2.00k|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  2.00k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.00k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.00k|	int _ret = (r); \
  |  |  |  |  168|  2.00k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 2.00k]
  |  |  |  |  ------------------
  |  |  |  |  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.00k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.00k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|       |
  594|  2.00k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  595|  2.00k|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  174|  2.00k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.00k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.00k|	int _ret = (r); \
  |  |  |  |  168|  2.00k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 1.99k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.00k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.99k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  596|       |
  597|  1.99k|	if (apdu.resplen == 0x100 && rbuf[0]==0 && rbuf[1]==0)
  ------------------
  |  Branch (597:6): [True: 12, False: 1.98k]
  |  Branch (597:31): [True: 2, False: 10]
  |  Branch (597:45): [True: 1, False: 1]
  ------------------
  598|  1.99k|		LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  599|       |
  600|  1.99k|	buflen = MIN(buflen, apdu.resplen);
  ------------------
  |  |   70|  1.99k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 1.99k]
  |  |  ------------------
  ------------------
  601|  1.99k|	memcpy(buf, rbuf, buflen);
  602|       |
  603|  1.99k|	LOG_FUNC_RETURN(card->ctx, (int)buflen);
  ------------------
  |  |  164|  1.99k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.99k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.99k|	int _ret = r; \
  |  |  |  |  155|  1.99k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.40k, False: 594]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.40k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.40k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.40k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.40k|	} else { \
  |  |  |  |  159|    594|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    594|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    594|	} \
  |  |  |  |  162|  1.99k|	return _ret; \
  |  |  |  |  163|  1.99k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  604|  1.99k|}
card-oberthur.c:auth_delete_file:
  609|  3.37k|{
  610|  3.37k|	struct sc_apdu apdu;
  611|  3.37k|	unsigned char sbuf[2];
  612|  3.37k|	int rv;
  613|  3.37k|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  614|       |
  615|  3.37k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.37k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.37k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.37k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.37k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  616|       |
  617|  3.37k|	rv = sc_path_print(pbuf, sizeof(pbuf), path);
  618|  3.37k|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|  3.37k|#define SC_SUCCESS				0
  ------------------
  |  Branch (618:6): [True: 0, False: 3.37k]
  ------------------
  619|      0|		pbuf[0] = '\0';
  620|       |
  621|  3.37k|	sc_log(card->ctx, "path; type=%d, path=%s", path->type, pbuf);
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  622|       |
  623|  3.37k|	if (path->len < 2) {
  ------------------
  |  Branch (623:6): [True: 0, False: 3.37k]
  ------------------
  624|      0|		sc_log(card->ctx, "Invalid path 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__
  |  |  ------------------
  ------------------
  625|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  626|      0|	}
  627|       |
  628|  3.37k|	if (path->len > 2) {
  ------------------
  |  Branch (628:6): [True: 0, False: 3.37k]
  ------------------
  629|      0|		struct sc_path parent = *path;
  630|       |
  631|      0|		parent.len -= 2;
  632|      0|		parent.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
  633|      0|		rv = auth_select_file(card, &parent, NULL);
  634|      0|		LOG_TEST_RET(card->ctx, rv, "select parent 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  635|      0|	}
  636|       |
  637|  3.37k|	sbuf[0] = path->value[path->len - 2];
  638|  3.37k|	sbuf[1] = path->value[path->len - 1];
  639|       |
  640|  3.37k|	if (memcmp(sbuf,"\x00\x00",2)==0 || (memcmp(sbuf,"\xFF\xFF",2)==0) ||
  ------------------
  |  Branch (640:6): [True: 2, False: 3.37k]
  |  Branch (640:38): [True: 2, False: 3.37k]
  ------------------
  641|  3.37k|			memcmp(sbuf,"\x3F\xFF",2)==0)
  ------------------
  |  Branch (641:4): [True: 0, False: 3.37k]
  ------------------
  642|  3.37k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|       |
  644|  3.37k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x02, 0x00);
  ------------------
  |  |  293|  3.37k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  645|  3.37k|	apdu.lc = 2;
  646|  3.37k|	apdu.datalen = 2;
  647|  3.37k|	apdu.data = sbuf;
  648|       |
  649|  3.37k|	rv = sc_transmit_apdu(card, &apdu);
  650|  3.37k|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  3.37k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.37k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.37k|	int _ret = (r); \
  |  |  |  |  168|  3.37k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.37k]
  |  |  |  |  ------------------
  |  |  |  |  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.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  651|  3.37k|	if (apdu.sw1 == 0x6A && apdu.sw2 == 0x82) {
  ------------------
  |  Branch (651:6): [True: 2.01k, False: 1.35k]
  |  Branch (651:26): [True: 2.01k, False: 1]
  ------------------
  652|       |		/* Clean up tDF contents.*/
  653|  2.01k|		struct sc_path tmp_path;
  654|  2.01k|		int ii, len;
  655|  2.01k|		unsigned char lbuf[SC_MAX_APDU_BUFFER_SIZE];
  656|       |
  657|  2.01k|		memset(&tmp_path, 0, sizeof(struct sc_path));
  658|  2.01k|		tmp_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  2.01k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  659|  2.01k|		memcpy(tmp_path.value, sbuf, 2);
  660|  2.01k|		tmp_path.len = 2;
  661|  2.01k|		rv = auth_select_file(card, &tmp_path, NULL);
  662|  2.01k|		LOG_TEST_RET(card->ctx, rv, "select DF failed");
  ------------------
  |  |  174|  2.01k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.01k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.01k|	int _ret = (r); \
  |  |  |  |  168|  2.01k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 9, False: 2.00k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.00k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  663|       |
  664|  2.00k|		len = auth_list_files(card, lbuf, sizeof(lbuf));
  665|  2.00k|		LOG_TEST_RET(card->ctx, len, "list DF failed");
  ------------------
  |  |  174|  2.00k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.00k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.00k|	int _ret = (r); \
  |  |  |  |  168|  2.00k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 1.99k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.00k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.99k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  666|       |
  667|  4.71k|		for (ii = 0; ii < len / 2; ii++) {
  ------------------
  |  Branch (667:16): [True: 3.31k, False: 1.40k]
  ------------------
  668|  3.31k|			struct sc_path tmp_path_x;
  669|       |
  670|  3.31k|			memset(&tmp_path_x, 0, sizeof(struct sc_path));
  671|  3.31k|			tmp_path_x.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|  3.31k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  672|  3.31k|			tmp_path_x.value[0] = *(lbuf + ii*2);
  673|  3.31k|			tmp_path_x.value[1] = *(lbuf + ii*2 + 1);
  674|  3.31k|			tmp_path_x.len = 2;
  675|       |
  676|  3.31k|			rv = auth_delete_file(card, &tmp_path_x);
  677|  3.31k|			LOG_TEST_RET(card->ctx, rv, "delete failed");
  ------------------
  |  |  174|  3.31k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.31k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.31k|	int _ret = (r); \
  |  |  |  |  168|  3.31k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 594, False: 2.72k]
  |  |  |  |  ------------------
  |  |  |  |  169|    594|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    594|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    594|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    594|		return _ret; \
  |  |  |  |  172|    594|	} \
  |  |  |  |  173|  3.31k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  678|  3.31k|		}
  679|       |
  680|  1.40k|		tmp_path.type = SC_PATH_TYPE_PARENT;
  ------------------
  |  |  123|  1.40k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  681|  1.40k|		rv = auth_select_file(card, &tmp_path, NULL);
  682|  1.40k|		LOG_TEST_RET(card->ctx, rv, "select parent failed");
  ------------------
  |  |  174|  1.40k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.40k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.40k|	int _ret = (r); \
  |  |  |  |  168|  1.40k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 1.39k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.40k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.39k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  683|       |
  684|  1.39k|		apdu.p1 = 1;
  685|  1.39k|		rv = sc_transmit_apdu(card, &apdu);
  686|  1.39k|	}
  687|       |
  688|  2.75k|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  2.75k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.75k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.75k|	int _ret = (r); \
  |  |  |  |  168|  2.75k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.75k]
  |  |  |  |  ------------------
  |  |  |  |  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.75k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.75k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  689|  2.75k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  690|       |
  691|  2.75k|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  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|     30|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 30, False: 2.72k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  692|  2.75k|}
card-oberthur.c:auth_create_file:
  910|     17|{
  911|     17|	struct sc_apdu apdu;
  912|     17|	struct sc_path path;
  913|     17|	int rv, rec_nr;
  914|     17|	unsigned char sbuf[0x18];
  915|     17|	size_t sendlen = sizeof(sbuf);
  916|     17|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  917|       |
  918|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  919|       |
  920|     17|	rv = sc_path_print(pbuf, sizeof(pbuf), &file->path);
  921|     17|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|     17|#define SC_SUCCESS				0
  ------------------
  |  Branch (921:6): [True: 0, False: 17]
  ------------------
  922|      0|		pbuf[0] = '\0';
  923|     17|	sc_log(card->ctx, " create path=%s", pbuf);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  924|       |
  925|     17|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  926|     17|	       "id %04X; size %"SC_FORMAT_LEN_SIZE_T"u; type 0x%X; ef 0x%X",
  927|     17|	       file->id, file->size, file->type, file->ef_structure);
  928|       |
  929|     17|	if (file->id==0x0000 || file->id==0xFFFF || file->id==0x3FFF)
  ------------------
  |  Branch (929:6): [True: 0, False: 17]
  |  Branch (929:26): [True: 0, False: 17]
  |  Branch (929:46): [True: 0, False: 17]
  ------------------
  930|     17|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  931|       |
  932|     17|	if (file->path.len) {
  ------------------
  |  Branch (932:6): [True: 17, False: 0]
  ------------------
  933|     17|		memcpy(&path, &file->path, sizeof(path));
  934|     17|		if (path.len>2)
  ------------------
  |  Branch (934:7): [True: 17, False: 0]
  ------------------
  935|     17|			path.len -= 2;
  936|       |
  937|     17|		if (auth_select_file(card, &path, NULL)) {
  ------------------
  |  Branch (937:7): [True: 1, False: 16]
  ------------------
  938|      1|			sc_log(card->ctx, "Cannot select parent DF.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  939|      1|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  940|      1|		}
  941|     17|	}
  942|       |
  943|     16|	rv = encode_file_structure_V5(card, file, sbuf, &sendlen);
  944|     16|	LOG_TEST_RET(card->ctx, rv, "File structure encoding 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: 1, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  945|       |
  946|     15|	if (file->type != SC_FILE_TYPE_DF && file->ef_structure != SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  214|     30|#define SC_FILE_TYPE_DF			0x04
  ------------------
              	if (file->type != SC_FILE_TYPE_DF && file->ef_structure != SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  221|     15|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (946:6): [True: 15, False: 0]
  |  Branch (946:39): [True: 5, False: 10]
  ------------------
  947|      5|		rec_nr = (int)file->record_count;
  948|     10|	else
  949|     10|		rec_nr = 0;
  950|       |
  951|     15|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, rec_nr);
  ------------------
  |  |  293|     15|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  952|     15|	apdu.data = sbuf;
  953|     15|	apdu.datalen = sendlen;
  954|     15|	apdu.lc = sendlen;
  955|       |
  956|     15|	rv = sc_transmit_apdu(card, &apdu);
  957|     15|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  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: 0, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  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|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  958|     15|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
  959|     15|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  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: 3, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  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|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  960|       |
  961|       |	/* select created DF. */
  962|     12|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     12|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (962:6): [True: 0, False: 12]
  ------------------
  963|      0|		struct sc_path tmp_path;
  964|      0|		struct sc_file *df_file = NULL;
  965|       |
  966|      0|		memset(&tmp_path, 0, sizeof(struct sc_path));
  967|      0|		tmp_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      0|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  968|      0|		tmp_path.value[0] = file->id >> 8;
  969|      0|		tmp_path.value[1] = file->id & 0xFF;
  970|      0|		tmp_path.len = 2;
  971|      0|		rv = auth_select_file(card, &tmp_path, &df_file);
  972|      0|		sc_log(card->ctx, "rv %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__
  |  |  ------------------
  ------------------
  973|      0|		sc_file_free(df_file);
  974|      0|	}
  975|       |
  976|     12|	sc_file_free(auth_current_ef);
  977|     12|	auth_current_ef = NULL;
  978|     12|	sc_file_dup(&auth_current_ef, file);
  979|       |
  980|     12|	LOG_FUNC_RETURN(card->ctx, 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: 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|      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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  981|     12|}
card-oberthur.c:encode_file_structure_V5:
  732|     16|{
  733|     16|	size_t ii;
  734|     16|	int rv = 0;
  735|     16|	size_t size;
  736|     16|	unsigned char *p = buf;
  737|     16|	unsigned char  ops[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  738|       |
  739|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|     16|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  741|     16|	       "id %04X; size %"SC_FORMAT_LEN_SIZE_T"u; type 0x%X/0x%X",
  742|     16|	       file->id, file->size, file->type, file->ef_structure);
  743|       |
  744|     16|	if (*buflen < 0x18)
  ------------------
  |  Branch (744:6): [True: 0, False: 16]
  ------------------
  745|     16|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  746|       |
  747|     16|	p[0] = 0x62, p[1] = 0x16;
  748|     16|	p[2] = 0x82, p[3] = 0x02;
  749|       |
  750|     16|	rv = 0;
  751|     16|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     16|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (751:6): [True: 0, False: 16]
  ------------------
  752|      0|		p[4] = 0x38;
  753|      0|		p[5] = 0x00;
  754|     16|	} else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|     16|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (754:13): [True: 10, False: 6]
  ------------------
  755|     10|		switch (file->ef_structure) {
  756|     10|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|     10|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (756:3): [True: 10, False: 0]
  ------------------
  757|     10|			p[4] = 0x01;
  758|     10|			p[5] = 0x01;
  759|     10|			break;
  760|      0|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (760:3): [True: 0, False: 10]
  ------------------
  761|      0|			p[4] = 0x04;
  762|      0|			p[5] = 0x01;
  763|      0|			break;
  764|      0|		default:
  ------------------
  |  Branch (764:3): [True: 0, False: 10]
  ------------------
  765|      0|			rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  766|      0|			break;
  767|     10|		}
  768|     10|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|      6|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (768:13): [True: 5, False: 1]
  ------------------
  769|      5|		switch (file->ef_structure) {
  770|      0|		case SC_CARDCTL_OBERTHUR_KEY_DES:
  ------------------
  |  Branch (770:3): [True: 0, False: 5]
  ------------------
  771|      0|			p[4] = 0x11;
  772|      0|			p[5] = 0x00;
  773|      0|			break;
  774|      4|		case SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC:
  ------------------
  |  Branch (774:3): [True: 4, False: 1]
  ------------------
  775|      4|			p[4] = 0x12;
  776|      4|			p[5] = 0x00;
  777|      4|			break;
  778|      1|		case SC_CARDCTL_OBERTHUR_KEY_RSA_CRT:
  ------------------
  |  Branch (778:3): [True: 1, False: 4]
  ------------------
  779|      1|			p[4] = 0x14;
  780|      1|			p[5] = 0x00;
  781|      1|			break;
  782|      0|		default:
  ------------------
  |  Branch (782:3): [True: 0, False: 5]
  ------------------
  783|      0|			rv = -1;
  784|      0|			break;
  785|      5|		}
  786|      5|	} else
  787|      1|		rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  788|       |
  789|     16|	if (rv) {
  ------------------
  |  Branch (789:6): [True: 1, False: 15]
  ------------------
  790|      1|		sc_log(card->ctx, "Invalid EF structure 0x%X/0x%X", file->type, file->ef_structure);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  791|      1|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  792|      1|	}
  793|       |
  794|     15|	p[6] = 0x83;
  795|     15|	p[7] = 0x02;
  796|     15|	p[8] = file->id >> 8;
  797|     15|	p[9] = file->id & 0xFF;
  798|       |
  799|     15|	p[10] = 0x85;
  800|     15|	p[11] = 0x02;
  801|       |
  802|     15|	size = file->size;
  803|       |
  804|     15|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     15|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (804:6): [True: 0, False: 15]
  ------------------
  805|      0|		size &= 0xFF;
  806|     15|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF &&
  ------------------
  |  |  215|     30|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (806:13): [True: 5, False: 10]
  ------------------
  807|      5|			file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (807:4): [True: 4, False: 1]
  ------------------
  808|      4|		sc_log(card->ctx, "ef %s","SC_FILE_EF_RSA_PUBLIC");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  809|      4|		if (file->size == PUBKEY_512_ASN1_SIZE || file->size == 512)
  ------------------
  |  |  100|      8|#define PUBKEY_512_ASN1_SIZE	0x4A
  ------------------
  |  Branch (809:7): [True: 0, False: 4]
  |  Branch (809:45): [True: 0, False: 4]
  ------------------
  810|      0|			size = 512;
  811|      4|		else if (file->size == PUBKEY_1024_ASN1_SIZE || file->size == 1024)
  ------------------
  |  |  101|      8|#define PUBKEY_1024_ASN1_SIZE	0x8C
  ------------------
  |  Branch (811:12): [True: 0, False: 4]
  |  Branch (811:51): [True: 4, False: 0]
  ------------------
  812|      4|			size = 1024;
  813|      0|		else if (file->size == PUBKEY_2048_ASN1_SIZE || file->size == 2048)
  ------------------
  |  |  102|      0|#define PUBKEY_2048_ASN1_SIZE	0x10E
  ------------------
  |  Branch (813:12): [True: 0, False: 0]
  |  Branch (813:51): [True: 0, False: 0]
  ------------------
  814|      0|			size = 2048;
  815|      0|		else {
  816|      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__
  |  |  ------------------
  ------------------
  817|      0|			       "incorrect RSA size %"SC_FORMAT_LEN_SIZE_T"X",
  818|      0|			       file->size);
  819|      0|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  820|      0|		}
  821|     11|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF &&
  ------------------
  |  |  215|     22|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (821:13): [True: 1, False: 10]
  ------------------
  822|      1|			file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_DES) {
  ------------------
  |  Branch (822:4): [True: 0, False: 1]
  ------------------
  823|      0|		if (file->size == 8 || file->size == 64)
  ------------------
  |  Branch (823:7): [True: 0, False: 0]
  |  Branch (823:26): [True: 0, False: 0]
  ------------------
  824|      0|			size = 64;
  825|      0|		else if (file->size == 16 || file->size == 128)
  ------------------
  |  Branch (825:12): [True: 0, False: 0]
  |  Branch (825:32): [True: 0, False: 0]
  ------------------
  826|      0|			size = 128;
  827|      0|		else if (file->size == 24 || file->size == 192)
  ------------------
  |  Branch (827:12): [True: 0, False: 0]
  |  Branch (827:32): [True: 0, False: 0]
  ------------------
  828|      0|			size = 192;
  829|      0|		else {
  830|      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__
  |  |  ------------------
  ------------------
  831|      0|			       "incorrect DES size %"SC_FORMAT_LEN_SIZE_T"u",
  832|      0|			       file->size);
  833|      0|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  834|      0|		}
  835|      0|	}
  836|       |
  837|     15|	p[12] = (size >> 8) & 0xFF;
  838|     15|	p[13] = size & 0xFF;
  839|       |
  840|     15|	p[14] = 0x86;
  841|     15|	p[15] = 0x08;
  842|       |
  843|     15|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     15|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (843:6): [True: 0, False: 15]
  ------------------
  844|      0|		ops[0] = SC_AC_OP_CREATE;
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
  845|      0|		ops[1] = SC_AC_OP_CRYPTO;
  ------------------
  |  |  173|      0|#define SC_AC_OP_CRYPTO			7
  ------------------
  846|      0|		ops[2] = SC_AC_OP_LIST_FILES;
  ------------------
  |  |  172|      0|#define SC_AC_OP_LIST_FILES		6
  ------------------
  847|      0|		ops[3] = SC_AC_OP_DELETE;
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
  848|      0|		ops[4] = SC_AC_OP_PIN_DEFINE;
  ------------------
  |  |  183|      0|#define SC_AC_OP_PIN_DEFINE		17
  ------------------
  849|      0|		ops[5] = SC_AC_OP_PIN_CHANGE;
  ------------------
  |  |  184|      0|#define SC_AC_OP_PIN_CHANGE		18
  ------------------
  850|      0|		ops[6] = SC_AC_OP_PIN_RESET;
  ------------------
  |  |  185|      0|#define SC_AC_OP_PIN_RESET		19
  ------------------
  851|     15|	} else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|     15|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (851:13): [True: 10, False: 5]
  ------------------
  852|     10|		if (file->ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|     10|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (852:7): [True: 10, False: 0]
  ------------------
  853|     10|			sc_log(card->ctx, "SC_FILE_EF_TRANSPARENT");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  854|     10|			ops[0] = SC_AC_OP_WRITE;
  ------------------
  |  |  190|     10|#define SC_AC_OP_WRITE			24
  ------------------
  855|     10|			ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|     10|#define SC_AC_OP_UPDATE			23
  ------------------
  856|     10|			ops[2] = SC_AC_OP_READ;
  ------------------
  |  |  188|     10|#define SC_AC_OP_READ			22
  ------------------
  857|     10|			ops[3] = SC_AC_OP_ERASE;
  ------------------
  |  |  202|     10|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     10|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  858|     10|		} else if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (858:14): [True: 0, False: 0]
  ------------------
  859|      0|			sc_log(card->ctx, "SC_FILE_EF_LINEAR_VARIABLE");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  860|      0|			ops[0] = SC_AC_OP_WRITE;
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  861|      0|			ops[1] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  862|      0|			ops[2] = SC_AC_OP_READ;
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
  863|      0|			ops[3] = SC_AC_OP_ERASE;
  ------------------
  |  |  202|      0|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|      0|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  864|      0|		}
  865|     10|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) {
  ------------------
  |  |  215|      5|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (865:13): [True: 5, False: 0]
  ------------------
  866|      5|		if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_DES) {
  ------------------
  |  Branch (866:7): [True: 0, False: 5]
  ------------------
  867|      0|			sc_log(card->ctx, "EF_DES");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  868|      0|			ops[0] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  869|      0|			ops[1] = SC_AC_OP_PSO_DECRYPT;
  ------------------
  |  |  175|      0|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  870|      0|			ops[2] = SC_AC_OP_PSO_ENCRYPT;
  ------------------
  |  |  176|      0|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  871|      0|			ops[3] = SC_AC_OP_PSO_COMPUTE_CHECKSUM;
  ------------------
  |  |  179|      0|#define SC_AC_OP_PSO_COMPUTE_CHECKSUM	13
  ------------------
  872|      0|			ops[4] = SC_AC_OP_PSO_VERIFY_CHECKSUM;
  ------------------
  |  |  180|      0|#define SC_AC_OP_PSO_VERIFY_CHECKSUM	14
  ------------------
  873|      0|			ops[5] = SC_AC_OP_INTERNAL_AUTHENTICATE;
  ------------------
  |  |  181|      0|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  874|      0|			ops[6] = SC_AC_OP_EXTERNAL_AUTHENTICATE;
  ------------------
  |  |  182|      0|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  875|      5|		} else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (875:14): [True: 4, False: 1]
  ------------------
  876|      4|			sc_log(card->ctx, "EF_RSA_PUBLIC");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  877|      4|			ops[0] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      4|#define SC_AC_OP_UPDATE			23
  ------------------
  878|      4|			ops[2] = SC_AC_OP_PSO_ENCRYPT;
  ------------------
  |  |  176|      4|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  879|      4|			ops[4] = SC_AC_OP_PSO_VERIFY_SIGNATURE;
  ------------------
  |  |  178|      4|#define SC_AC_OP_PSO_VERIFY_SIGNATURE	12
  ------------------
  880|      4|			ops[6] = SC_AC_OP_EXTERNAL_AUTHENTICATE;
  ------------------
  |  |  182|      4|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  881|      4|		} else if (file->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_CRT) {
  ------------------
  |  Branch (881:14): [True: 1, False: 0]
  ------------------
  882|      1|			sc_log(card->ctx, "EF_RSA_PRIVATE");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  883|      1|			ops[0] = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
  884|      1|			ops[1] = SC_AC_OP_PSO_DECRYPT;
  ------------------
  |  |  175|      1|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  885|      1|			ops[3] = SC_AC_OP_PSO_COMPUTE_SIGNATURE;
  ------------------
  |  |  177|      1|#define SC_AC_OP_PSO_COMPUTE_SIGNATURE	11
  ------------------
  886|      1|			ops[5] = SC_AC_OP_INTERNAL_AUTHENTICATE;
  ------------------
  |  |  181|      1|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  887|      1|		}
  888|      5|	}
  889|       |
  890|    135|	for (ii = 0; ii < sizeof(ops); ii++) {
  ------------------
  |  Branch (890:15): [True: 120, False: 15]
  ------------------
  891|    120|		const struct sc_acl_entry *entry;
  892|       |
  893|    120|		p[16+ii] = 0xFF;
  894|    120|		if (ops[ii]==0xFF)
  ------------------
  |  Branch (894:7): [True: 60, False: 60]
  ------------------
  895|     60|			continue;
  896|     60|		entry = sc_file_get_acl_entry(file, ops[ii]);
  897|     60|		rv = acl_to_ac_byte(card,entry);
  898|     60|		LOG_TEST_RET(card->ctx, rv, "Invalid ACL");
  ------------------
  |  |  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: 0, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  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|     60|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  899|     60|		p[16+ii] = rv;
  900|     60|	}
  901|       |
  902|     15|	*buflen = 0x18;
  903|       |
  904|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  905|     15|}
card-oberthur.c:acl_to_ac_byte:
  697|     60|{
  698|     60|	unsigned key_ref;
  699|       |
  700|     60|	if (e == NULL)
  ------------------
  |  Branch (700:6): [True: 0, False: 60]
  ------------------
  701|      0|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  702|       |
  703|     60|	key_ref = e->key_ref & ~OBERTHUR_PIN_LOCAL;
  ------------------
  |  |   41|     60|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
  704|       |
  705|     60|	switch (e->method) {
  ------------------
  |  Branch (705:10): [True: 60, False: 0]
  ------------------
  706|     56|	case SC_AC_NONE:
  ------------------
  |  |  150|     56|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (706:2): [True: 56, False: 4]
  ------------------
  707|     56|		LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  708|       |
  709|      0|	case SC_AC_CHV:
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (709:2): [True: 0, False: 60]
  ------------------
  710|      0|		if (key_ref > 0 && key_ref < 6)
  ------------------
  |  Branch (710:7): [True: 0, False: 0]
  |  Branch (710:22): [True: 0, False: 0]
  ------------------
  711|      0|			LOG_FUNC_RETURN(card->ctx, (0x20 | key_ref));
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  712|      0|		else
  713|      0|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  714|       |
  715|      4|	case SC_AC_PRO:
  ------------------
  |  |  153|      4|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (715:2): [True: 4, False: 56]
  ------------------
  716|      4|		if (((key_ref & 0xE0) != 0x60) || ((key_ref & 0x18) == 0))
  ------------------
  |  Branch (716:7): [True: 0, False: 4]
  |  Branch (716:37): [True: 0, False: 4]
  ------------------
  717|      4|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  718|      4|		else
  719|      4|			LOG_FUNC_RETURN(card->ctx, key_ref);
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define 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|	} else { \
  |  |  |  |  159|      4|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      4|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      4|	} \
  |  |  |  |  162|      4|	return _ret; \
  |  |  |  |  163|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  720|       |
  721|      0|	case SC_AC_NEVER:
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (721:2): [True: 0, False: 60]
  ------------------
  722|      0|		return 0xff;
  723|     60|	}
  724|       |
  725|      0|	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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  726|      0|}
card-oberthur.c:auth_read_binary:
 2113|  30.1k|{
 2114|  30.1k|	int rv;
 2115|  30.1k|	size_t sz;
 2116|  30.1k|	struct sc_pkcs15_bignum bn[2];
 2117|  30.1k|	unsigned char *out = NULL;
 2118|  30.1k|	bn[0].data = NULL;
 2119|  30.1k|	bn[1].data = NULL;
 2120|       |
 2121|  30.1k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  30.1k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  30.1k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  30.1k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  30.1k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 30.1k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2122|       |
 2123|  30.1k|	if (!auth_current_ef)
  ------------------
  |  Branch (2123:6): [True: 626, False: 29.5k]
  ------------------
 2124|  30.1k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid auth_current_ef");
  ------------------
  |  |  174|    626|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    626|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    626|	int _ret = (r); \
  |  |  |  |  168|    626|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 626, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    626|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    626|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    626|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    626|		return _ret; \
  |  |  |  |  172|    626|	} \
  |  |  |  |  173|    626|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2125|       |
 2126|  29.5k|	sc_log(card->ctx,
  ------------------
  |  |   71|  59.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: 21.0k, False: 8.47k]
  |  |  ------------------
  ------------------
 2127|  29.5k|	       "offset %i; size %"SC_FORMAT_LEN_SIZE_T"u; flags 0x%lX",
 2128|  29.5k|	       offset, count, flags ? *flags : 0);
 2129|  29.5k|	sc_log(card->ctx,"last selected : magic %X; ef %X",
  ------------------
  |  |   71|  29.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__
  |  |  ------------------
  ------------------
 2130|  29.5k|			auth_current_ef->magic, auth_current_ef->ef_structure);
 2131|       |
 2132|  29.5k|	if (offset & ~0x7FFF)
  ------------------
  |  Branch (2132:6): [True: 1, False: 29.5k]
  ------------------
 2133|  29.5k|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid file offset");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2134|       |
 2135|  29.5k|	if (auth_current_ef->magic == SC_FILE_MAGIC &&
  ------------------
  |  |   57|  59.1k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  |  Branch (2135:6): [True: 29.5k, False: 0]
  ------------------
 2136|  29.5k|			auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (2136:4): [True: 9.15k, False: 20.4k]
  ------------------
 2137|  9.15k|		int jj;
 2138|  9.15k|		unsigned char resp[SC_MAX_APDU_RESP_SIZE];
 2139|  9.15k|		size_t resp_len, out_len;
 2140|  9.15k|		struct sc_pkcs15_pubkey_rsa key;
 2141|       |
 2142|  9.15k|		resp_len = sizeof(resp);
 2143|  9.15k|		rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 2144|  9.15k|				2, resp, resp_len);
 2145|  9.15k|		LOG_TEST_RET(card->ctx, rv, "read component failed");
  ------------------
  |  |  174|  9.15k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  9.15k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  9.15k|	int _ret = (r); \
  |  |  |  |  168|  9.15k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8.69k, False: 455]
  |  |  |  |  ------------------
  |  |  |  |  169|  8.69k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.69k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  8.69k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  8.69k|		return _ret; \
  |  |  |  |  172|  8.69k|	} \
  |  |  |  |  173|  9.15k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 455]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2146|       |
 2147|    752|		for (jj=0; jj<rv && *(resp+jj)==0; jj++)
  ------------------
  |  Branch (2147:14): [True: 603, False: 149]
  |  Branch (2147:23): [True: 297, False: 306]
  ------------------
 2148|    297|			;
 2149|       |
 2150|    455|		if (rv - jj == 0)
  ------------------
  |  Branch (2150:7): [True: 149, False: 306]
  ------------------
 2151|    149|			return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|    149|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 2152|    306|		bn[0].data = calloc(1, rv - jj);
 2153|    306|		if (!bn[0].data) {
  ------------------
  |  Branch (2153:7): [True: 0, False: 306]
  ------------------
 2154|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2155|      0|			goto err;
 2156|      0|		}
 2157|    306|		bn[0].len = rv - jj;
 2158|    306|		memcpy(bn[0].data, resp + jj, rv - jj);
 2159|       |
 2160|    306|		rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 2161|    306|				1, resp, resp_len);
 2162|    306|		LOG_TEST_GOTO_ERR(card->ctx, rv, "Cannot read RSA public key component");
  ------------------
  |  |  184|    306|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    306|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    306|	int _ret = (r); \
  |  |  |  |  178|    306|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 83, False: 223]
  |  |  |  |  ------------------
  |  |  |  |  179|     83|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     83|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     83|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     83|		goto err; \
  |  |  |  |  182|     83|	} \
  |  |  |  |  183|    306|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 223]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2163|       |
 2164|    223|		bn[1].data = calloc(1, rv);
 2165|    223|		if (!bn[1].data) {
  ------------------
  |  Branch (2165:7): [True: 0, False: 223]
  ------------------
 2166|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2167|      0|			goto err;
 2168|      0|		}
 2169|    223|		bn[1].len = rv;
 2170|    223|		memcpy(bn[1].data, resp, rv);
 2171|       |
 2172|    223|		key.exponent = bn[0];
 2173|    223|		key.modulus = bn[1];
 2174|       |
 2175|    223|		if (sc_pkcs15_encode_pubkey_rsa(card->ctx, &key, &out, &out_len) != SC_SUCCESS) {
  ------------------
  |  |   28|    223|#define SC_SUCCESS				0
  ------------------
  |  Branch (2175:7): [True: 78, False: 145]
  ------------------
 2176|     78|			rv = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     78|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2177|     78|			LOG_TEST_GOTO_ERR(card->ctx, rv, "cannot encode RSA public key");
  ------------------
  |  |  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: 78, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     78|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     78|		goto err; \
  |  |  |  |  182|     78|	} \
  |  |  |  |  183|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2178|     78|		}
 2179|    145|		else {
 2180|    145|			if (out_len < offset) {
  ------------------
  |  Branch (2180:8): [True: 21, False: 124]
  ------------------
 2181|     21|				rv = SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     21|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
 2182|     21|				goto err;
 2183|     21|			}
 2184|    124|			sz = MIN(out_len - offset, count);
  ------------------
  |  |   70|    124|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 72, False: 52]
  |  |  ------------------
  ------------------
 2185|    124|			memcpy(buf, out + offset, sz);
 2186|       |
 2187|    124|			sc_log_hex(card->ctx, "write_publickey", buf, sz);
  ------------------
  |  |  129|    124|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|    124|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2188|    124|			rv = (int)sz;
 2189|    124|		}
 2190|  20.4k|	} else {
 2191|  20.4k|		rv = iso_ops->read_binary(card, offset, buf, count, 0);
 2192|  20.4k|	}
 2193|       |
 2194|  20.7k|err:
 2195|  20.7k|	free(bn[0].data);
 2196|  20.7k|	free(bn[1].data);
 2197|  20.7k|	free(out);
 2198|       |
 2199|  20.7k|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|  20.7k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  20.7k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  20.7k|	int _ret = r; \
  |  |  |  |  155|  20.7k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.5k, False: 8.13k]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.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|  12.2k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 12.2k, False: 368]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.5k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.5k|	} else { \
  |  |  |  |  159|  8.13k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  8.13k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  8.13k|	} \
  |  |  |  |  162|  20.7k|	return _ret; \
  |  |  |  |  163|  20.7k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2200|  20.7k|}
card-oberthur.c:auth_read_component:
 1481|  9.46k|{
 1482|  9.46k|	struct sc_apdu apdu;
 1483|  9.46k|	int rv;
 1484|  9.46k|	unsigned char resp[SC_MAX_APDU_RESP_SIZE];
 1485|       |
 1486|  9.46k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  9.46k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  9.46k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  9.46k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  9.46k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 9.46k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1487|  9.46k|	sc_log(card->ctx, "num %i, outlen %"SC_FORMAT_LEN_SIZE_T"u, type %i",
  ------------------
  |  |   71|  9.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__
  |  |  ------------------
  ------------------
 1488|  9.46k|	       num, outlen, type);
 1489|       |
 1490|  9.46k|	if (!outlen || type!=SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC)
  ------------------
  |  Branch (1490:6): [True: 0, False: 9.46k]
  |  Branch (1490:17): [True: 0, False: 9.46k]
  ------------------
 1491|  9.46k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1492|       |
 1493|  9.46k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xB4,	num, 0x00);
  ------------------
  |  |  292|  9.46k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1494|  9.46k|	apdu.cla |= 0x80;
 1495|  9.46k|	apdu.le = outlen;
 1496|  9.46k|	apdu.resp = resp;
 1497|  9.46k|	apdu.resplen = sizeof(resp);
 1498|  9.46k|	rv = sc_transmit_apdu(card, &apdu);
 1499|  9.46k|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  9.46k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  9.46k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  9.46k|	int _ret = (r); \
  |  |  |  |  168|  9.46k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 285, False: 9.17k]
  |  |  |  |  ------------------
  |  |  |  |  169|    285|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    285|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    285|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    285|		return _ret; \
  |  |  |  |  172|    285|	} \
  |  |  |  |  173|  9.46k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9.17k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1500|       |
 1501|  9.17k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1502|  9.17k|	LOG_TEST_RET(card->ctx, rv, "Card returned error");
  ------------------
  |  |  174|  9.17k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  9.17k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  9.17k|	int _ret = (r); \
  |  |  |  |  168|  9.17k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8.49k, False: 680]
  |  |  |  |  ------------------
  |  |  |  |  169|  8.49k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.49k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  8.49k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  8.49k|		return _ret; \
  |  |  |  |  172|  8.49k|	} \
  |  |  |  |  173|  9.17k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 680]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1503|       |
 1504|    680|	if (outlen < apdu.resplen)
  ------------------
  |  Branch (1504:6): [True: 1, False: 679]
  ------------------
 1505|    680|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1506|       |
 1507|    679|	memcpy(out, apdu.resp, apdu.resplen);
 1508|    679|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|    679|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    679|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    679|	int _ret = r; \
  |  |  |  |  155|    679|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 227, False: 452]
  |  |  |  |  ------------------
  |  |  |  |  156|    227|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 227]
  |  |  |  |  ------------------
  |  |  |  |  157|    227|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    452|	} else { \
  |  |  |  |  159|    452|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    452|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    452|	} \
  |  |  |  |  162|    679|	return _ret; \
  |  |  |  |  163|    679|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1509|    679|}
card-oberthur.c:auth_update_binary:
 2074|    248|{
 2075|    248|	int rv = 0;
 2076|       |
 2077|    248|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    248|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    248|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    248|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    248|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 248]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2078|       |
 2079|    248|	if (!auth_current_ef)
  ------------------
  |  Branch (2079:6): [True: 0, False: 248]
  ------------------
 2080|    248|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid auth_current_ef");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2081|       |
 2082|    248|	sc_log(card->ctx, "offset %i; count %"SC_FORMAT_LEN_SIZE_T"u", offset,
  ------------------
  |  |   71|    248|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2083|    248|	       count);
 2084|    248|	sc_log(card->ctx, "last selected : magic %X; ef %X",
  ------------------
  |  |   71|    248|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2085|    248|			auth_current_ef->magic, auth_current_ef->ef_structure);
 2086|       |
 2087|    248|	if (offset & ~0x7FFF)
  ------------------
  |  Branch (2087:6): [True: 1, False: 247]
  ------------------
 2088|    248|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid file offset");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2089|       |
 2090|    247|	if (auth_current_ef->magic == SC_FILE_MAGIC &&
  ------------------
  |  |   57|    494|#define SC_FILE_MAGIC			0x14426950
  ------------------
  |  Branch (2090:6): [True: 247, False: 0]
  ------------------
 2091|    247|			auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC) {
  ------------------
  |  Branch (2091:4): [True: 53, False: 194]
  ------------------
 2092|     53|		rv = write_publickey(card, offset, buf, count);
 2093|    194|	} else if (auth_current_ef->magic == SC_FILE_MAGIC &&
  ------------------
  |  |   57|    388|#define SC_FILE_MAGIC			0x14426950
  ------------------
  |  Branch (2093:13): [True: 194, False: 0]
  ------------------
 2094|    194|			auth_current_ef->ef_structure == SC_CARDCTL_OBERTHUR_KEY_DES) {
  ------------------
  |  Branch (2094:4): [True: 0, False: 194]
  ------------------
 2095|      0|		struct auth_update_component_info args;
 2096|       |
 2097|      0|		memset(&args, 0, sizeof(args));
 2098|      0|		args.type = SC_CARDCTL_OBERTHUR_KEY_DES;
 2099|      0|		args.data = (unsigned char *)buf;
 2100|      0|		args.len = count;
 2101|      0|		rv = auth_update_component(card, &args);
 2102|    194|	} else {
 2103|    194|		rv = iso_ops->update_binary(card, offset, buf, count, 0);
 2104|    194|	}
 2105|       |
 2106|    247|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    247|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    247|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    247|	int _ret = r; \
  |  |  |  |  155|    247|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 21, False: 226]
  |  |  |  |  ------------------
  |  |  |  |  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|    226|	} else { \
  |  |  |  |  159|    226|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    226|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    226|	} \
  |  |  |  |  162|    247|	return _ret; \
  |  |  |  |  163|    247|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2107|    247|}
card-oberthur.c:write_publickey:
 2011|     53|{
 2012|     53|	struct auth_update_component_info args;
 2013|     53|	struct sc_pkcs15_pubkey_rsa key;
 2014|     53|	int ii, rv;
 2015|     53|	size_t len = 0, der_size = 0;
 2016|       |
 2017|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2018|       |
 2019|     53|	sc_log_hex(card->ctx, "write_publickey", buf, count);
  ------------------
  |  |  129|     53|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|     53|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2020|       |
 2021|     53|	if (1+offset > sizeof(rsa_der))
  ------------------
  |  Branch (2021:6): [True: 17, False: 36]
  ------------------
 2022|     53|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid offset value");
  ------------------
  |  |  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: 17, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     17|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2023|       |
 2024|     36|	len = offset+count > sizeof(rsa_der) ? sizeof(rsa_der) - offset : count;
  ------------------
  |  Branch (2024:8): [True: 17, False: 19]
  ------------------
 2025|       |
 2026|     36|	memcpy(rsa_der + offset, buf, len);
 2027|     36|	rsa_der_len = offset + len;
 2028|       |
 2029|     36|	if (rsa_der[0] == 0x30) {
  ------------------
  |  Branch (2029:6): [True: 36, False: 0]
  ------------------
 2030|     36|		if (rsa_der[1] & 0x80)
  ------------------
  |  Branch (2030:7): [True: 36, False: 0]
  ------------------
 2031|    488|			for (ii=0; ii < (rsa_der[1]&0x0F); ii++)
  ------------------
  |  Branch (2031:15): [True: 452, False: 36]
  ------------------
 2032|    452|				der_size = der_size*0x100 + rsa_der[2+ii];
 2033|      0|		else
 2034|      0|			der_size = rsa_der[1];
 2035|     36|	}
 2036|       |
 2037|     36|	sc_log(card->ctx, "der_size %"SC_FORMAT_LEN_SIZE_T"u", der_size);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2038|     36|	if (offset + len < der_size + 2)
  ------------------
  |  Branch (2038:6): [True: 36, False: 0]
  ------------------
 2039|     36|		LOG_FUNC_RETURN(card->ctx, (int)len);
  ------------------
  |  |  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: 0, False: 36]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     36|	} else { \
  |  |  |  |  159|     36|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     36|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     36|	} \
  |  |  |  |  162|     36|	return _ret; \
  |  |  |  |  163|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2040|       |
 2041|      0|	rv = sc_pkcs15_decode_pubkey_rsa(card->ctx, &key, rsa_der, rsa_der_len);
 2042|      0|	rsa_der_len = 0;
 2043|      0|	memset(rsa_der, 0, sizeof(rsa_der));
 2044|      0|	LOG_TEST_RET(card->ctx, rv, "cannot decode 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2045|       |
 2046|      0|	memset(&args, 0, sizeof(args));
 2047|      0|	args.type = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
 2048|      0|	args.component = 1;
 2049|      0|	args.data = key.modulus.data;
 2050|      0|	args.len = key.modulus.len;
 2051|      0|	rv = auth_update_component(card, &args);
 2052|      0|	free(args.data);
 2053|      0|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (2053:6): [True: 0, False: 0]
  ------------------
 2054|      0|		free(key.exponent.data);
 2055|      0|		LOG_TEST_RET(card->ctx, rv, "Update component 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2056|      0|	}
 2057|       |
 2058|      0|	memset(&args, 0, sizeof(args));
 2059|      0|	args.type = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
 2060|      0|	args.component = 2;
 2061|      0|	args.data = key.exponent.data;
 2062|      0|	args.len = key.exponent.len;
 2063|      0|	rv = auth_update_component(card, &args);
 2064|      0|	free(args.data);
 2065|      0|	LOG_TEST_RET(card->ctx, rv, "Update component 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2066|       |
 2067|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2068|      0|}
card-oberthur.c:auth_card_ctl:
 1453|    493|{
 1454|    493|	switch (cmd) {
 1455|      0|	case SC_CARDCTL_GET_DEFAULT_KEY:
  ------------------
  |  Branch (1455:2): [True: 0, False: 493]
  ------------------
 1456|      0|		return auth_get_default_key(card,
 1457|      0|				(struct sc_cardctl_default_key *) ptr);
 1458|      2|	case SC_CARDCTL_OBERTHUR_GENERATE_KEY:
  ------------------
  |  Branch (1458:2): [True: 2, False: 491]
  ------------------
 1459|      2|		return auth_generate_key(card, 0,
 1460|      2|				(struct sc_cardctl_oberthur_genkey_info *) ptr);
 1461|      0|	case SC_CARDCTL_OBERTHUR_UPDATE_KEY:
  ------------------
  |  Branch (1461:2): [True: 0, False: 493]
  ------------------
 1462|      0|		return auth_update_key(card,
 1463|      0|				(struct sc_cardctl_oberthur_updatekey_info *) ptr);
 1464|      0|	case SC_CARDCTL_OBERTHUR_CREATE_PIN:
  ------------------
  |  Branch (1464:2): [True: 0, False: 493]
  ------------------
 1465|      0|		return auth_create_reference_data(card,
 1466|      0|				(struct sc_cardctl_oberthur_createpin_info *) ptr);
 1467|     10|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1467:2): [True: 10, False: 483]
  ------------------
 1468|     10|		return auth_get_serialnr(card, (struct sc_serial_number *)ptr);
 1469|      0|	case SC_CARDCTL_LIFECYCLE_GET:
  ------------------
  |  Branch (1469:2): [True: 0, False: 493]
  ------------------
 1470|    481|	case SC_CARDCTL_LIFECYCLE_SET:
  ------------------
  |  Branch (1470:2): [True: 481, False: 12]
  ------------------
 1471|    481|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    481|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1472|      0|	default:
  ------------------
  |  Branch (1472:2): [True: 0, False: 493]
  ------------------
 1473|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1474|    493|	}
 1475|    493|}
card-oberthur.c:auth_generate_key:
 1233|      2|{
 1234|      2|	struct sc_apdu apdu;
 1235|      2|	unsigned char sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1236|      2|	struct sc_path tmp_path;
 1237|      2|	int rv = 0;
 1238|       |
 1239|      2|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1240|      2|	if (data->key_bits < 512 || data->key_bits > 2048 ||
  ------------------
  |  Branch (1240:6): [True: 0, False: 2]
  |  Branch (1240:30): [True: 0, False: 2]
  ------------------
 1241|      2|			(data->key_bits % 0x20) != 0) {
  ------------------
  |  Branch (1241:4): [True: 0, False: 2]
  ------------------
 1242|      0|		LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_ARGUMENTS, "Illegal key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1243|      0|	}
 1244|       |
 1245|      2|	sbuf[0] = (data->id_pub >> 8) & 0xFF;
 1246|      2|	sbuf[1] = data->id_pub & 0xFF;
 1247|      2|	sbuf[2] = (data->id_prv >> 8) & 0xFF;
 1248|      2|	sbuf[3] = data->id_prv & 0xFF;
 1249|      2|	if (data->exponent != 0x10001) {
  ------------------
  |  Branch (1249:6): [True: 0, False: 2]
  ------------------
 1250|      0|		rv = auth_encode_exponent(data->exponent, &sbuf[5],SC_MAX_APDU_BUFFER_SIZE-6);
  ------------------
  |  |   34|      0|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
 1251|      0|		LOG_TEST_RET(card->ctx, rv, "Cannot encode exponent");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1252|       |
 1253|      0|		sbuf[4] = rv;
 1254|      0|		rv++;
 1255|      0|	}
 1256|       |
 1257|      2|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x46, 0x00, 0x00);
  ------------------
  |  |  294|      2|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 1258|      2|	apdu.resp = calloc(1, data->key_bits/8+8);
 1259|      2|	if (!apdu.resp)
  ------------------
  |  Branch (1259:6): [True: 0, False: 2]
  ------------------
 1260|      2|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1261|       |
 1262|      2|	apdu.resplen = data->key_bits/8+8;
 1263|      2|	apdu.lc = rv + 4;
 1264|      2|	apdu.le = data->key_bits/8;
 1265|      2|	apdu.data = sbuf;
 1266|      2|	apdu.datalen = rv + 4;
 1267|       |
 1268|      2|	rv = sc_transmit_apdu(card, &apdu);
 1269|      2|	LOG_TEST_GOTO_ERR(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  184|      2|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      2|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      2|	int _ret = (r); \
  |  |  |  |  178|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1270|      2|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1271|      2|	LOG_TEST_GOTO_ERR(card->ctx, rv, "Card returned error");
  ------------------
  |  |  184|      2|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      2|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      2|	int _ret = (r); \
  |  |  |  |  178|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1272|       |
 1273|      2|	memset(&tmp_path, 0, sizeof(struct sc_path));
 1274|      2|	tmp_path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      2|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
 1275|      2|	tmp_path.len = 2;
 1276|      2|	memcpy(tmp_path.value, sbuf, 2);
 1277|       |
 1278|      2|	rv = auth_select_file(card, &tmp_path, NULL);
 1279|      2|	LOG_TEST_GOTO_ERR(card->ctx, rv, "cannot select public key");
  ------------------
  |  |  184|      2|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      2|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      2|	int _ret = (r); \
  |  |  |  |  178|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1280|       |
 1281|      2|	rv = auth_read_component(card, SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC,
 1282|      2|			1, apdu.resp, data->key_bits/8);
 1283|      2|	LOG_TEST_GOTO_ERR(card->ctx, rv, "auth_read_component() returned error");
  ------------------
  |  |  184|      2|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      2|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      2|	int _ret = (r); \
  |  |  |  |  178|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1284|       |
 1285|      1|	apdu.resplen = rv;
 1286|       |
 1287|      1|	if (data->pubkey) {
  ------------------
  |  Branch (1287:6): [True: 1, False: 0]
  ------------------
 1288|      1|		if (data->pubkey_len < apdu.resplen) {
  ------------------
  |  Branch (1288:7): [True: 0, False: 1]
  ------------------
 1289|      0|			rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1290|      0|			LOG_TEST_GOTO_ERR(card->ctx, rv, "invalid length received");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1291|      0|		}
 1292|       |
 1293|      1|		memcpy(data->pubkey,apdu.resp,apdu.resplen);
 1294|      1|	}
 1295|       |
 1296|      1|	data->pubkey_len = apdu.resplen;
 1297|      1|	free(apdu.resp);
 1298|       |
 1299|      1|	sc_log(card->ctx, "resulted public key len %"SC_FORMAT_LEN_SIZE_T"u",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1300|      1|	       apdu.resplen);
 1301|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1302|      1|err:
 1303|      1|	free(apdu.resp);
 1304|      1|	return rv;
 1305|      1|}
card-oberthur.c:auth_init_pin_info:
 1540|    394|{
 1541|    394|	pin->offset = 0;
 1542|    394|	pin->pad_char   = 0xFF;
 1543|    394|	pin->encoding   = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  432|    394|#define SC_PIN_ENCODING_ASCII	0
  ------------------
 1544|       |
 1545|    394|	if (type == OBERTHUR_AUTH_TYPE_PIN) {
  ------------------
  |  |   92|    394|#define OBERTHUR_AUTH_TYPE_PIN		1
  ------------------
  |  Branch (1545:6): [True: 394, False: 0]
  ------------------
 1546|    394|		pin->max_length = OBERTHUR_AUTH_MAX_LENGTH_PIN;
  ------------------
  |  |   95|    394|#define OBERTHUR_AUTH_MAX_LENGTH_PIN	64
  ------------------
 1547|    394|		pin->pad_length = OBERTHUR_AUTH_MAX_LENGTH_PIN;
  ------------------
  |  |   95|    394|#define OBERTHUR_AUTH_MAX_LENGTH_PIN	64
  ------------------
 1548|    394|	} else {
 1549|      0|		pin->max_length = OBERTHUR_AUTH_MAX_LENGTH_PUK;
  ------------------
  |  |   96|      0|#define OBERTHUR_AUTH_MAX_LENGTH_PUK	16
  ------------------
 1550|      0|		pin->pad_length = OBERTHUR_AUTH_MAX_LENGTH_PUK;
  ------------------
  |  |   96|      0|#define OBERTHUR_AUTH_MAX_LENGTH_PUK	16
  ------------------
 1551|      0|	}
 1552|    394|}
card-oberthur.c:auth_get_serialnr:
 2264|     10|{
 2265|     10|	if (!serial)
  ------------------
  |  Branch (2265:6): [True: 0, False: 10]
  ------------------
 2266|     10|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2267|       |
 2268|     10|	if (card->serialnr.len==0)
  ------------------
  |  Branch (2268:6): [True: 0, False: 10]
  ------------------
 2269|     10|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2270|       |
 2271|     10|	memcpy(serial, &card->serialnr, sizeof(*serial));
 2272|       |
 2273|     10|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2274|     10|}
card-oberthur.c:auth_process_fci:
  297|  8.78k|{
  298|  8.78k|	unsigned char type;
  299|  8.78k|	const unsigned char *attr;
  300|  8.78k|	size_t attr_len = 0;
  301|       |
  302|  8.78k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  8.78k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  8.78k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  8.78k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  8.78k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 8.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  303|  8.78k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x82, &attr_len);
  304|  8.78k|	if (!attr || attr_len < 1)
  ------------------
  |  Branch (304:6): [True: 3.25k, False: 5.53k]
  |  Branch (304:15): [True: 812, False: 4.72k]
  ------------------
  305|  8.78k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  4.06k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.06k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.06k|	int _ret = r; \
  |  |  |  |  155|  4.06k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.06k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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|  4.06k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.06k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.06k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.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|  4.06k|	return _ret; \
  |  |  |  |  163|  4.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  306|  4.72k|	type = attr[0];
  307|       |
  308|  4.72k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x83, &attr_len);
  309|  4.72k|	if (!attr || attr_len < 2)
  ------------------
  |  Branch (309:6): [True: 1.04k, False: 3.67k]
  |  Branch (309:15): [True: 18, False: 3.66k]
  ------------------
  310|  4.72k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  311|  3.66k|	file->id = attr[0]*0x100 + attr[1];
  312|       |
  313|  3.66k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, type==0x01 ? 0x80 : 0x85, &attr_len);
  ------------------
  |  Branch (313:50): [True: 1.85k, False: 1.80k]
  ------------------
  314|  3.66k|	switch (type) {
  315|  1.85k|	case 0x01:
  ------------------
  |  Branch (315:2): [True: 1.85k, False: 1.80k]
  ------------------
  316|  1.85k|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (316:7): [True: 39, False: 1.81k]
  |  Branch (316:16): [True: 64, False: 1.75k]
  ------------------
  317|  1.85k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    103|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    103|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    103|	int _ret = r; \
  |  |  |  |  155|    103|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 103, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    103|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    103|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 103, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    103|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    103|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    103|	return _ret; \
  |  |  |  |  163|    103|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  318|  1.75k|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|  1.75k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  319|  1.75k|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|  1.75k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  320|  1.75k|		file->size = attr[0]*0x100 + attr[1];
  321|  1.75k|		break;
  322|      0|	case 0x04:
  ------------------
  |  Branch (322:2): [True: 0, False: 3.66k]
  ------------------
  323|      0|		if (!attr || attr_len < 1)
  ------------------
  |  Branch (323:7): [True: 0, False: 0]
  |  Branch (323:16): [True: 0, False: 0]
  ------------------
  324|      0|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  325|      0|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  326|      0|		file->ef_structure = SC_FILE_EF_LINEAR_VARIABLE;
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  327|      0|		file->size = attr[0];
  328|      0|		attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x82, &attr_len);
  329|      0|		if (!attr || attr_len < 5)
  ------------------
  |  Branch (329:7): [True: 0, False: 0]
  |  Branch (329:16): [True: 0, False: 0]
  ------------------
  330|      0|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  331|      0|		file->record_length = attr[2]*0x100+attr[3];
  332|      0|		file->record_count = attr[4];
  333|      0|		break;
  334|     74|	case 0x11:
  ------------------
  |  Branch (334:2): [True: 74, False: 3.58k]
  ------------------
  335|     74|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (335:7): [True: 8, False: 66]
  |  Branch (335:16): [True: 9, False: 57]
  ------------------
  336|     74|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  337|     57|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     57|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  338|     57|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_DES;
  339|     57|		file->size = attr[0]*0x100 + attr[1];
  340|     57|		file->size /= 8;
  341|     57|		break;
  342|    279|	case 0x12:
  ------------------
  |  Branch (342:2): [True: 279, False: 3.38k]
  ------------------
  343|    279|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (343:7): [True: 24, False: 255]
  |  Branch (343:16): [True: 0, False: 255]
  ------------------
  344|    279|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  345|    255|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|    255|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  346|    255|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
  347|       |
  348|    255|		file->size = attr[0]*0x100 + attr[1];
  349|    255|		if (file->size==512)
  ------------------
  |  Branch (349:7): [True: 0, False: 255]
  ------------------
  350|      0|			file->size = PUBKEY_512_ASN1_SIZE;
  ------------------
  |  |  100|      0|#define PUBKEY_512_ASN1_SIZE	0x4A
  ------------------
  351|    255|		else if (file->size==1024)
  ------------------
  |  Branch (351:12): [True: 0, False: 255]
  ------------------
  352|      0|			file->size = PUBKEY_1024_ASN1_SIZE;
  ------------------
  |  |  101|      0|#define PUBKEY_1024_ASN1_SIZE	0x8C
  ------------------
  353|    255|		else if (file->size==2048)
  ------------------
  |  Branch (353:12): [True: 0, False: 255]
  ------------------
  354|      0|			file->size = PUBKEY_2048_ASN1_SIZE;
  ------------------
  |  |  102|      0|#define PUBKEY_2048_ASN1_SIZE	0x10E
  ------------------
  355|    255|		else {
  356|    255|			sc_log(card->ctx,
  ------------------
  |  |   71|    255|#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|    255|			       "Not supported public key size: %"SC_FORMAT_LEN_SIZE_T"u",
  358|    255|			       file->size);
  359|    255|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    255|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    255|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    255|	int _ret = r; \
  |  |  |  |  155|    255|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 255, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    255|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    255|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 255, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    255|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    255|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    255|	return _ret; \
  |  |  |  |  163|    255|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  360|    255|		}
  361|      0|		break;
  362|     16|	case 0x14:
  ------------------
  |  Branch (362:2): [True: 16, False: 3.64k]
  ------------------
  363|     16|		if (!attr || attr_len < 2)
  ------------------
  |  Branch (363:7): [True: 14, False: 2]
  |  Branch (363:16): [True: 2, False: 0]
  ------------------
  364|     16|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|      0|		file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|      0|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  366|      0|		file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_RSA_CRT;
  367|      0|		file->size = attr[0]*0x100 + attr[1];
  368|      0|		break;
  369|  1.25k|	case 0x38:
  ------------------
  |  Branch (369:2): [True: 1.25k, False: 2.40k]
  ------------------
  370|  1.25k|		if (!attr || attr_len < 1)
  ------------------
  |  Branch (370:7): [True: 97, False: 1.15k]
  |  Branch (370:16): [True: 8, False: 1.14k]
  ------------------
  371|  1.25k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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|    105|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 105, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  372|  1.14k|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|  1.14k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  373|  1.14k|		file->size = attr[0];
  374|  1.14k|		if (SC_SUCCESS != sc_file_set_type_attr(file,attr,attr_len))
  ------------------
  |  |   28|  1.14k|#define SC_SUCCESS				0
  ------------------
  |  Branch (374:7): [True: 0, False: 1.14k]
  ------------------
  375|  1.14k|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|  1.14k|		break;
  377|  1.14k|	default:
  ------------------
  |  Branch (377:2): [True: 185, False: 3.47k]
  ------------------
  378|    185|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    185|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    185|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    185|	int _ret = r; \
  |  |  |  |  155|    185|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 185, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    185|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    185|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 185, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    185|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    185|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    185|	return _ret; \
  |  |  |  |  163|    185|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|  3.66k|	}
  380|       |
  381|  2.95k|	attr = sc_asn1_find_tag(card->ctx, buf, buflen, 0x86, &attr_len);
  382|  2.95k|	if (!attr || attr_len < 8)
  ------------------
  |  Branch (382:6): [True: 781, False: 2.17k]
  |  Branch (382:15): [True: 1.79k, False: 383]
  ------------------
  383|  2.95k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  2.57k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.57k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.57k|	int _ret = r; \
  |  |  |  |  155|  2.57k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.57k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|  2.57k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.57k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.57k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.57k|	return _ret; \
  |  |  |  |  163|  2.57k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|       |
  385|    383|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|    383|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (385:6): [True: 319, False: 64]
  ------------------
  386|    319|		add_acl_entry(card, file, SC_AC_OP_CREATE, attr[0]);
  ------------------
  |  |  169|    319|#define SC_AC_OP_CREATE			3
  ------------------
  387|    319|		add_acl_entry(card, file, SC_AC_OP_CRYPTO, attr[1]);
  ------------------
  |  |  173|    319|#define SC_AC_OP_CRYPTO			7
  ------------------
  388|    319|		add_acl_entry(card, file, SC_AC_OP_LIST_FILES, attr[2]);
  ------------------
  |  |  172|    319|#define SC_AC_OP_LIST_FILES		6
  ------------------
  389|    319|		add_acl_entry(card, file, SC_AC_OP_DELETE, attr[3]);
  ------------------
  |  |  168|    319|#define SC_AC_OP_DELETE			2
  ------------------
  390|    319|		add_acl_entry(card, file, SC_AC_OP_PIN_DEFINE, attr[4]);
  ------------------
  |  |  183|    319|#define SC_AC_OP_PIN_DEFINE		17
  ------------------
  391|    319|		add_acl_entry(card, file, SC_AC_OP_PIN_CHANGE, attr[5]);
  ------------------
  |  |  184|    319|#define SC_AC_OP_PIN_CHANGE		18
  ------------------
  392|    319|		add_acl_entry(card, file, SC_AC_OP_PIN_RESET, attr[6]);
  ------------------
  |  |  185|    319|#define SC_AC_OP_PIN_RESET		19
  ------------------
  393|    319|		sc_log(card->ctx, "SC_FILE_TYPE_DF:CRYPTO %X", attr[1]);
  ------------------
  |  |   71|    319|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  394|    319|	} else if (file->type == SC_FILE_TYPE_INTERNAL_EF) { /* EF */
  ------------------
  |  |  215|     64|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (394:13): [True: 5, False: 59]
  ------------------
  395|      5|		switch (file->ef_structure) {
  ------------------
  |  Branch (395:11): [True: 5, False: 0]
  ------------------
  396|      5|		case SC_CARDCTL_OBERTHUR_KEY_DES:
  ------------------
  |  Branch (396:3): [True: 5, False: 0]
  ------------------
  397|      5|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|      5|#define SC_AC_OP_UPDATE			23
  ------------------
  398|      5|			add_acl_entry(card, file, SC_AC_OP_PSO_DECRYPT, attr[1]);
  ------------------
  |  |  175|      5|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  399|      5|			add_acl_entry(card, file, SC_AC_OP_PSO_ENCRYPT, attr[2]);
  ------------------
  |  |  176|      5|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  400|      5|			add_acl_entry(card, file, SC_AC_OP_PSO_COMPUTE_CHECKSUM, attr[3]);
  ------------------
  |  |  179|      5|#define SC_AC_OP_PSO_COMPUTE_CHECKSUM	13
  ------------------
  401|      5|			add_acl_entry(card, file, SC_AC_OP_PSO_VERIFY_CHECKSUM, attr[4]);
  ------------------
  |  |  180|      5|#define SC_AC_OP_PSO_VERIFY_CHECKSUM	14
  ------------------
  402|      5|			add_acl_entry(card, file, SC_AC_OP_INTERNAL_AUTHENTICATE, attr[5]);
  ------------------
  |  |  181|      5|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  403|      5|			add_acl_entry(card, file, SC_AC_OP_EXTERNAL_AUTHENTICATE, attr[6]);
  ------------------
  |  |  182|      5|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  404|      5|			break;
  405|      0|		case SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC:
  ------------------
  |  Branch (405:3): [True: 0, False: 5]
  ------------------
  406|      0|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  407|      0|			add_acl_entry(card, file, SC_AC_OP_PSO_ENCRYPT, attr[2]);
  ------------------
  |  |  176|      0|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
  408|      0|			add_acl_entry(card, file, SC_AC_OP_PSO_VERIFY_SIGNATURE, attr[4]);
  ------------------
  |  |  178|      0|#define SC_AC_OP_PSO_VERIFY_SIGNATURE	12
  ------------------
  409|      0|			add_acl_entry(card, file, SC_AC_OP_EXTERNAL_AUTHENTICATE, attr[6]);
  ------------------
  |  |  182|      0|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  410|      0|			break;
  411|      0|		case SC_CARDCTL_OBERTHUR_KEY_RSA_CRT:
  ------------------
  |  Branch (411:3): [True: 0, False: 5]
  ------------------
  412|      0|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[0]);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  413|      0|			add_acl_entry(card, file, SC_AC_OP_PSO_DECRYPT, attr[1]);
  ------------------
  |  |  175|      0|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  414|      0|			add_acl_entry(card, file, SC_AC_OP_PSO_COMPUTE_SIGNATURE, attr[3]);
  ------------------
  |  |  177|      0|#define SC_AC_OP_PSO_COMPUTE_SIGNATURE	11
  ------------------
  415|      0|			add_acl_entry(card, file, SC_AC_OP_INTERNAL_AUTHENTICATE, attr[5]);
  ------------------
  |  |  181|      0|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
  416|      0|			break;
  417|      5|		}
  418|     59|	} else {
  419|     59|		switch (file->ef_structure) {
  ------------------
  |  Branch (419:11): [True: 59, False: 0]
  ------------------
  420|     59|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|     59|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (420:3): [True: 59, False: 0]
  ------------------
  421|     59|			add_acl_entry(card, file, SC_AC_OP_WRITE, attr[0]);
  ------------------
  |  |  190|     59|#define SC_AC_OP_WRITE			24
  ------------------
  422|     59|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[1]);
  ------------------
  |  |  189|     59|#define SC_AC_OP_UPDATE			23
  ------------------
  423|     59|			add_acl_entry(card, file, SC_AC_OP_READ, attr[2]);
  ------------------
  |  |  188|     59|#define SC_AC_OP_READ			22
  ------------------
  424|     59|			add_acl_entry(card, file, SC_AC_OP_ERASE, attr[3]);
  ------------------
  |  |  202|     59|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     59|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  425|     59|			break;
  426|      0|		case SC_FILE_EF_LINEAR_VARIABLE:
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (426:3): [True: 0, False: 59]
  ------------------
  427|      0|			add_acl_entry(card, file, SC_AC_OP_WRITE, attr[0]);
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  428|      0|			add_acl_entry(card, file, SC_AC_OP_UPDATE, attr[1]);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  429|      0|			add_acl_entry(card, file, SC_AC_OP_READ, attr[2]);
  ------------------
  |  |  188|      0|#define SC_AC_OP_READ			22
  ------------------
  430|      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
  |  |  ------------------
  ------------------
  431|      0|			break;
  432|     59|		}
  433|     59|	}
  434|       |
  435|    383|	file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|    383|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  436|    383|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|    383|#define SC_FILE_MAGIC			0x14426950
  ------------------
  437|       |
  438|    383|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    383|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    383|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    383|	int _ret = r; \
  |  |  |  |  155|    383|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 383, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    383|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 383]
  |  |  |  |  ------------------
  |  |  |  |  157|    383|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    383|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    383|	return _ret; \
  |  |  |  |  163|    383|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  439|    383|}
card-oberthur.c:add_acl_entry:
  260|  2.50k|{
  261|  2.50k|	if ((acl_byte & 0xE0) == 0x60) {
  ------------------
  |  Branch (261:6): [True: 915, False: 1.58k]
  ------------------
  262|    915|		sc_log(card->ctx, "called; op 0x%X; SC_AC_PRO; ref 0x%X", op, acl_byte);
  ------------------
  |  |   71|    915|#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|    915|		sc_file_add_acl_entry(file, op, SC_AC_PRO, acl_byte);
  ------------------
  |  |  153|    915|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  264|    915|		return;
  265|    915|	}
  266|       |
  267|  1.58k|	switch (acl_byte) {
  268|    192|	case 0x00:
  ------------------
  |  Branch (268:2): [True: 192, False: 1.39k]
  ------------------
  269|    192|		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|    192|#define SC_AC_NONE			0x00000000
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|    192|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  270|    192|		break;
  271|       |	/* User and OneTime PINs are locals */
  272|      0|	case 0x21:
  ------------------
  |  Branch (272:2): [True: 0, False: 1.58k]
  ------------------
  273|      0|	case 0x22:
  ------------------
  |  Branch (273:2): [True: 0, False: 1.58k]
  ------------------
  274|      0|		sc_file_add_acl_entry(file, op, SC_AC_CHV, (acl_byte & 0x0F) | OBERTHUR_PIN_LOCAL);
  ------------------
  |  |  151|      0|#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|      0|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
  275|      0|		break;
  276|       |	/* Local SOPIN is only for the unblocking. */
  277|      0|	case 0x24:
  ------------------
  |  Branch (277:2): [True: 0, False: 1.58k]
  ------------------
  278|    120|	case 0x25:
  ------------------
  |  Branch (278:2): [True: 120, False: 1.46k]
  ------------------
  279|    120|		if (op == SC_AC_OP_PIN_RESET)
  ------------------
  |  |  185|    120|#define SC_AC_OP_PIN_RESET		19
  ------------------
  |  Branch (279:7): [True: 120, False: 0]
  ------------------
  280|    120|			sc_file_add_acl_entry(file, op, SC_AC_CHV, 0x84);
  ------------------
  |  |  151|    120|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  281|      0|		else
  282|      0|			sc_file_add_acl_entry(file, op, SC_AC_CHV, 0x04);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  283|    120|		break;
  284|     31|	case 0xFF:
  ------------------
  |  Branch (284:2): [True: 31, False: 1.55k]
  ------------------
  285|     31|		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  163|     31|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_NEVER, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|     31|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  286|     31|		break;
  287|  1.24k|	default:
  ------------------
  |  Branch (287:2): [True: 1.24k, False: 343]
  ------------------
  288|  1.24k|		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  162|  1.24k|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		sc_file_add_acl_entry(file, op, SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|  1.24k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  289|  1.24k|		break;
  290|  1.58k|	}
  291|  1.58k|}
card-oberthur.c:auth_pin_cmd:
 1894|    404|{
 1895|    404|	int rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    404|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1896|       |
 1897|    404|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    404|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    404|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    404|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    404|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 404]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1898|    404|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|    404|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1898:6): [True: 0, False: 404]
  ------------------
 1899|    404|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1900|       |
 1901|    404|	sc_log(card->ctx, "PIN CMD:%i; reference:%i; pin1:%p/%zu, pin2:%p/%zu", data->cmd,
  ------------------
  |  |   71|    404|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1902|    404|			data->pin_reference, data->pin1.data, data->pin1.len,
 1903|    404|			data->pin2.data, data->pin2.len);
 1904|    404|	switch (data->cmd) {
 1905|    394|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  422|    394|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1905:2): [True: 394, False: 10]
  ------------------
 1906|    394|		rv = auth_pin_verify(card, SC_AC_CHV, data);
  ------------------
  |  |  151|    394|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1907|    394|		LOG_TEST_RET(card->ctx, rv, "CMD 'PIN VERIFY' failed");
  ------------------
  |  |  174|    394|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    394|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    394|	int _ret = (r); \
  |  |  |  |  168|    394|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 34, False: 360]
  |  |  |  |  ------------------
  |  |  |  |  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|    394|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 360]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1908|    360|		break;
 1909|    360|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1909:2): [True: 0, False: 404]
  ------------------
 1910|      0|		rv = auth_pin_change(card, SC_AC_CHV, data);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1911|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1912|      0|		break;
 1913|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1913:2): [True: 0, False: 404]
  ------------------
 1914|      0|		rv = auth_pin_reset(card, SC_AC_CHV, data);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1915|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1916|      0|		break;
 1917|     10|	default:
  ------------------
  |  Branch (1917:2): [True: 10, False: 394]
  ------------------
 1918|     10|		LOG_TEST_RET(card->ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported PIN operation");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1919|    404|	}
 1920|       |
 1921|    360|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    360|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    360|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    360|	int _ret = r; \
  |  |  |  |  155|    360|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 360, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    360|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 360]
  |  |  |  |  ------------------
  |  |  |  |  157|    360|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    360|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    360|	return _ret; \
  |  |  |  |  163|    360|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1922|    360|}
card-oberthur.c:auth_pin_verify:
 1614|    394|{
 1615|    394|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1616|    394|	int rv;
 1617|       |
 1618|    394|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    394|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    394|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    394|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    394|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 394]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1619|       |
 1620|    394|	if (type != SC_AC_CHV)
  ------------------
  |  |  151|    394|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1620:6): [True: 0, False: 394]
  ------------------
 1621|    394|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1622|       |
 1623|    394|	data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  429|    394|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 1624|       |
 1625|    394|	auth_init_pin_info(card, &data->pin1, OBERTHUR_AUTH_TYPE_PIN);
  ------------------
  |  |   92|    394|#define OBERTHUR_AUTH_TYPE_PIN		1
  ------------------
 1626|       |
 1627|       |	/* User PIN is always local. */
 1628|    394|	if (data->pin_reference == OBERTHUR_PIN_REFERENCE_USER
  ------------------
  |  |   42|    788|#define OBERTHUR_PIN_REFERENCE_USER	0x81
  ------------------
  |  Branch (1628:6): [True: 183, False: 211]
  ------------------
 1629|    211|			|| data->pin_reference == OBERTHUR_PIN_REFERENCE_ONETIME)
  ------------------
  |  |   43|    211|#define OBERTHUR_PIN_REFERENCE_ONETIME	0x82
  ------------------
  |  Branch (1629:7): [True: 0, False: 211]
  ------------------
 1630|    183|		data->pin_reference  |= OBERTHUR_PIN_LOCAL;
  ------------------
  |  |   41|    183|#define OBERTHUR_PIN_LOCAL	0x80
  ------------------
 1631|       |
 1632|    394|        rv = auth_pin_is_verified(card, data->pin_reference, &data->pin1.tries_left);
 1633|    394|    	sc_log(card->ctx, "auth_pin_is_verified returned rv %i", rv);
  ------------------
  |  |   71|    394|#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|       |	/* Return if only PIN status has been asked. */
 1636|    394|	if (data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1636:6): [True: 394, False: 0]
  |  Branch (1636:25): [True: 394, False: 0]
  ------------------
 1637|    394|		LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    394|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    394|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    394|	int _ret = r; \
  |  |  |  |  155|    394|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 394, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    394|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 360]
  |  |  |  |  ------------------
  |  |  |  |  157|    394|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    394|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    394|	return _ret; \
  |  |  |  |  163|    394|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1638|       |
 1639|       |	/* Return SUCCESS without verifying if
 1640|       |	 * PIN has been already verified and PIN pad has to be used. */
 1641|      0|	if (!rv && !data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1641:6): [True: 0, False: 0]
  |  Branch (1641:13): [True: 0, False: 0]
  |  Branch (1641:33): [True: 0, False: 0]
  ------------------
 1642|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1643|       |
 1644|      0|	if (!data->pin1.data && !data->pin1.len)
  ------------------
  |  Branch (1644:6): [True: 0, False: 0]
  |  Branch (1644:26): [True: 0, False: 0]
  ------------------
 1645|      0|		rv = auth_pin_verify_pinpad(card, data->pin_reference, &data->pin1.tries_left);
 1646|      0|	else
 1647|      0|		rv = iso_drv->ops->pin_cmd(card, data);
 1648|       |
 1649|      0|	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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1650|      0|}
card-oberthur.c:auth_pin_is_verified:
 1655|    394|{
 1656|    394|	struct sc_apdu apdu;
 1657|    394|	int rv;
 1658|       |
 1659|    394|	sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0x20, 0, pin_reference);
  ------------------
  |  |  291|    394|#define SC_APDU_CASE_1			0x01
  ------------------
 1660|       |
 1661|    394|	rv = sc_transmit_apdu(card, &apdu);
 1662|    394|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|    394|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    394|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    394|	int _ret = (r); \
  |  |  |  |  168|    394|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 394]
  |  |  |  |  ------------------
  |  |  |  |  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|    394|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 394]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1663|       |
 1664|    394|	if (tries_left && apdu.sw1 == 0x63 && (apdu.sw2 & 0xF0) == 0xC0)
  ------------------
  |  Branch (1664:6): [True: 394, False: 0]
  |  Branch (1664:20): [True: 5, False: 389]
  |  Branch (1664:40): [True: 2, False: 3]
  ------------------
 1665|      2|		*tries_left = apdu.sw2 & 0x0F;
 1666|       |
 1667|       |	/* Replace 'no tries left' with 'auth method blocked' */
 1668|    394|	if (apdu.sw1 == 0x63 && apdu.sw2 == 0xC0) {
  ------------------
  |  Branch (1668:6): [True: 5, False: 389]
  |  Branch (1668:26): [True: 0, False: 5]
  ------------------
 1669|      0|		apdu.sw1 = 0x69;
 1670|      0|		apdu.sw2 = 0x83;
 1671|      0|	}
 1672|       |
 1673|    394|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1674|       |
 1675|    394|	return rv;
 1676|    394|}
card-oberthur.c:auth_check_sw:
 2287|  74.8k|{
 2288|  74.8k|	int ii;
 2289|       |
 2290|   149k|	for (ii = 0; auth_warnings[ii].SWs; ii++) {
  ------------------
  |  Branch (2290:15): [True: 74.8k, False: 74.4k]
  ------------------
 2291|  74.8k|		if (auth_warnings[ii].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (2291:7): [True: 334, False: 74.4k]
  ------------------
 2292|    334|			sc_log(card->ctx, "%s", auth_warnings[ii].errorstr);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2293|    334|			return auth_warnings[ii].errorno;
 2294|    334|		}
 2295|  74.8k|	}
 2296|       |
 2297|  74.4k|	return iso_ops->check_sw(card, sw1, sw2);
 2298|  74.8k|}

populate_blobs_to_mf:
  381|    329|{
  382|    329|	pgp_do_info_t	*info;
  383|  21.9k|	for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) {
  ------------------
  |  Branch (383:33): [True: 21.9k, False: 0]
  |  Branch (383:51): [True: 21.6k, False: 329]
  ------------------
  384|  21.6k|		if (((info->access & READ_MASK) != READ_NEVER) && (info->get_fn != NULL)) {
  ------------------
  |  Branch (384:7): [True: 16.1k, False: 5.54k]
  |  Branch (384:53): [True: 6.82k, False: 9.28k]
  ------------------
  385|  6.82k|			pgp_blob_t *child = NULL;
  386|  6.82k|			sc_file_t *file = sc_file_new();
  387|       |
  388|  6.82k|			child = pgp_new_blob(card, priv->mf, info->id, file);
  389|       |
  390|       |			/* catch out of memory condition */
  391|  6.82k|			if (child == NULL) {
  ------------------
  |  Branch (391:8): [True: 0, False: 6.82k]
  ------------------
  392|      0|				sc_file_free(file);
  393|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  394|      0|			}
  395|  6.82k|		}
  396|  21.6k|	}
  397|    329|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    329|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    329|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    329|	int _ret = r; \
  |  |  |  |  155|    329|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 329, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    329|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 329]
  |  |  |  |  ------------------
  |  |  |  |  157|    329|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    329|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    329|	return _ret; \
  |  |  |  |  163|    329|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|    329|}
_pgp_handle_curve25519:
  717|  2.03k|{
  718|  2.03k|	if (!card || !key_info)
  ------------------
  |  Branch (718:6): [True: 0, False: 2.03k]
  |  Branch (718:15): [True: 0, False: 2.03k]
  ------------------
  719|      0|		return 0;
  720|  2.03k|	if (!sc_compare_oid(&key_info->u.ec.oid, &curve25519_oid) &&
  ------------------
  |  Branch (720:6): [True: 2.03k, False: 0]
  ------------------
  721|  2.03k|			!sc_compare_oid(&key_info->u.ec.oid, &X25519_oid))
  ------------------
  |  Branch (721:4): [True: 477, False: 1.56k]
  ------------------
  722|    477|		return 0;
  723|       |
  724|       |	/* CKM_XEDDSA supports both Sign and Derive, but
  725|       |	* OpenPGP card supports only derivation using these
  726|       |	* keys as far as I know */
  727|  1.56k|	_sc_card_add_xeddsa_alg(card, key_info->u.ec.key_length,
  728|  1.56k|			SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |  182|  1.56k|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              			SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |  102|  1.56k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  729|  1.56k|	sc_log(card->ctx, "DO %uX: Added XEDDSA algorithm (%d), mod_len = %zu",
  ------------------
  |  |   71|  1.56k|#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)
  |  |  ------------------
  |  |  |  |  730|  1.56k|	    do_num, SC_ALGORITHM_XEDDSA, key_info->u.ec.key_length);
  |  |  |  |  ------------------
  |  |  |  |  |  |   82|  1.56k|#define SC_ALGORITHM_XEDDSA		5
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  730|  1.56k|	    do_num, SC_ALGORITHM_XEDDSA, key_info->u.ec.key_length);
  731|  1.56k|	return 1;
  732|  2.03k|}
_pgp_add_algo:
  736|  3.83k|{
  737|  3.83k|	unsigned long flags = 0, ext_flags = 0;
  738|       |
  739|  3.83k|	if (!card || !key_info)
  ------------------
  |  Branch (739:6): [True: 0, False: 3.83k]
  |  Branch (739:15): [True: 0, False: 3.83k]
  ------------------
  740|      0|		return 0;
  741|       |
  742|       |	/* [RFC 4880], [draft-ietf-openpgp-crypto-refresh] */
  743|  3.83k|	switch (key_info->algorithm) {
  744|  1.07k|	case SC_OPENPGP_KEYALGO_RSA:
  ------------------
  |  |  869|  1.07k|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (744:2): [True: 1.07k, False: 2.75k]
  ------------------
  745|       |		/* OpenPGP card spec 1.1 & 2.x, section 7.2.9 & 7.2.10 /
  746|       |		 * v3.x section 7.2.11 & 7.2.12 */
  747|  1.07k|		flags = SC_ALGORITHM_RSA_PAD_PKCS1 |
  ------------------
  |  |  120|  1.07k|#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) */
  |  |  ------------------
  |  |  |  |  118|  1.07k|#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) */
  |  |  ------------------
  |  |  |  |  119|  1.07k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  748|  1.07k|			SC_ALGORITHM_RSA_HASH_NONE |
  ------------------
  |  |  142|  1.07k|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  749|  1.07k|			SC_ALGORITHM_ONBOARD_KEY_GEN;	/* key gen on card */
  ------------------
  |  |  102|  1.07k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  750|       |
  751|  1.07k|		_sc_card_add_rsa_alg(card, key_info->u.rsa.modulus_len, flags, 0);
  752|  1.07k|		sc_log(card->ctx, "DO %uX: Added RSA algorithm, mod_len = %"
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
  753|  1.07k|			SC_FORMAT_LEN_SIZE_T"u",
  754|  1.07k|			do_num, key_info->u.rsa.modulus_len);
  755|  1.07k|		break;
  756|    593|	case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  870|    593|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (756:2): [True: 593, False: 3.23k]
  ------------------
  757|       |		/* The montgomery curve (curve25519) needs to go through
  758|       |		 * different paths, otherwise we handle it as a normal EC key */
  759|    593|		if (_pgp_handle_curve25519(card, key_info, do_num))
  ------------------
  |  Branch (759:7): [True: 175, False: 418]
  ------------------
  760|    175|			break;
  761|       |		/* fall through */
  762|  1.13k|	case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  871|  1.13k|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (762:2): [True: 717, False: 3.11k]
  ------------------
  763|       |		/* v3.0+: ECC [RFC 4880 & 6637] */
  764|       |
  765|       |		/* Allow curve to be used by both ECDH and ECDSA.
  766|       |		 * pgp_init set these flags the same way */
  767|  1.13k|		flags = SC_ALGORITHM_ECDH_CDH_RAW;
  ------------------
  |  |  182|  1.13k|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  768|  1.13k|		flags |= SC_ALGORITHM_ECDSA_RAW;
  ------------------
  |  |  183|  1.13k|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  769|  1.13k|		flags |= SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  184|  1.13k|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|  1.13k|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  770|  1.13k|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|  1.13k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  771|  1.13k|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  210|  1.13k|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  772|       |
  773|  1.13k|		_sc_card_add_ec_alg(card, key_info->u.ec.key_length, flags, ext_flags,
  774|  1.13k|			&key_info->u.ec.oid);
  775|  1.13k|		sc_log(card->ctx, "DO %uX: Added EC algorithm (%d), mod_len = %zu" ,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  776|  1.13k|			do_num, key_info->algorithm, key_info->u.ec.key_length);
  777|  1.13k|		break;
  778|  1.44k|	case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  872|  1.44k|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (778:2): [True: 1.44k, False: 2.38k]
  ------------------
  779|       |		/* EdDSA from draft-ietf-openpgp-rfc4880bis-08 */
  780|       |		/* Handle Yubikey bug, that in DO FA curve25519 has EDDSA algo */
  781|  1.44k|		if (_pgp_handle_curve25519(card, key_info, do_num))
  ------------------
  |  Branch (781:7): [True: 1.38k, False: 59]
  ------------------
  782|  1.38k|			break;
  783|     59|		_sc_card_add_eddsa_alg(card, key_info->u.ec.key_length,
  784|     59|				SC_ALGORITHM_EDDSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |  197|     59|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
              				SC_ALGORITHM_EDDSA_RAW | SC_ALGORITHM_ONBOARD_KEY_GEN, 0, &key_info->u.ec.oid);
  ------------------
  |  |  102|     59|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  785|       |
  786|     59|		sc_log(card->ctx, "DO %uX: Added EDDSA algorithm (%d), mod_len = %zu" ,
  ------------------
  |  |   71|     59|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  787|     59|			do_num, key_info->algorithm, key_info->u.ec.key_length);
  788|     59|		break;
  789|      0|	default:
  ------------------
  |  Branch (789:2): [True: 0, False: 3.83k]
  ------------------
  790|      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__
  |  |  ------------------
  ------------------
  791|      0|			do_num, key_info->algorithm);
  792|       |		/* return "false" if we do not understand algo */
  793|      0|		return 0;
  794|  3.83k|	}
  795|       |	/* return true */
  796|  3.83k|	return 1;
  797|  3.83k|}
sc_get_openpgp_driver:
 4211|  3.69k|{
 4212|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 4213|       |
 4214|  3.69k|	iso_ops = iso_drv->ops;
 4215|       |
 4216|  3.69k|	pgp_ops = *iso_ops;
 4217|  3.69k|	pgp_ops.match_card	= pgp_match_card;
 4218|  3.69k|	pgp_ops.init		= pgp_init;
 4219|  3.69k|	pgp_ops.finish		= pgp_finish;
 4220|  3.69k|	pgp_ops.select_file	= pgp_select_file;
 4221|  3.69k|	pgp_ops.list_files	= pgp_list_files;
 4222|  3.69k|	pgp_ops.get_challenge	= pgp_get_challenge;
 4223|  3.69k|	pgp_ops.read_binary	= pgp_read_binary;
 4224|  3.69k|	pgp_ops.write_binary	= NULL;
 4225|  3.69k|	pgp_ops.pin_cmd		= pgp_pin_cmd;
 4226|  3.69k|	pgp_ops.logout		= pgp_logout;
 4227|  3.69k|	pgp_ops.get_data	= pgp_get_data;
 4228|  3.69k|	pgp_ops.put_data	= pgp_put_data;
 4229|  3.69k|	pgp_ops.set_security_env= pgp_set_security_env;
 4230|  3.69k|	pgp_ops.compute_signature= pgp_compute_signature;
 4231|  3.69k|	pgp_ops.decipher	= pgp_decipher;
 4232|  3.69k|	pgp_ops.card_ctl	= pgp_card_ctl;
 4233|  3.69k|	pgp_ops.delete_file	= pgp_delete_file;
 4234|  3.69k|	pgp_ops.update_binary	= pgp_update_binary;
 4235|  3.69k|	pgp_ops.card_reader_lock_obtained = pgp_card_reader_lock_obtained;
 4236|       |
 4237|  3.69k|	return &pgp_drv;
 4238|  3.69k|}
card-openpgp.c:pgp_new_blob:
 1237|  45.9k|{
 1238|  45.9k|	pgp_blob_t *blob = NULL;
 1239|       |
 1240|  45.9k|	if (file == NULL)
  ------------------
  |  Branch (1240:6): [True: 0, False: 45.9k]
  ------------------
 1241|      0|		return NULL;
 1242|       |
 1243|  45.9k|	if ((blob = calloc(1, sizeof(pgp_blob_t))) != NULL) {
  ------------------
  |  Branch (1243:6): [True: 45.9k, False: 0]
  ------------------
 1244|  45.9k|		struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  45.9k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1245|  45.9k|		pgp_do_info_t *info;
 1246|       |
 1247|  45.9k|		blob->file = file;
 1248|       |
 1249|  45.9k|		blob->file->type         = SC_FILE_TYPE_WORKING_EF; /* default */
  ------------------
  |  |  216|  45.9k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 1250|  45.9k|		blob->file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|  45.9k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 1251|  45.9k|		blob->file->id           = file_id;
 1252|       |
 1253|  45.9k|		blob->id     = file_id;
 1254|  45.9k|		blob->parent = parent;
 1255|       |
 1256|  45.9k|		if (parent != NULL) {
  ------------------
  |  Branch (1256:7): [True: 45.6k, False: 329]
  ------------------
 1257|  45.6k|			pgp_blob_t **p;
 1258|       |
 1259|       |			/* set file's path = parent's path + file's id */
 1260|  45.6k|			blob->file->path = parent->file->path;
 1261|  45.6k|			sc_append_file_id(&blob->file->path, file_id);
 1262|       |
 1263|       |			/* append blob to list of parent's children */
 1264|  8.71M|			for (p = &parent->files; *p != NULL; p = &(*p)->next)
  ------------------
  |  Branch (1264:29): [True: 8.66M, False: 45.6k]
  ------------------
 1265|  8.66M|				;
 1266|  45.6k|			*p = blob;
 1267|  45.6k|		}
 1268|    329|		else {
 1269|    329|			char path[10] = "0000";	/* long enough */
 1270|       |
 1271|       |			/* no parent: set file's path = file's id */
 1272|    329|			if (4 != snprintf(path, sizeof(path), "%04X", file_id & 0xFFFF)) {
  ------------------
  |  Branch (1272:8): [True: 0, False: 329]
  ------------------
 1273|      0|				free(blob);
 1274|      0|				return NULL;
 1275|      0|			}
 1276|       |
 1277|    329|			sc_format_path(path, &blob->file->path);
 1278|    329|		}
 1279|       |
 1280|       |		/* find matching DO info: set file type depending on it */
 1281|  2.18M|		for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++) {
  ------------------
  |  Branch (1281:34): [True: 2.18M, False: 0]
  |  Branch (1281:52): [True: 2.16M, False: 19.3k]
  ------------------
 1282|  2.16M|			if (info->id == file_id) {
  ------------------
  |  Branch (1282:8): [True: 26.6k, False: 2.13M]
  ------------------
 1283|  26.6k|				blob->info = info;
 1284|  26.6k|				blob->file->type = blob->info->type;
 1285|  26.6k|				pgp_attach_acl(card, blob->file, info);
 1286|  26.6k|				break;
 1287|  26.6k|			}
 1288|  2.16M|		}
 1289|  45.9k|	}
 1290|       |
 1291|  45.9k|	return blob;
 1292|  45.9k|}
card-openpgp.c:pgp_attach_acl:
 1169|  26.6k|{
 1170|  26.6k|	unsigned int method = SC_AC_NONE;
  ------------------
  |  |  150|  26.6k|#define SC_AC_NONE			0x00000000
  ------------------
 1171|  26.6k|	unsigned long key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  26.6k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 1172|       |
 1173|       |	/* Write access */
 1174|  26.6k|	switch (info->access & WRITE_MASK) {
  ------------------
  |  Branch (1174:10): [True: 26.6k, False: 0]
  ------------------
 1175|  5.14k|	case WRITE_NEVER:
  ------------------
  |  Branch (1175:2): [True: 5.14k, False: 21.4k]
  ------------------
 1176|  5.14k|		method = SC_AC_NEVER;
  ------------------
  |  |  163|  5.14k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1177|  5.14k|		break;
 1178|      0|	case WRITE_PIN1:
  ------------------
  |  Branch (1178:2): [True: 0, False: 26.6k]
  ------------------
 1179|      0|		method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1180|      0|		key_ref = 0x01;
 1181|      0|		break;
 1182|    658|	case WRITE_PIN2:
  ------------------
  |  Branch (1182:2): [True: 658, False: 25.9k]
  ------------------
 1183|    658|		method = SC_AC_CHV;
  ------------------
  |  |  151|    658|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1184|    658|		key_ref = 0x02;
 1185|    658|		break;
 1186|  20.8k|	case WRITE_PIN3:
  ------------------
  |  Branch (1186:2): [True: 20.8k, False: 5.80k]
  ------------------
 1187|  20.8k|		method = SC_AC_CHV;
  ------------------
  |  |  151|  20.8k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1188|  20.8k|		key_ref = 0x03;
 1189|  20.8k|		break;
 1190|  26.6k|	}
 1191|       |
 1192|  26.6k|	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  150|  53.2k|#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 (1192:6): [True: 26.6k, False: 0]
  |  Branch (1192:30): [True: 0, False: 0]
  ------------------
 1193|  26.6k|		sc_file_add_acl_entry(file, SC_AC_OP_WRITE, method, key_ref);
  ------------------
  |  |  190|  26.6k|#define SC_AC_OP_WRITE			24
  ------------------
 1194|  26.6k|		sc_file_add_acl_entry(file, SC_AC_OP_UPDATE, method, key_ref);
  ------------------
  |  |  189|  26.6k|#define SC_AC_OP_UPDATE			23
  ------------------
 1195|  26.6k|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE, method, key_ref);
  ------------------
  |  |  168|  26.6k|#define SC_AC_OP_DELETE			2
  ------------------
 1196|  26.6k|		sc_file_add_acl_entry(file, SC_AC_OP_CREATE, method, key_ref);
  ------------------
  |  |  169|  26.6k|#define SC_AC_OP_CREATE			3
  ------------------
 1197|  26.6k|	}
 1198|      0|	else {
 1199|       |		/* When SC_AC_OP_DELETE is absent, we need to provide
 1200|       |		 * SC_AC_OP_DELETE_SELF for sc_pkcs15init_delete_by_path() */
 1201|      0|		sc_file_add_acl_entry(file, SC_AC_OP_DELETE_SELF, method, key_ref);
  ------------------
  |  |  174|      0|#define SC_AC_OP_DELETE_SELF		8
  ------------------
 1202|      0|	}
 1203|       |
 1204|  26.6k|	method = SC_AC_NONE;
  ------------------
  |  |  150|  26.6k|#define SC_AC_NONE			0x00000000
  ------------------
 1205|  26.6k|	key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|  26.6k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
 1206|       |	/* Read access */
 1207|  26.6k|	switch (info->access & READ_MASK) {
  ------------------
  |  Branch (1207:10): [True: 1.28k, False: 25.3k]
  ------------------
 1208|    626|	case READ_NEVER:
  ------------------
  |  Branch (1208:2): [True: 626, False: 25.9k]
  ------------------
 1209|    626|		method = SC_AC_NEVER;
  ------------------
  |  |  163|    626|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
 1210|    626|		break;
 1211|      0|	case READ_PIN1:
  ------------------
  |  Branch (1211:2): [True: 0, False: 26.6k]
  ------------------
 1212|      0|		method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1213|      0|		key_ref = 0x01;
 1214|      0|		break;
 1215|    329|	case READ_PIN2:
  ------------------
  |  Branch (1215:2): [True: 329, False: 26.2k]
  ------------------
 1216|    329|		method = SC_AC_CHV;
  ------------------
  |  |  151|    329|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1217|    329|		key_ref = 0x02;
 1218|    329|		break;
 1219|    329|	case READ_PIN3:
  ------------------
  |  Branch (1219:2): [True: 329, False: 26.2k]
  ------------------
 1220|    329|		method = SC_AC_CHV;
  ------------------
  |  |  151|    329|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1221|    329|		key_ref = 0x03;
 1222|    329|		break;
 1223|  26.6k|	}
 1224|       |
 1225|  26.6k|	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  150|  53.2k|#define SC_AC_NONE			0x00000000
  ------------------
              	if (method != SC_AC_NONE || key_ref != SC_AC_KEY_REF_NONE) {
  ------------------
  |  |  204|  25.3k|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (1225:6): [True: 1.28k, False: 25.3k]
  |  Branch (1225:30): [True: 0, False: 25.3k]
  ------------------
 1226|  1.28k|		sc_file_add_acl_entry(file, SC_AC_OP_READ, method, key_ref);
  ------------------
  |  |  188|  1.28k|#define SC_AC_OP_READ			22
  ------------------
 1227|  1.28k|	}
 1228|  26.6k|}
card-openpgp.c:pgp_match_card:
  326|    475|{
  327|    475|	int i;
  328|       |
  329|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  330|       |
  331|    475|	i = _sc_match_atr(card, pgp_atrs, &card->type);
  332|    475|	if (i >= 0) {
  ------------------
  |  Branch (332:6): [True: 0, False: 475]
  ------------------
  333|      0|		card->name = pgp_atrs[i].name;
  334|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  335|      0|	}
  336|    475|	else {
  337|    475|		sc_path_t	partial_aid;
  338|    475|		sc_file_t *file = NULL;
  339|       |
  340|       |		/* select application "OpenPGP" */
  341|    475|		sc_format_path("D276:0001:2401", &partial_aid);
  342|    475|		partial_aid.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    475|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  343|       |		/* OpenPGP card only supports selection *with* requested FCI */
  344|    475|		i = iso_ops->select_file(card, &partial_aid, &file);
  345|    475|		if (SC_SUCCESS == i) {
  ------------------
  |  |   28|    475|#define SC_SUCCESS				0
  ------------------
  |  Branch (345:7): [True: 331, False: 144]
  ------------------
  346|    331|			card->type = SC_CARD_TYPE_OPENPGP_BASE;
  347|    331|			card->name = default_cardname;
  348|       |
  349|    331|			if (file->namelen != 16)
  ------------------
  |  Branch (349:8): [True: 331, False: 0]
  ------------------
  350|    331|				(void) get_full_pgp_aid(card, file);
  351|    331|			if (file->namelen == 16) {
  ------------------
  |  Branch (351:8): [True: 38, False: 293]
  ------------------
  352|     38|				unsigned char major = BCD2UCHAR(file->name[6]);
  ------------------
  |  |  216|     38|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  353|       |
  354|     38|				switch (major) {
  355|      2|					case 1:
  ------------------
  |  Branch (355:6): [True: 2, False: 36]
  ------------------
  356|      2|						card->type = SC_CARD_TYPE_OPENPGP_V1;
  357|      2|						card->name = default_cardname_v1;
  358|      2|						break;
  359|      5|					case 2:
  ------------------
  |  Branch (359:6): [True: 5, False: 33]
  ------------------
  360|      5|						card->type = SC_CARD_TYPE_OPENPGP_V2;
  361|      5|						card->name = default_cardname_v2;
  362|      5|						break;
  363|     22|					case 3:
  ------------------
  |  Branch (363:6): [True: 22, False: 16]
  ------------------
  364|     22|						card->type = SC_CARD_TYPE_OPENPGP_V3;
  365|     22|						card->name = default_cardname_v3;
  366|     22|						break;
  367|      9|					default:
  ------------------
  |  Branch (367:6): [True: 9, False: 29]
  ------------------
  368|      9|						break;
  369|     38|				}
  370|     38|			}
  371|    331|			sc_file_free(file);
  372|    331|			LOG_FUNC_RETURN(card->ctx, 1);
  ------------------
  |  |  164|    331|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    331|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    331|	int _ret = r; \
  |  |  |  |  155|    331|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 331]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    331|	} else { \
  |  |  |  |  159|    331|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    331|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    331|	} \
  |  |  |  |  162|    331|	return _ret; \
  |  |  |  |  163|    331|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  373|    331|		}
  374|    475|	}
  375|    144|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|    144|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    144|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    144|	int _ret = r; \
  |  |  |  |  155|    144|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 144, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    144|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 144]
  |  |  |  |  ------------------
  |  |  |  |  157|    144|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    144|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    144|	return _ret; \
  |  |  |  |  163|    144|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  376|    144|}
card-openpgp.c:get_full_pgp_aid:
  307|    662|{
  308|    662|	int r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    662|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  309|       |
  310|    662|	if (file != NULL) {
  ------------------
  |  Branch (310:6): [True: 662, False: 0]
  ------------------
  311|       |		/* explicitly get the full aid */
  312|    662|		r = sc_get_data(card, 0x004F, file->name, sizeof file->name);
  313|    662|		file->namelen = MAX(r, 0);
  ------------------
  |  |   67|    662|#define MAX(x, y) (((x) > (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (67:20): [True: 364, False: 298]
  |  |  ------------------
  ------------------
  314|    662|	}
  315|       |
  316|    662|	return r;
  317|    662|}
card-openpgp.c:pgp_init:
  405|    331|{
  406|    331|	struct pgp_priv_data *priv;
  407|    331|	sc_path_t	path;
  408|    331|	sc_file_t	*file = NULL;
  409|    331|	int		r, i;
  410|       |
  411|    331|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    331|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    331|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    331|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    331|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 331]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  412|       |
  413|    331|	priv = calloc (1, sizeof *priv);
  414|    331|	if (!priv)
  ------------------
  |  Branch (414:6): [True: 0, False: 331]
  ------------------
  415|    331|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  416|    331|	card->drv_data = priv;
  417|       |
  418|    331|	card->cla = 0x00;
  419|       |
  420|       |	/* select application "OpenPGP" */
  421|    331|	sc_format_path("D276:0001:2401", &path);
  422|    331|	path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    331|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  423|    331|	if ((r = iso_ops->select_file(card, &path, &file)) < 0) {
  ------------------
  |  Branch (423:6): [True: 0, False: 331]
  ------------------
  424|      0|		sc_file_free(file);
  425|      0|		pgp_finish(card);
  426|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  427|      0|	}
  428|       |
  429|       |	/* defensive programming check */
  430|    331|	if (!file)   {
  ------------------
  |  Branch (430:6): [True: 0, False: 331]
  ------------------
  431|      0|		pgp_finish(card);
  432|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|      0|	}
  434|       |
  435|    331|	if (file->namelen != 16) {
  ------------------
  |  Branch (435:6): [True: 331, False: 0]
  ------------------
  436|       |		/* explicitly get the full aid */
  437|    331|		r = get_full_pgp_aid(card, file);
  438|    331|		if (r < 0) {
  ------------------
  |  Branch (438:7): [True: 2, False: 329]
  ------------------
  439|      2|			sc_file_free(file);
  440|      2|			pgp_finish(card);
  441|      2|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_CARD);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  442|      2|		}
  443|    331|	}
  444|       |
  445|       |	/* read information from AID */
  446|    329|	if (file->namelen == 16) {
  ------------------
  |  Branch (446:6): [True: 318, False: 11]
  ------------------
  447|    318|		static char card_name[SC_MAX_APDU_BUFFER_SIZE] = "OpenPGP card";
  448|       |
  449|       |		/* OpenPGP card spec 1.1, 2.x & 3.x, section 4.2.1 & 4.1.2.1 */
  450|    318|		priv->bcd_version = bebytes2ushort(file->name + 6);
  451|    318|		card->version.fw_major = card->version.hw_major = BCD2UCHAR(file->name[6]);
  ------------------
  |  |  216|    318|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  452|    318|		card->version.fw_minor = card->version.hw_minor = BCD2UCHAR(file->name[7]);
  ------------------
  |  |  216|    318|#define BCD2UCHAR(x) (((((x) & 0xF0) >> 4) * 10) + ((x) & 0x0F))
  ------------------
  453|       |
  454|       |		/* for "standard" cards, include detailed card version & serial no. in card name */
  455|    318|		if (card->name == default_cardname_v1 ||
  ------------------
  |  Branch (455:7): [True: 2, False: 316]
  ------------------
  456|    316|		    card->name == default_cardname_v2 ||
  ------------------
  |  Branch (456:7): [True: 1, False: 315]
  ------------------
  457|    315|		    card->name == default_cardname_v3) {
  ------------------
  |  Branch (457:7): [True: 18, False: 297]
  ------------------
  458|     21|			snprintf(card_name, sizeof(card_name),
  459|     21|				 "OpenPGP card v%u.%u (%04X %08lX)",
  460|     21|				 card->version.hw_major, card->version.hw_minor,
  461|     21|				 bebytes2ushort(file->name + 8),
  462|     21|				 bebytes2ulong(file->name + 10));
  463|     21|		}
  464|    297|		else if (card->name != NULL) {
  ------------------
  |  Branch (464:12): [True: 297, False: 0]
  ------------------
  465|       |			/* for other cards, append serial number to the card name */
  466|    297|			snprintf(card_name, sizeof(card_name),
  467|    297|				 "%s (%04X %08lX)",
  468|    297|				 card->name,
  469|    297|				 bebytes2ushort(file->name + 8),
  470|    297|				 bebytes2ulong(file->name + 10));
  471|    297|		}
  472|    318|		card->name = card_name;
  473|       |
  474|       |		/* GPG compatibility: set card's serial number to manufacturer ID + serial number */
  475|    318|		memcpy(card->serialnr.value, file->name + 8, 6);
  476|    318|		card->serialnr.len = 6;
  477|    318|	} else {
  478|       |		/* set detailed card version */
  479|     11|		switch (card->type) {
  480|      4|			case SC_CARD_TYPE_OPENPGP_V3:
  ------------------
  |  Branch (480:4): [True: 4, False: 7]
  ------------------
  481|      4|				priv->bcd_version = OPENPGP_CARD_3_0;
  482|      4|				break;
  483|      0|			case SC_CARD_TYPE_OPENPGP_GNUK:
  ------------------
  |  Branch (483:4): [True: 0, False: 11]
  ------------------
  484|      4|			case SC_CARD_TYPE_OPENPGP_V2:
  ------------------
  |  Branch (484:4): [True: 4, False: 7]
  ------------------
  485|      4|				priv->bcd_version = OPENPGP_CARD_2_0;
  486|      4|				break;
  487|      3|			default:
  ------------------
  |  Branch (487:4): [True: 3, False: 8]
  ------------------
  488|      3|				priv->bcd_version = OPENPGP_CARD_1_1;
  489|      3|				break;
  490|     11|		}
  491|     11|	}
  492|       |
  493|       |	/* set pointer to correct list of card objects */
  494|    329|	priv->pgp_objects = (priv->bcd_version < OPENPGP_CARD_2_0) ? pgp1x_objects
  ------------------
  |  Branch (494:22): [True: 9, False: 320]
  ------------------
  495|    329|			  : (priv->bcd_version < OPENPGP_CARD_2_1) ? pgp20_objects
  ------------------
  |  Branch (495:8): [True: 5, False: 315]
  ------------------
  496|    320|			  : (priv->bcd_version < OPENPGP_CARD_3_0) ? pgp21_objects
  ------------------
  |  Branch (496:8): [True: 5, False: 310]
  ------------------
  497|    315|			  : (priv->bcd_version < OPENPGP_CARD_3_3) ? pgp30_objects
  ------------------
  |  Branch (497:8): [True: 4, False: 306]
  ------------------
  498|    310|			  : (priv->bcd_version < OPENPGP_CARD_3_4) ? pgp33_objects
  ------------------
  |  Branch (498:8): [True: 0, False: 306]
  ------------------
  499|    306|			  :					     pgp34_objects;
  500|       |
  501|       |	/* With gnuk, we use different curves */
  502|    329|	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  Branch (502:6): [True: 0, False: 329]
  ------------------
  503|      0|		priv->ec_curves = ec_curves_gnuk;
  504|    329|	} else if (priv->bcd_version >= OPENPGP_CARD_3_4) {
  ------------------
  |  Branch (504:13): [True: 306, False: 23]
  ------------------
  505|    306|		priv->ec_curves = ec_curves_openpgp34;
  506|    306|	} else {
  507|     23|		priv->ec_curves = ec_curves_openpgp;
  508|     23|	}
  509|       |
  510|       |	/* change file path to MF for reuse in MF */
  511|    329|	sc_format_path("3f00", &file->path);
  512|       |
  513|       |	/* set up the root of our fake file tree */
  514|       |	/* Transfers ownership of the file to the priv->mf structure */
  515|    329|	priv->mf = pgp_new_blob(card, NULL, 0x3f00, file);
  516|    329|	if (!priv->mf) {
  ------------------
  |  Branch (516:6): [True: 0, False: 329]
  ------------------
  517|      0|		sc_file_free(file);
  518|      0|		pgp_finish(card);
  519|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  520|      0|	}
  521|       |
  522|       |	/* select MF */
  523|    329|	priv->current = priv->mf;
  524|       |
  525|    329|	r = populate_blobs_to_mf(card, priv);
  526|    329|	if (r < 0) {
  ------------------
  |  Branch (526:6): [True: 0, False: 329]
  ------------------
  527|      0|		pgp_finish(card);
  528|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  529|      0|	}
  530|       |
  531|       |	/* get card_features from ATR & DOs */
  532|    329|	if (pgp_get_card_features(card)) {
  ------------------
  |  Branch (532:6): [True: 84, False: 245]
  ------------------
  533|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  534|     84|	}
  535|       |
  536|       |	/* if algorithm attributes can be changed,
  537|       |	 * add supported algorithms based on specification for pkcs15-init */
  538|    245|	if (priv->ext_caps & EXT_CAP_ALG_ATTR_CHANGEABLE) {
  ------------------
  |  Branch (538:6): [True: 154, False: 91]
  ------------------
  539|    154|		unsigned long flags_rsa, flags_ecc, ext_flags;
  540|    154|		unsigned long flags_eddsa, flags_xeddsa;
  541|       |
  542|       |		/* OpenPGP card spec 1.1 & 2.x, section 7.2.9 & 7.2.10 / v3.x section 7.2.11 & 7.2.12 */
  543|    154|		flags_rsa = SC_ALGORITHM_RSA_PAD_PKCS1|
  ------------------
  |  |  120|    154|#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) */
  |  |  ------------------
  |  |  |  |  118|    154|#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) */
  |  |  ------------------
  |  |  |  |  119|    154|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  544|    154|			    SC_ALGORITHM_RSA_HASH_NONE|
  ------------------
  |  |  142|    154|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  545|    154|			    SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    154|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  546|    154|		flags_ecc = SC_ALGORITHM_ECDSA_RAW|
  ------------------
  |  |  183|    154|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
  547|    154|			    SC_ALGORITHM_ECDH_CDH_RAW|
  ------------------
  |  |  182|    154|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  548|    154|			    SC_ALGORITHM_ECDSA_HASH_NONE|
  ------------------
  |  |  184|    154|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|    154|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
  549|    154|			    SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    154|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  550|    154|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE;
  ------------------
  |  |  210|    154|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
  551|       |
  552|    154|		flags_eddsa = SC_ALGORITHM_EDDSA_RAW |
  ------------------
  |  |  197|    154|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
  553|    154|			      SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    154|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  554|       |		/* xeddsa may allow signing at some time */
  555|    154|		flags_xeddsa = SC_ALGORITHM_ECDH_CDH_RAW |
  ------------------
  |  |  182|    154|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
  556|    154|			       SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    154|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  557|       |
  558|    154|		switch (card->type) {
  559|      7|			case SC_CARD_TYPE_OPENPGP_V3:
  ------------------
  |  Branch (559:4): [True: 7, False: 147]
  ------------------
  560|       |				/* RSA 1024 was removed for v3+ */
  561|      7|				_sc_card_add_rsa_alg(card, 4096, flags_rsa, 0);
  562|      7|				_sc_card_add_rsa_alg(card, 3072, flags_rsa, 0);
  563|       |				/* fallthrough */
  564|      7|			case SC_CARD_TYPE_OPENPGP_GNUK:
  ------------------
  |  Branch (564:4): [True: 0, False: 154]
  ------------------
  565|      7|				_sc_card_add_rsa_alg(card, 2048, flags_rsa, 0);
  566|     82|				for (i=0; priv->ec_curves[i].oid.value[0] >= 0; i++)
  ------------------
  |  Branch (566:15): [True: 75, False: 7]
  ------------------
  567|     75|				{
  568|     75|					if (priv->ec_curves[i].key_type == SC_ALGORITHM_EC)
  ------------------
  |  |   79|     75|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (568:10): [True: 63, False: 12]
  ------------------
  569|     63|						_sc_card_add_ec_alg(card, priv->ec_curves[i].size,
  570|     63|								flags_ecc, ext_flags, &priv->ec_curves[i].oid);
  571|     12|					else if (priv->ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   81|     12|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (571:15): [True: 6, False: 6]
  ------------------
  572|      6|						_sc_card_add_eddsa_alg(card, priv->ec_curves[i].size,
  573|      6|								flags_eddsa, ext_flags, &priv->ec_curves[i].oid);
  574|      6|					else if (priv->ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   82|      6|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (574:15): [True: 6, False: 0]
  ------------------
  575|      6|						_sc_card_add_xeddsa_alg(card, priv->ec_curves[i].size,
  576|      6|								flags_xeddsa, ext_flags, &priv->ec_curves[i].oid);
  577|      0|					else
  578|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  579|     75|				}
  580|      7|				break;
  581|      7|			case SC_CARD_TYPE_OPENPGP_V2:
  ------------------
  |  Branch (581:4): [True: 4, False: 150]
  ------------------
  582|    147|			default:
  ------------------
  |  Branch (582:4): [True: 143, False: 11]
  ------------------
  583|    147|				_sc_card_add_rsa_alg(card, 1024, flags_rsa, 0);
  584|    147|				_sc_card_add_rsa_alg(card, 2048, flags_rsa, 0);
  585|    147|				_sc_card_add_rsa_alg(card, 3072, flags_rsa, 0);
  586|    147|				_sc_card_add_rsa_alg(card, 4096, flags_rsa, 0);
  587|    147|				break;
  588|    154|		}
  589|    154|	}
  590|       |
  591|    245|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|    245|}
card-openpgp.c:pgp_get_pubkey:
 1787|    324|{
 1788|    324|	sc_apdu_t	apdu;
 1789|    324|	u8 apdu_case = (card->type == SC_CARD_TYPE_OPENPGP_GNUK)
  ------------------
  |  Branch (1789:17): [True: 0, False: 324]
  ------------------
 1790|    324|			? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_4;
  ------------------
  |  |  294|      0|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              			? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_4;
  ------------------
  |  |  303|    648|#define SC_APDU_CASE_4			0x24
  ------------------
 1791|    324|	u8		idbuf[2];
 1792|    324|	int		r;
 1793|       |
 1794|    324|	sc_log(card->ctx, "called, tag=%04x\n", tag);
  ------------------
  |  |   71|    324|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1795|       |
 1796|    324|	sc_format_apdu(card, &apdu, apdu_case, 0x47, 0x81, 0);
 1797|    324|	apdu.lc = 2;
 1798|    324|	apdu.data = ushort2bebytes(idbuf, tag);
 1799|    324|	apdu.datalen = 2;
 1800|    324|	apdu.le = ((buf_len >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : buf_len;
  ------------------
  |  |  554|    324|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (1800:13): [True: 324, False: 0]
  |  Branch (1800:33): [True: 303, False: 21]
  ------------------
 1801|    324|	apdu.resp = buf;
 1802|    324|	apdu.resplen = buf_len;
 1803|       |
 1804|    324|	r = sc_transmit_apdu(card, &apdu);
 1805|    324|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    324|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    324|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    324|	int _ret = (r); \
  |  |  |  |  168|    324|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 17, False: 307]
  |  |  |  |  ------------------
  |  |  |  |  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|    324|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 307]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1806|       |
 1807|    307|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1808|    307|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    307|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    307|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    307|	int _ret = (r); \
  |  |  |  |  168|    307|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 229, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  169|    229|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    229|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    229|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    229|		return _ret; \
  |  |  |  |  172|    229|	} \
  |  |  |  |  173|    307|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1809|       |
 1810|     78|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  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: 35, False: 43]
  |  |  |  |  ------------------
  |  |  |  |  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|     43|	} 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|     78|	return _ret; \
  |  |  |  |  163|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1811|     78|}
card-openpgp.c:pgp_get_pubkey_pem:
 1819|      4|{
 1820|      4|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|      4|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1821|      4|	pgp_blob_t	*blob, *mod_blob, *exp_blob, *pubkey_blob, *blob6e, *blob73, *aa_blob;
 1822|      4|	sc_pkcs15_pubkey_t p15pubkey;
 1823|      4|	sc_cardctl_openpgp_key_gen_store_info_t key_info;
 1824|      4|	unsigned int	aa_tag = 0;
 1825|      4|	u8		*data = NULL;
 1826|      4|	size_t		len = 0;
 1827|      4|	int		r;
 1828|       |
 1829|      4|	sc_log(card->ctx, "called, tag=%04x\n", tag);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1830|      4|	memset(&p15pubkey, 0, sizeof(p15pubkey));
 1831|       |
 1832|      4|	if ((r = pgp_get_blob(card, priv->mf, tag & 0xFFFE, &blob)) < 0
  ------------------
  |  Branch (1832:6): [True: 0, False: 4]
  ------------------
 1833|      4|		|| (r = pgp_get_blob(card, blob, 0x7F49, &blob)) < 0)
  ------------------
  |  Branch (1833:6): [True: 4, False: 0]
  ------------------
 1834|      4|		LOG_TEST_RET(card->ctx, r, "error getting elements");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1835|       |
 1836|       |	/* RSA */
 1837|      0|	if ((r = pgp_get_blob(card, blob, 0x0081, &mod_blob)) >= 0
  ------------------
  |  Branch (1837:6): [True: 0, False: 0]
  ------------------
 1838|      0|		&& (r = pgp_get_blob(card, blob, 0x0082, &exp_blob)) >= 0
  ------------------
  |  Branch (1838:6): [True: 0, False: 0]
  ------------------
 1839|      0|		&& (r = pgp_read_blob(card, mod_blob)) >= 0
  ------------------
  |  Branch (1839:6): [True: 0, False: 0]
  ------------------
 1840|      0|		&& (r = pgp_read_blob(card, exp_blob)) >= 0) {
  ------------------
  |  Branch (1840:6): [True: 0, False: 0]
  ------------------
 1841|       |
 1842|      0|		p15pubkey.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      0|#define SC_ALGORITHM_RSA		0
  ------------------
 1843|      0|		p15pubkey.u.rsa.modulus.data  = mod_blob->data;
 1844|      0|		p15pubkey.u.rsa.modulus.len   = mod_blob->len;
 1845|      0|		p15pubkey.u.rsa.exponent.data = exp_blob->data;
 1846|      0|		p15pubkey.u.rsa.exponent.len  = exp_blob->len;
 1847|      0|		r = sc_pkcs15_encode_pubkey(card->ctx, &p15pubkey, &data, &len);
 1848|      0|	}
 1849|       |	/* ECC */
 1850|      0|	else if ((r = pgp_get_blob(card, blob, 0x0086, &pubkey_blob)) >= 0
  ------------------
  |  Branch (1850:11): [True: 0, False: 0]
  ------------------
 1851|      0|		&& (r = pgp_read_blob(card, pubkey_blob)) >= 0) {
  ------------------
  |  Branch (1851:6): [True: 0, False: 0]
  ------------------
 1852|       |
 1853|      0|		switch(tag & 0xFFFE) {
 1854|      0|			case DO_SIGN: aa_tag = 0x00C1; break;
  ------------------
  |  |  141|      0|#define DO_SIGN                  0xb600
  ------------------
  |  Branch (1854:4): [True: 0, False: 0]
  ------------------
 1855|      0|			case DO_ENCR: aa_tag = 0x00C2; break;
  ------------------
  |  |  142|      0|#define DO_ENCR                  0xb800
  ------------------
  |  Branch (1855:4): [True: 0, False: 0]
  ------------------
 1856|      0|			case DO_AUTH: aa_tag = 0x00C3; break;
  ------------------
  |  |  143|      0|#define DO_AUTH                  0xa400
  ------------------
  |  Branch (1856:4): [True: 0, False: 0]
  ------------------
 1857|      0|			default: r = SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|      0|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (1857:4): [True: 0, False: 0]
  ------------------
 1858|      0|		}
 1859|       |
 1860|       |		/* Get EC parameters from Algorithm Attribute if present */
 1861|       |
 1862|      0|		if (aa_tag && ((r = pgp_get_blob(card, priv->mf, 0x006e, &blob6e)) >= 0) &&
  ------------------
  |  Branch (1862:7): [True: 0, False: 0]
  |  Branch (1862:17): [True: 0, False: 0]
  ------------------
 1863|      0|				((r = pgp_get_blob(card, blob6e, 0x0073, &blob73)) >= 0) &&
  ------------------
  |  Branch (1863:5): [True: 0, False: 0]
  ------------------
 1864|      0|				((r = pgp_get_blob(card, blob73, aa_tag, &aa_blob)) >= 0) &&
  ------------------
  |  Branch (1864:5): [True: 0, False: 0]
  ------------------
 1865|      0|				((r = pgp_parse_algo_attr_blob(card, aa_blob, &key_info)) >= 0)) {
  ------------------
  |  Branch (1865:5): [True: 0, False: 0]
  ------------------
 1866|      0|			switch (key_info.algorithm) {
 1867|      0|			case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (1867:4): [True: 0, False: 0]
  ------------------
 1868|       |				/* In EDDSA key case we do not have to care about OIDs
 1869|       |				 * as we support only one for now */
 1870|      0|				p15pubkey.algorithm = SC_ALGORITHM_EDDSA;
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
 1871|      0|				p15pubkey.u.ec.ecpointQ.value = pubkey_blob->data;
 1872|      0|				p15pubkey.u.ec.ecpointQ.len = pubkey_blob->len;
 1873|       |				/* PKCS#11 3.0: 2.3.5 Edwards EC public keys only support the use
 1874|       |				 * of the curveName selection to specify a curve name as defined
 1875|       |				 * in [RFC 8032] */
 1876|      0|				r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &p15pubkey, &data, &len);
 1877|      0|				break;
 1878|      0|			case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  870|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (1878:4): [True: 0, False: 0]
  ------------------
 1879|       |				/* This yields either EC(DSA) key or EC_MONTGOMERY (curve25519) key */
 1880|      0|				if (sc_compare_oid(&key_info.u.ec.oid, &curve25519_oid)) {
  ------------------
  |  Branch (1880:9): [True: 0, False: 0]
  ------------------
 1881|      0|					p15pubkey.algorithm = SC_ALGORITHM_XEDDSA;
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
 1882|      0|					p15pubkey.u.ec.ecpointQ.value = pubkey_blob->data;
 1883|      0|					p15pubkey.u.ec.ecpointQ.len = pubkey_blob->len;
 1884|       |					/* PKCS#11 3.0 2.3.7 Montgomery EC public keys only support
 1885|       |					 * the use of the curveName selection to specify a curve
 1886|       |					 * name as defined in [RFC7748] */
 1887|       |					/* XXX only curve25519 supported now. Theoretically could be
 1888|       |					 * also curve448 or OIDs */
 1889|       |
 1890|      0|					r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &p15pubkey, &data, &len);
 1891|      0|					break;
 1892|      0|				}
 1893|       |				/* fall through */
 1894|      0|			case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (1894:4): [True: 0, False: 0]
  ------------------
 1895|      0|				if ((r = sc_encode_oid(card->ctx, &key_info.u.ec.oid,
  ------------------
  |  Branch (1895:9): [True: 0, False: 0]
  ------------------
 1896|      0|						&p15pubkey.u.ec.params.der.value,
 1897|      0|						&p15pubkey.u.ec.params.der.len)) == 0) {
 1898|      0|					p15pubkey.algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
 1899|      0|					p15pubkey.u.ec.ecpointQ.value = pubkey_blob->data;
 1900|      0|					p15pubkey.u.ec.ecpointQ.len = pubkey_blob->len;
 1901|      0|					p15pubkey.u.ec.params.type = 1;
 1902|      0|					r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &p15pubkey, &data, &len);
 1903|      0|				} else {
 1904|      0|					sc_log(card->ctx, "Unable to encode EC curve OID from algorithm info");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1905|      0|				}
 1906|      0|				break;
 1907|      0|			default:
  ------------------
  |  Branch (1907:4): [True: 0, False: 0]
  ------------------
 1908|      0|				sc_log(card->ctx, "Unknown algorithm ID received (%d)", key_info.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__
  |  |  ------------------
  ------------------
 1909|      0|				break;
 1910|      0|			}
 1911|      0|		} else {
 1912|      0|			sc_log(card->ctx, "Unable to find Algorithm Attribute for EC curve OID");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1913|      0|		}
 1914|      0|	} else {
 1915|      0|		LOG_TEST_RET(card->ctx, r, "error getting elements");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1916|      0|	}
 1917|       |
 1918|       |	/* clean up anything we may have set in p15pubkey that can not be freed */
 1919|      0|	if (p15pubkey.algorithm == SC_ALGORITHM_RSA) {
  ------------------
  |  |   78|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1919:6): [True: 0, False: 0]
  ------------------
 1920|      0|		p15pubkey.u.rsa.modulus.data  = NULL;
 1921|      0|		p15pubkey.u.rsa.modulus.len = 0;
 1922|      0|		p15pubkey.u.rsa.exponent.data  = NULL;
 1923|      0|		p15pubkey.u.rsa.exponent.len = 0;
 1924|      0|	} else if (p15pubkey.algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1924:13): [True: 0, False: 0]
  ------------------
 1925|      0|			p15pubkey.algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1925:4): [True: 0, False: 0]
  ------------------
 1926|      0|			p15pubkey.algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1926:4): [True: 0, False: 0]
  ------------------
 1927|      0|		p15pubkey.u.ec.ecpointQ.value = NULL;
 1928|      0|		p15pubkey.u.ec.ecpointQ.len = 0;
 1929|       |		/* p15pubkey.u.ec.params.der and named_curve will be freed by sc_pkcs15_erase_pubkey */
 1930|      0|	}
 1931|      0|	sc_pkcs15_erase_pubkey(&p15pubkey);
 1932|       |
 1933|      0|	LOG_TEST_RET(card->ctx, r, "public key encoding 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1934|       |
 1935|      0|	if (len > buf_len)
  ------------------
  |  Branch (1935:6): [True: 0, False: 0]
  ------------------
 1936|      0|		len = buf_len;
 1937|      0|	memcpy(buf, data, len);
 1938|      0|	free(data);
 1939|       |
 1940|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1941|      0|}
card-openpgp.c:pgp_get_blob:
 1477|  19.1k|{
 1478|  19.1k|	pgp_blob_t		*child;
 1479|  19.1k|	int			r;
 1480|       |
 1481|  19.1k|	if ((r = pgp_enumerate_blob(card, blob)) < 0)
  ------------------
  |  Branch (1481:6): [True: 5.83k, False: 13.2k]
  ------------------
 1482|  5.83k|		return r;
 1483|       |
 1484|  63.2k|	for (child = blob->files; child; child = child->next) {
  ------------------
  |  Branch (1484:28): [True: 52.7k, False: 10.5k]
  ------------------
 1485|  52.7k|		if (child->id == id) {
  ------------------
  |  Branch (1485:7): [True: 2.74k, False: 49.9k]
  ------------------
 1486|  2.74k|			(void) pgp_read_blob(card, child);
 1487|  2.74k|			*ret = child;
 1488|  2.74k|			return SC_SUCCESS;
  ------------------
  |  |   28|  2.74k|#define SC_SUCCESS				0
  ------------------
 1489|  2.74k|		}
 1490|  52.7k|	}
 1491|       |
 1492|       |	/* This part is for "NOT FOUND" cases */
 1493|       |
 1494|       |	/* Special case:
 1495|       |	 * Gnuk does not have default value for children of DO 65 (DOs 5B, 5F2D, 5F35)
 1496|       |	 * So, if these blob was not found, we create it. */
 1497|  10.5k|	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  154|  21.0k|#define DO_CARDHOLDER            0x65
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  155|  1.61k|#define DO_NAME                  0x5b
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  156|  1.61k|#define DO_LANG_PREF             0x5f2d
  ------------------
              	if (blob->id == DO_CARDHOLDER && (id == DO_NAME || id == DO_LANG_PREF || id == DO_SEX)) {
  ------------------
  |  |  157|    718|#define DO_SEX                   0x5f35
  ------------------
  |  Branch (1497:6): [True: 809, False: 9.71k]
  |  Branch (1497:36): [True: 0, False: 809]
  |  Branch (1497:53): [True: 91, False: 718]
  |  Branch (1497:75): [True: 0, False: 718]
  ------------------
 1498|     91|		sc_log(card->ctx, "Create blob %X under %X", id, blob->id);
  ------------------
  |  |   71|     91|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1499|     91|		child = pgp_new_blob(card, blob, id, sc_file_new());
 1500|     91|		if (child) {
  ------------------
  |  Branch (1500:7): [True: 91, False: 0]
  ------------------
 1501|     91|			pgp_set_blob(child, NULL, 0);
 1502|     91|			*ret = child;
 1503|     91|			return SC_SUCCESS;
  ------------------
  |  |   28|     91|#define SC_SUCCESS				0
  ------------------
 1504|     91|		}
 1505|      0|		else
 1506|      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__
  |  |  ------------------
  ------------------
 1507|     91|			       "Not enough memory to create blob for DO %X",
 1508|     91|			       id);
 1509|     91|	}
 1510|       |
 1511|  10.4k|	return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  10.4k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 1512|  10.5k|}
card-openpgp.c:pgp_enumerate_blob:
 1395|  19.4k|{
 1396|  19.4k|	const u8	*in;
 1397|  19.4k|	int		r;
 1398|  19.4k|	sc_file_t	*file = NULL;
 1399|       |
 1400|  19.4k|	if (blob->files != NULL)
  ------------------
  |  Branch (1400:6): [True: 7.19k, False: 12.2k]
  ------------------
 1401|  7.19k|		return SC_SUCCESS;
  ------------------
  |  |   28|  7.19k|#define SC_SUCCESS				0
  ------------------
 1402|       |
 1403|  12.2k|	if ((r = pgp_read_blob(card, blob)) < 0)
  ------------------
  |  Branch (1403:6): [True: 1.22k, False: 10.9k]
  ------------------
 1404|  1.22k|		return r;
 1405|       |
 1406|  10.9k|	in = blob->data;
 1407|       |
 1408|  50.2k|	while ((int) blob->len > (in - blob->data)) {
  ------------------
  |  Branch (1408:9): [True: 44.1k, False: 6.09k]
  ------------------
 1409|  44.1k|		unsigned int	cla, tag, tmptag;
 1410|  44.1k|		size_t		len;
 1411|  44.1k|		const u8	*data = in;
 1412|  44.1k|		pgp_blob_t	*new;
 1413|       |
 1414|  44.1k|		if (!in)
  ------------------
  |  Branch (1414:7): [True: 0, False: 44.1k]
  ------------------
 1415|      0|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1416|       |
 1417|  44.1k|		r = sc_asn1_read_tag(&data, blob->len - (in - blob->data),
 1418|  44.1k|					&cla, &tag, &len);
 1419|  44.1k|		if (r == SC_ERROR_INVALID_ASN1_OBJECT) {
  ------------------
  |  |   82|  44.1k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  |  Branch (1419:7): [True: 1.00k, False: 43.1k]
  ------------------
 1420|  1.00k|			sc_log(card->ctx, "Invalid ASN.1 object");
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 1421|  1.00k|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|  1.00k|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1422|  1.00k|		}
 1423|       |		/* Check for unknown error, or empty data */
 1424|  43.1k|		if (((r < 0) && (r != SC_ERROR_ASN1_END_OF_CONTENTS)) ||
  ------------------
  |  |   84|  2.87k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (1424:8): [True: 2.87k, False: 40.2k]
  |  Branch (1424:19): [True: 0, False: 2.87k]
  ------------------
 1425|  43.1k|		    (data == NULL)) {
  ------------------
  |  Branch (1425:7): [True: 1.06k, False: 42.0k]
  ------------------
 1426|  1.06k|			sc_log(card->ctx, "Unexpected end of contents");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1427|  1.06k|			return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|  1.06k|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1428|  1.06k|		}
 1429|       |
 1430|       |		/* undo ASN1's split of tag & class */
 1431|  43.2k|		for (tmptag = tag; tmptag > 0x0FF; tmptag >>= 8) {
  ------------------
  |  Branch (1431:22): [True: 1.14k, False: 42.0k]
  ------------------
 1432|  1.14k|			cla <<= 8;
 1433|  1.14k|		}
 1434|  42.0k|		tag |= cla;
 1435|       |		/* Check for length mismatch */
 1436|  42.0k|		if ((r == SC_ERROR_ASN1_END_OF_CONTENTS) ||
  ------------------
  |  |   84|  42.0k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (1436:7): [True: 2.87k, False: 39.2k]
  ------------------
 1437|  39.2k|		    (data + len > blob->data + blob->len)) {
  ------------------
  |  Branch (1437:7): [True: 0, False: 39.2k]
  ------------------
 1438|       |			// Check if it is not known Yubikey 5 issue
 1439|  2.87k|			if ((tag != blob->id) || (tag != 0xfa)) {
  ------------------
  |  Branch (1439:8): [True: 1.87k, False: 1.00k]
  |  Branch (1439:29): [True: 957, False: 49]
  ------------------
 1440|  2.82k|				sc_log(card->ctx, "Unexpected end of contents");
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 1441|  2.82k|				return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|  2.82k|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 1442|  2.82k|			}
 1443|  2.87k|		}
 1444|       |
 1445|       |		/* Awful hack for composite DOs that have
 1446|       |		 * a TLV with the DO's id encompassing the
 1447|       |		 * entire blob. Example: Yubikey Neo */
 1448|  39.2k|		if (tag == blob->id) {
  ------------------
  |  Branch (1448:7): [True: 549, False: 38.7k]
  ------------------
 1449|    549|			in = data;
 1450|    549|			continue;
 1451|    549|		}
 1452|       |
 1453|       |		/* create fake file system hierarchy by
 1454|       |		 * using constructed DOs as DF */
 1455|  38.7k|		file = sc_file_new();
 1456|  38.7k|		if ((new = pgp_new_blob(card, blob, tag, file)) == NULL) {
  ------------------
  |  Branch (1456:7): [True: 0, False: 38.7k]
  ------------------
 1457|      0|			sc_file_free(file);
 1458|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1459|      0|		}
 1460|  38.7k|		if (pgp_set_blob(new, data, len) != SC_SUCCESS) {
  ------------------
  |  |   28|  38.7k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1460:7): [True: 0, False: 38.7k]
  ------------------
 1461|      0|			sc_file_free(file);
 1462|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1463|      0|		}
 1464|  38.7k|		in = data + len;
 1465|  38.7k|	}
 1466|       |
 1467|  6.09k|	return SC_SUCCESS;
  ------------------
  |  |   28|  6.09k|#define SC_SUCCESS				0
  ------------------
 1468|  10.9k|}
card-openpgp.c:pgp_set_blob:
 1137|  40.1k|{
 1138|  40.1k|	if (blob->data)
  ------------------
  |  Branch (1138:6): [True: 38, False: 40.1k]
  ------------------
 1139|     38|		free(blob->data);
 1140|  40.1k|	blob->data = NULL;
 1141|  40.1k|	blob->len    = 0;
 1142|  40.1k|	blob->status = 0;
 1143|       |
 1144|  40.1k|	if (len > 0) {
  ------------------
  |  Branch (1144:6): [True: 23.5k, False: 16.6k]
  ------------------
 1145|  23.5k|		void *tmp = calloc(1, len);
 1146|       |
 1147|  23.5k|		if (tmp == NULL)
  ------------------
  |  Branch (1147:7): [True: 0, False: 23.5k]
  ------------------
 1148|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1149|       |
 1150|  23.5k|		blob->data = tmp;
 1151|  23.5k|		blob->len  = (unsigned int)len;
 1152|  23.5k|		if (data != NULL)
  ------------------
  |  Branch (1152:7): [True: 23.5k, False: 0]
  ------------------
 1153|  23.5k|			memcpy(blob->data, data, len);
 1154|  23.5k|	}
 1155|       |
 1156|  40.1k|	if (blob->file)
  ------------------
  |  Branch (1156:6): [True: 40.1k, False: 0]
  ------------------
 1157|  40.1k|		blob->file->size = len;
 1158|       |
 1159|  40.1k|	return SC_SUCCESS;
  ------------------
  |  |   28|  40.1k|#define SC_SUCCESS				0
  ------------------
 1160|  40.1k|}
card-openpgp.c:pgp_read_blob:
 1345|  15.4k|{
 1346|  15.4k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  15.4k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1347|       |
 1348|  15.4k|	if (blob->data != NULL)
  ------------------
  |  Branch (1348:6): [True: 6.80k, False: 8.59k]
  ------------------
 1349|  6.80k|		return SC_SUCCESS;
  ------------------
  |  |   28|  6.80k|#define SC_SUCCESS				0
  ------------------
 1350|  8.59k|	if (blob->info == NULL)
  ------------------
  |  Branch (1350:6): [True: 4.66k, False: 3.93k]
  ------------------
 1351|  4.66k|		return blob->status;
 1352|       |
 1353|  3.93k|	if (blob->info->get_fn) {	/* readable, top-level DO */
  ------------------
  |  Branch (1353:6): [True: 3.40k, False: 531]
  ------------------
 1354|  3.40k|		u8 	buffer[MAX_OPENPGP_DO_SIZE];
 1355|  3.40k|		size_t	buf_len = sizeof(buffer);
 1356|  3.40k|		int r = SC_SUCCESS;
  ------------------
  |  |   28|  3.40k|#define SC_SUCCESS				0
  ------------------
 1357|       |
 1358|       |		/* buffer length for certificate */
 1359|  3.40k|		if (blob->id == DO_CERT && priv->max_cert_size > 0) {
  ------------------
  |  |  138|  6.80k|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (1359:7): [True: 0, False: 3.40k]
  |  Branch (1359:30): [True: 0, False: 0]
  ------------------
 1360|      0|			buf_len = MIN(priv->max_cert_size, sizeof(buffer));
  ------------------
  |  |   70|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1361|      0|		}
 1362|       |
 1363|       |		/* buffer length for Gnuk pubkey */
 1364|  3.40k|		if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
  ------------------
  |  Branch (1364:7): [True: 0, False: 3.40k]
  ------------------
 1365|      0|		    (blob->id == DO_AUTH ||
  ------------------
  |  |  143|      0|#define DO_AUTH                  0xa400
  ------------------
  |  Branch (1365:8): [True: 0, False: 0]
  ------------------
 1366|      0|		     blob->id == DO_SIGN ||
  ------------------
  |  |  141|      0|#define DO_SIGN                  0xb600
  ------------------
  |  Branch (1366:8): [True: 0, False: 0]
  ------------------
 1367|      0|		     blob->id == DO_ENCR ||
  ------------------
  |  |  142|      0|#define DO_ENCR                  0xb800
  ------------------
  |  Branch (1367:8): [True: 0, False: 0]
  ------------------
 1368|      0|		     blob->id == DO_AUTH_SYM ||
  ------------------
  |  |  147|      0|#define DO_AUTH_SYM              0xa401
  ------------------
  |  Branch (1368:8): [True: 0, False: 0]
  ------------------
 1369|      0|		     blob->id == DO_SIGN_SYM ||
  ------------------
  |  |  145|      0|#define DO_SIGN_SYM              0xb601
  ------------------
  |  Branch (1369:8): [True: 0, False: 0]
  ------------------
 1370|      0|		     blob->id == DO_ENCR_SYM)) {
  ------------------
  |  |  146|      0|#define DO_ENCR_SYM              0xb801
  ------------------
  |  Branch (1370:8): [True: 0, False: 0]
  ------------------
 1371|      0|			buf_len = MIN(MAXLEN_RESP_PUBKEY_GNUK, sizeof(buffer));
  ------------------
  |  |   70|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, Folded]
  |  |  ------------------
  ------------------
 1372|      0|		}
 1373|       |
 1374|  3.40k|		r = blob->info->get_fn(card, blob->id, buffer, buf_len);
 1375|       |
 1376|  3.40k|		if (r < 0) {	/* an error occurred */
  ------------------
  |  Branch (1376:7): [True: 2.11k, False: 1.28k]
  ------------------
 1377|  2.11k|			blob->status = r;
 1378|  2.11k|			return r;
 1379|  2.11k|		}
 1380|       |
 1381|  1.28k|		return pgp_set_blob(blob, buffer, r);
 1382|  3.40k|	}
 1383|    531|	else {		/* un-readable DO or part of a constructed DO */
 1384|    531|		return SC_SUCCESS;
  ------------------
  |  |   28|    531|#define SC_SUCCESS				0
  ------------------
 1385|    531|	}
 1386|  3.93k|}
card-openpgp.c:pgp_parse_algo_attr_blob:
  630|  16.0k|{
  631|  16.0k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  16.0k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  632|  16.0k|	struct sc_object_id oid;
  633|  16.0k|	unsigned int j, r;
  634|       |
  635|  16.0k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  16.0k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  16.0k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  16.0k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  16.0k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 16.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|       |
  637|  16.0k|	if (blob == NULL || blob->data == NULL || blob->len == 0 ||
  ------------------
  |  Branch (637:6): [True: 0, False: 16.0k]
  |  Branch (637:22): [True: 1.79k, False: 14.2k]
  |  Branch (637:44): [True: 0, False: 14.2k]
  ------------------
  638|  14.2k|	    blob->id < 0x00c1 || blob->id > 0x00c3 || key_info == NULL) {
  ------------------
  |  Branch (638:6): [True: 0, False: 14.2k]
  |  Branch (638:27): [True: 0, False: 14.2k]
  |  Branch (638:48): [True: 0, False: 14.2k]
  ------------------
  639|  1.79k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  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|  1.79k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.79k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|  1.79k|	}
  641|       |
  642|  14.2k|	key_info->key_id = blob->id - 0x00c0;	/* attribute algorithm blobs are C1 - C3 */
  643|       |
  644|  14.2k|	switch (blob->data[0]) {
  645|  3.80k|		case SC_OPENPGP_KEYALGO_RSA:
  ------------------
  |  |  869|  3.80k|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (645:3): [True: 3.80k, False: 10.4k]
  ------------------
  646|  3.80k|			if (blob->len < 5) {
  ------------------
  |  Branch (646:8): [True: 2.72k, False: 1.07k]
  ------------------
  647|  2.72k|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  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|  2.72k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.72k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  648|  2.72k|			}
  649|       |
  650|  1.07k|			key_info->algorithm = SC_OPENPGP_KEYALGO_RSA;
  ------------------
  |  |  869|  1.07k|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  651|  1.07k|			key_info->u.rsa.modulus_len = bebytes2ushort(blob->data + 1);
  652|  1.07k|			key_info->u.rsa.exponent_len = bebytes2ushort(blob->data + 3);
  653|       |
  654|  1.07k|			key_info->u.rsa.keyformat = (blob->len > 5)
  ------------------
  |  Branch (654:32): [True: 541, False: 537]
  ------------------
  655|  1.07k|						  ? blob->data[5]
  656|  1.07k|						  : SC_OPENPGP_KEYFORMAT_RSA_STD;
  ------------------
  |  |  874|  1.61k|#define SC_OPENPGP_KEYFORMAT_RSA_STD	0    /* See 4.3.3.6 Algorithm Attributes */
  ------------------
  657|  1.07k|			break;
  658|  5.07k|		case SC_OPENPGP_KEYALGO_ECDH:
  ------------------
  |  |  870|  5.07k|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (658:3): [True: 5.07k, False: 9.16k]
  ------------------
  659|  6.08k|		case SC_OPENPGP_KEYALGO_ECDSA:
  ------------------
  |  |  871|  6.08k|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (659:3): [True: 1.01k, False: 13.2k]
  ------------------
  660|  7.74k|		case SC_OPENPGP_KEYALGO_EDDSA:
  ------------------
  |  |  872|  7.74k|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (660:3): [True: 1.66k, False: 12.5k]
  ------------------
  661|       |
  662|       |			/* SC_OPENPGP_KEYALGO_ECDH || SC_OPENPGP_KEYALGO_ECDSA || SC_OPENPGP_KEYALGO_EDDSA */
  663|  7.74k|			key_info->algorithm = blob->data[0];
  664|       |
  665|       |			/* last byte is set to 0xFF if pubkey import is supported */
  666|  7.74k|			if (blob->data[blob->len-1] == SC_OPENPGP_KEYFORMAT_EC_STDPUB){
  ------------------
  |  |  880|  7.74k|#define SC_OPENPGP_KEYFORMAT_EC_STDPUB	0xFF
  ------------------
  |  Branch (666:8): [True: 2.14k, False: 5.60k]
  ------------------
  667|  2.14k|				if (blob->len < 3)
  ------------------
  |  Branch (667:9): [True: 680, False: 1.46k]
  ------------------
  668|    680|					return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|    680|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  669|  1.46k|				key_info->u.ec.oidv_len = blob->len - 2;
  670|  1.46k|				key_info->u.ec.keyformat = SC_OPENPGP_KEYFORMAT_EC_STDPUB;
  ------------------
  |  |  880|  1.46k|#define SC_OPENPGP_KEYFORMAT_EC_STDPUB	0xFF
  ------------------
  671|  1.46k|			}
  672|  5.60k|			else {
  673|       |				/* otherwise, last byte could be 00, so let's ignore it, as
  674|       |				 * it is not part of OID */
  675|  5.60k|				if (blob->len < 2)
  ------------------
  |  Branch (675:9): [True: 899, False: 4.70k]
  ------------------
  676|    899|					return SC_ERROR_INCORRECT_PARAMETERS;
  ------------------
  |  |   55|    899|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  677|  4.70k|				if (blob->data[blob->len-1] == SC_OPENPGP_KEYFORMAT_EC_STD)
  ------------------
  |  |  879|  4.70k|#define SC_OPENPGP_KEYFORMAT_EC_STD	0
  ------------------
  |  Branch (677:9): [True: 761, False: 3.94k]
  ------------------
  678|    761|					key_info->u.ec.oidv_len = blob->len - 2;
  679|  3.94k|				else
  680|  3.94k|					key_info->u.ec.oidv_len = blob->len - 1;
  681|  4.70k|				key_info->u.ec.keyformat = SC_OPENPGP_KEYFORMAT_EC_STD;
  ------------------
  |  |  879|  4.70k|#define SC_OPENPGP_KEYFORMAT_EC_STD	0
  ------------------
  682|  4.70k|			}
  683|       |
  684|       |			/* Create copy of oid from blob */
  685|  6.16k|			sc_init_oid(&oid);
  686|  6.16k|			r = sc_asn1_decode_object_id(&blob->data[1], key_info->u.ec.oidv_len, &oid);
  687|       |
  688|       |			/* decoding failed, return sc_asn1_decode_object_id error code */
  689|  6.16k|			if (r > 0){
  ------------------
  |  Branch (689:8): [True: 2.59k, False: 3.56k]
  ------------------
  690|  2.59k|				return r;
  691|  2.59k|			}
  692|       |			/* compare with list of supported ec_curves */
  693|  20.3k|			for (j = 0; priv->ec_curves[j].oid.value[0] >= 0; j++) {
  ------------------
  |  Branch (693:16): [True: 19.5k, False: 804]
  ------------------
  694|  19.5k|				if (sc_compare_oid(&priv->ec_curves[j].oid, &oid)) {
  ------------------
  |  Branch (694:9): [True: 2.76k, False: 16.8k]
  ------------------
  695|  2.76k|					sc_log(card->ctx, "Matched EC oid %s (%d)",
  ------------------
  |  |   71|  2.76k|#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|  2.76k|						sc_dump_oid(&oid), j);
  697|  2.76k|					key_info->u.ec.oid = priv->ec_curves[j].oid;
  698|  2.76k|					key_info->u.ec.key_length = priv->ec_curves[j].size;
  699|  2.76k|					break;
  700|  2.76k|				}
  701|  19.5k|			}
  702|       |			/* We did not match the OID */
  703|  3.56k|			if (priv->ec_curves[j].oid.value[0] < 0) {
  ------------------
  |  Branch (703:8): [True: 804, False: 2.76k]
  ------------------
  704|    804|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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|    804|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 804, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  705|    804|			}
  706|  2.76k|			break;
  707|  2.76k|		default:
  ------------------
  |  Branch (707:3): [True: 2.69k, False: 11.5k]
  ------------------
  708|  2.69k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|  2.69k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.69k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.69k|	int _ret = r; \
  |  |  |  |  155|  2.69k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.69k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|  2.69k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.69k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.69k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.69k|	return _ret; \
  |  |  |  |  163|  2.69k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|  14.2k|	}
  710|       |
  711|  3.84k|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.84k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.84k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.84k|	int _ret = r; \
  |  |  |  |  155|  3.84k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.84k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.84k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.84k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.84k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.84k|	} else { \
  |  |  |  |  159|      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.84k|	return _ret; \
  |  |  |  |  163|  3.84k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  712|  3.84k|}
card-openpgp.c:pgp_get_card_features:
  906|    329|{
  907|    329|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    329|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  908|    329|	u8 *hist_bytes = card->reader->atr_info.hist_bytes;
  909|    329|	size_t hist_bytes_len = card->reader->atr_info.hist_bytes_len;
  910|    329|	unsigned int i;
  911|    329|	pgp_blob_t *blob, *blob6e, *blob73, *blobfa;
  912|    329|	int handled_algos = 0;
  913|       |
  914|    329|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    329|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    329|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    329|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    329|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 329]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  915|       |
  916|       |	/* parse card capabilities from historical bytes in ATR */
  917|    329|	if (hist_bytes_len > 0) {
  ------------------
  |  Branch (917:6): [True: 138, False: 191]
  ------------------
  918|       |		/* category indicator 0x00, 0x10 or 0x80 => compact TLV (ISO) */
  919|    138|		switch (hist_bytes[0]) {
  ------------------
  |  Branch (919:11): [True: 41, False: 97]
  ------------------
  920|     41|			case 0x00:
  ------------------
  |  Branch (920:4): [True: 41, False: 97]
  ------------------
  921|     41|				if (hist_bytes_len > 4) {
  ------------------
  |  Branch (921:9): [True: 17, False: 24]
  ------------------
  922|     17|					pgp_parse_hist_bytes(card, hist_bytes+1, hist_bytes_len-4);
  923|     17|				}
  924|     41|				break;
  925|      0|			case 0x80:
  ------------------
  |  Branch (925:4): [True: 0, False: 138]
  ------------------
  926|      0|				if (hist_bytes_len > 1) {
  ------------------
  |  Branch (926:9): [True: 0, False: 0]
  ------------------
  927|      0|					pgp_parse_hist_bytes(card, hist_bytes+1, hist_bytes_len-1);
  928|      0|				}
  929|      0|				break;
  930|      0|			case 0x10:
  ------------------
  |  Branch (930:4): [True: 0, False: 138]
  ------------------
  931|      0|				if (hist_bytes_len > 2) {
  ------------------
  |  Branch (931:9): [True: 0, False: 0]
  ------------------
  932|      0|					pgp_parse_hist_bytes(card, hist_bytes+2, hist_bytes_len-2);
  933|      0|				}
  934|      0|				break;
  935|    138|		}
  936|    138|	}
  937|       |
  938|       |	/* v1.1 does not support lifecycle via ACTIVATE & TERMINATE: set default */
  939|    329|	priv->ext_caps &= ~EXT_CAP_LCS;
  940|       |
  941|    329|	if (priv->bcd_version >= OPENPGP_CARD_2_0) {
  ------------------
  |  Branch (941:6): [True: 320, False: 9]
  ------------------
  942|       |		/* get card capabilities from "historical bytes" DO */
  943|    320|		if ((pgp_get_blob(card, priv->mf, 0x5f52, &blob) >= 0) &&
  ------------------
  |  Branch (943:7): [True: 320, False: 0]
  ------------------
  944|    320|		    (blob->data != NULL) && (blob->data[0] == 0x00)) {
  ------------------
  |  Branch (944:7): [True: 17, False: 303]
  |  Branch (944:31): [True: 17, False: 0]
  ------------------
  945|       |
  946|     17|			if (blob->len > 4) {
  ------------------
  |  Branch (946:8): [True: 17, False: 0]
  ------------------
  947|     17|				pgp_parse_hist_bytes(card, blob->data+1, blob->len-4);
  948|     17|			}
  949|       |
  950|       |			/* get card status from historical bytes status indicator */
  951|     17|			if ((blob->data[0] == 0x00) && (blob->len >= 4)) {
  ------------------
  |  Branch (951:8): [True: 17, False: 0]
  |  Branch (951:35): [True: 17, False: 0]
  ------------------
  952|     17|				priv->state = blob->data[blob->len-3];
  953|       |				/* state not CARD_STATE_UNKNOWN => LCS supported */
  954|     17|				if (priv->state != CARD_STATE_UNKNOWN)
  ------------------
  |  Branch (954:9): [True: 14, False: 3]
  ------------------
  955|     14|					priv->ext_caps |= EXT_CAP_LCS;
  956|     17|			}
  957|     17|		}
  958|    320|	}
  959|       |
  960|    329|	if (priv->bcd_version >= OPENPGP_CARD_3_1) {
  ------------------
  |  Branch (960:6): [True: 306, False: 23]
  ------------------
  961|    306|		card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|    306|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  962|    306|	}
  963|       |
  964|    329|	if (priv->bcd_version >= OPENPGP_CARD_3_4) {
  ------------------
  |  Branch (964:6): [True: 306, False: 23]
  ------------------
  965|       |		/* Parse supported algorithms from Algorithm Information DO
  966|       |		 * see OpenPGP card spec 3.4 section 4.4.3.11 */
  967|    306|		if (pgp_get_blob(card, priv->mf, 0x00fa, &blobfa) >= 0) {
  ------------------
  |  Branch (967:7): [True: 306, False: 0]
  ------------------
  968|    306|			pgp_blob_t *child;
  969|    306|			pgp_enumerate_blob(card, blobfa);
  970|       |			/* There will be multiple children with the same ID, but
  971|       |			 * different algos, so we need to iterate over all of them */
  972|  31.3k|			for (child = blobfa->files; child; child = child->next) {
  ------------------
  |  Branch (972:32): [True: 31.0k, False: 306]
  ------------------
  973|  31.0k|				if ((child->id < 0x00c1) || (child->id > 0x00c3))
  ------------------
  |  Branch (973:9): [True: 13.5k, False: 17.5k]
  |  Branch (973:33): [True: 1.67k, False: 15.9k]
  ------------------
  974|  15.1k|					continue;
  975|  15.9k|				sc_cardctl_openpgp_key_gen_store_info_t key_info;
  976|  15.9k|				if (pgp_parse_algo_attr_blob(card, child, &key_info) >= 0)
  ------------------
  |  Branch (976:9): [True: 3.83k, False: 12.0k]
  ------------------
  977|  3.83k|					handled_algos += _pgp_add_algo(card, &key_info, 0x00fa);
  978|  15.9k|			}
  979|    306|		}
  980|    306|	}
  981|       |
  982|       |	/* v1.1 & v2.x: special DOs are limited to 254 bytes */
  983|    329|	priv->max_specialDO_size = 254;
  984|       |
  985|    329|	if ((pgp_get_blob(card, priv->mf, 0x006e, &blob6e) >= 0) &&
  ------------------
  |  Branch (985:6): [True: 329, False: 0]
  ------------------
  986|    329|	    (pgp_get_blob(card, blob6e, 0x0073, &blob73) >= 0)) {
  ------------------
  |  Branch (986:6): [True: 168, False: 161]
  ------------------
  987|       |
  988|       |		/* get "extended capabilities" DO */
  989|    168|		if ((pgp_get_blob(card, blob73, 0x00c0, &blob) >= 0) &&
  ------------------
  |  Branch (989:7): [True: 162, False: 6]
  ------------------
  990|    162|		    (blob->data != NULL) && (blob->len > 0)) {
  ------------------
  |  Branch (990:7): [True: 162, False: 0]
  |  Branch (990:31): [True: 162, False: 0]
  ------------------
  991|    162|			if ((blob->data[0] & 0x01) && (priv->bcd_version >= OPENPGP_CARD_3_3)) {
  ------------------
  |  Branch (991:8): [True: 23, False: 139]
  |  Branch (991:34): [True: 17, False: 6]
  ------------------
  992|     17|				priv->ext_caps |= EXT_CAP_KDF_DO;
  993|     17|			}
  994|       |			/* v2.0+: bit 0x04 in first byte means "algorithm attributes changeable" */
  995|    162|			if ((blob->data[0] & 0x04) &&
  ------------------
  |  Branch (995:8): [True: 155, False: 7]
  ------------------
  996|    155|					(priv->bcd_version >= OPENPGP_CARD_2_0))
  ------------------
  |  Branch (996:6): [True: 154, False: 1]
  ------------------
  997|    154|				priv->ext_caps |= EXT_CAP_ALG_ATTR_CHANGEABLE;
  998|       |			/* bit 0x08 in first byte means "support for private use DOs" */
  999|    162|			if (blob->data[0] & 0x08)
  ------------------
  |  Branch (999:8): [True: 22, False: 140]
  ------------------
 1000|     22|				priv->ext_caps |= EXT_CAP_PRIVATE_DO;
 1001|       |			/* bit 0x10 in first byte means "support for CHV status byte changeable" */
 1002|    162|			if (blob->data[0] & 0x10)
  ------------------
  |  Branch (1002:8): [True: 42, False: 120]
  ------------------
 1003|     42|				priv->ext_caps |= EXT_CAP_C4_CHANGEABLE;
 1004|       |			/* bit 0x20 in first byte means "support for Key Import" */
 1005|    162|			if (blob->data[0] & 0x20)
  ------------------
  |  Branch (1005:8): [True: 43, False: 119]
  ------------------
 1006|     43|				priv->ext_caps |= EXT_CAP_KEY_IMPORT;
 1007|       |			/* bit 0x40 in first byte means "support for Get Challenge" */
 1008|    162|			if (blob->data[0] & 0x40) {
  ------------------
  |  Branch (1008:8): [True: 26, False: 136]
  ------------------
 1009|     26|				card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|     26|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
 1010|     26|				priv->ext_caps |= EXT_CAP_GET_CHALLENGE;
 1011|     26|			}
 1012|       |			/* v2.0+: bit 0x80 in first byte means "support Secure Messaging" */
 1013|    162|			if ((blob->data[0] & 0x80) &&
  ------------------
  |  Branch (1013:8): [True: 36, False: 126]
  ------------------
 1014|     36|					(priv->bcd_version >= OPENPGP_CARD_2_0))
  ------------------
  |  Branch (1014:6): [True: 35, False: 1]
  ------------------
 1015|     35|				priv->ext_caps |= EXT_CAP_SM;
 1016|       |
 1017|    162|			if ((priv->bcd_version >= OPENPGP_CARD_2_0) && (blob->len >= 10)) {
  ------------------
  |  Branch (1017:8): [True: 161, False: 1]
  |  Branch (1017:51): [True: 161, False: 0]
  ------------------
 1018|       |				/* v2.0+: max. challenge size is at bytes 3-4 */
 1019|    161|				priv->max_challenge_size = bebytes2ushort(blob->data + 2);
 1020|       |				/* v2.0+: max. cert size it at bytes 5-6 */
 1021|    161|				priv->max_cert_size = bebytes2ushort(blob->data + 4);
 1022|       |
 1023|    161|				if (priv->bcd_version < OPENPGP_CARD_3_0) {
  ------------------
  |  Branch (1023:9): [True: 10, False: 151]
  ------------------
 1024|       |					/* v2.x: SM algorithm is at byte 2: 0 == 3DES */
 1025|     10|					priv->sm_algo = blob->data[1];
 1026|     10|					if ((priv->sm_algo == SM_ALGO_NONE) && (priv->ext_caps & EXT_CAP_SM))
  ------------------
  |  Branch (1026:10): [True: 9, False: 1]
  |  Branch (1026:45): [True: 2, False: 7]
  ------------------
 1027|      2|						priv->sm_algo = SM_ALGO_3DES;
 1028|       |
 1029|       |					/* v2.x: max. send/receive sizes are at bytes 7-8 resp. 9-10 */
 1030|     10|					card->max_send_size = bebytes2ushort(blob->data + 6);
 1031|     10|					card->max_recv_size = bebytes2ushort(blob->data + 8);
 1032|     10|				}
 1033|    151|				else {
 1034|       |					/* v3.0+: SM algorithm is at byte 2: 0 == UNKNOWN */
 1035|    151|					priv->sm_algo = blob->data[1];
 1036|    151|					if ((priv->sm_algo == SM_ALGO_NONE) && (priv->ext_caps & EXT_CAP_SM))
  ------------------
  |  Branch (1036:10): [True: 98, False: 53]
  |  Branch (1036:45): [True: 3, False: 95]
  ------------------
 1037|      3|						priv->sm_algo = SM_ALGO_UNKNOWN;
 1038|       |
 1039|       |					/* v3.0+: max. size of special DOs is at bytes 7-8 */
 1040|    151|					priv->max_specialDO_size = bebytes2ushort(blob->data + 6);
 1041|    151|				}
 1042|    161|				if (priv->bcd_version >= OPENPGP_CARD_3_3 && (blob->len >= 10)) {
  ------------------
  |  Branch (1042:9): [True: 148, False: 13]
  |  Branch (1042:50): [True: 148, False: 0]
  ------------------
 1043|       |					/* v3.3+: MSE for key numbers 2(DEC) and 3(AUT) supported */
 1044|    148|					if (blob->data[9])
  ------------------
  |  Branch (1044:10): [True: 68, False: 80]
  ------------------
 1045|     68|						priv->ext_caps |= EXT_CAP_MSE;
 1046|    148|				}
 1047|    161|			}
 1048|    162|		}
 1049|       |
 1050|       |		/* get max. PIN length from "CHV status bytes" DO */
 1051|    168|		if ((pgp_get_blob(card, blob73, 0x00c4, &blob) >= 0) &&
  ------------------
  |  Branch (1051:7): [True: 98, False: 70]
  ------------------
 1052|     98|			(blob->data != NULL) && (blob->len > 1)) {
  ------------------
  |  Branch (1052:4): [True: 68, False: 30]
  |  Branch (1052:28): [True: 68, False: 0]
  ------------------
 1053|       |			/* 2nd byte in "CHV status bytes" DO means "max. PIN length" */
 1054|     68|			card->max_pin_len = blob->data[1];
 1055|     68|		}
 1056|       |
 1057|    168|		if (priv->bcd_version >= OPENPGP_CARD_3_0) {
  ------------------
  |  Branch (1057:7): [True: 157, False: 11]
  ------------------
 1058|       |			/* v3.0+: get length info from "extended length information" DO */
 1059|    157|			if ((pgp_get_blob(card, blob6e, 0x7f66, &blob) >= 0) &&
  ------------------
  |  Branch (1059:8): [True: 1, False: 156]
  ------------------
 1060|      1|				(blob->data != NULL) && (blob->len >= 8)) {
  ------------------
  |  Branch (1060:5): [True: 1, False: 0]
  |  Branch (1060:29): [True: 1, False: 0]
  ------------------
 1061|       |				/* kludge: treat as SIMPLE DO and use appropriate offsets */
 1062|      1|				card->max_send_size = bebytes2ushort(blob->data + 2);
 1063|      1|				card->max_recv_size = bebytes2ushort(blob->data + 6);
 1064|      1|			}
 1065|    157|		}
 1066|       |
 1067|    168|#ifdef ENABLE_OPENSSL
 1068|    168|		if (priv->ext_caps & EXT_CAP_KDF_DO) {
  ------------------
  |  Branch (1068:7): [True: 17, False: 151]
  ------------------
 1069|     17|			int r = pgp_decode_kdf_do(card, priv);
 1070|     17|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     17|#define SC_SUCCESS				0
  ------------------
  |  Branch (1070:8): [True: 16, False: 1]
  ------------------
 1071|     16|				sc_log(card->ctx, "Failed to decode KDF DO: %s", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1072|     16|			}
 1073|     17|		}
 1074|    168|#endif /* ENABLE_OPENSSL */
 1075|       |
 1076|       |		/* if we found at least one usable algo, let's skip other ways to find them */
 1077|    168|		if (handled_algos) {
  ------------------
  |  Branch (1077:7): [True: 2, False: 166]
  ------------------
 1078|      2|			sc_log(card->ctx, "Algo list populated from Algorithm Information DO");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1079|      2|			LOG_FUNC_RETURN(card->ctx, handled_algos);
  ------------------
  |  |  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: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1080|      2|		}
 1081|       |
 1082|       |		/* get _current_ algorithms & key lengths from "algorithm attributes" DOs
 1083|       |		 *
 1084|       |		 * All available algorithms should be already provided by pgp_init. However, if another
 1085|       |		 * algorithm is found in the "algorithm attributes" DOs, it is supported by the card as
 1086|       |		 * well and therefore added
 1087|       |		 * see OpenPGP card spec 1.1 & 2.x section 4.3.3.6 / v3.x section 4.4.3.7 */
 1088|    664|		for (i = 0x00c1; i <= 0x00c3; i++) {
  ------------------
  |  Branch (1088:20): [True: 498, False: 166]
  ------------------
 1089|    498|			sc_cardctl_openpgp_key_gen_store_info_t key_info;
 1090|       |
 1091|    498|			sc_log(card->ctx, "Parsing algorithm attributes DO %uX" , i);
  ------------------
  |  |   71|    498|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1092|       |
 1093|       |			/* OpenPGP card spec 1.1 & 2.x section 4.3.3.6 / v3.x section 4.4.3.7 */
 1094|    498|			if ((pgp_get_blob(card, blob73, i, &blob) >= 0) &&
  ------------------
  |  Branch (1094:8): [True: 113, False: 385]
  ------------------
 1095|    113|			    (pgp_parse_algo_attr_blob(card, blob, &key_info) >= 0)) {
  ------------------
  |  Branch (1095:8): [True: 0, False: 113]
  ------------------
 1096|      0|				if (!_pgp_add_algo(card, &key_info, i))
  ------------------
  |  Branch (1096:9): [True: 0, False: 0]
  ------------------
 1097|      0|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1098|      0|			}
 1099|    498|		}
 1100|       |
 1101|    166|	}
 1102|       |
 1103|    327|	LOG_FUNC_RETURN(card->ctx, handled_algos);
  ------------------
  |  |  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: 245, False: 82]
  |  |  |  |  ------------------
  |  |  |  |  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|     82|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     82|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     82|	} \
  |  |  |  |  162|    327|	return _ret; \
  |  |  |  |  163|    327|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|    327|}
card-openpgp.c:pgp_parse_hist_bytes:
  600|     34|{
  601|     34|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|     34|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
  602|     34|	const u8 *ptr;
  603|       |
  604|       |	/* IS07816-4 hist bytes: 3rd function table */
  605|     34|	if ((ptr = sc_compacttlv_find_tag(ctlv, ctlv_len, 0x73, NULL)) != NULL) {
  ------------------
  |  Branch (605:6): [True: 21, False: 13]
  ------------------
  606|       |		/* bit 0x40 in byte 3 of TL 0x73 means "extended Le/Lc" */
  607|     21|		if (ptr[2] & 0x40) {
  ------------------
  |  Branch (607:7): [True: 17, False: 4]
  ------------------
  608|     17|			card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|     17|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  609|     17|			priv->ext_caps |= EXT_CAP_APDU_EXT;
  610|     17|		}
  611|       |		/* bit 0x80 in byte 3 of TL 0x73 means "Command chaining" */
  612|     21|		if (ptr[2] & 0x80) {
  ------------------
  |  Branch (612:7): [True: 20, False: 1]
  ------------------
  613|     20|			priv->ext_caps |= EXT_CAP_CHAINING;
  614|     20|		}
  615|     21|	}
  616|       |
  617|     34|	if ((priv->bcd_version >= OPENPGP_CARD_3_0) &&
  ------------------
  |  Branch (617:6): [True: 34, False: 0]
  ------------------
  618|     34|	    ((ptr = sc_compacttlv_find_tag(ctlv, ctlv_len, 0x31, NULL)) != NULL)) {
  ------------------
  |  Branch (618:6): [True: 4, False: 30]
  ------------------
  619|       |		// ToDo ...
  620|      4|	}
  621|     34|}
card-openpgp.c:pgp_decode_kdf_do:
  802|     17|{
  803|     17|	pgp_pin_kdf_info_t *pin_kdf_info = (pgp_pin_kdf_info_t *)calloc(1, sizeof(pgp_pin_kdf_info_t));
  804|     17|	int r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|     17|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  805|     17|	pgp_blob_t *kdf_blob;
  806|     17|	const uint8_t *data;
  807|     17|	size_t data_len;
  808|     17|	size_t tag_len;
  809|     17|	const uint8_t *p;
  810|     17|	pgp_blob_t *blob;
  811|       |
  812|     17|	if (!pin_kdf_info) {
  ------------------
  |  Branch (812:6): [True: 0, False: 17]
  ------------------
  813|      0|		return r;
  814|      0|	}
  815|       |
  816|     17|	r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     17|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  817|     17|	priv->pin_kdf_info = NULL;
  818|     17|	if ((pgp_get_blob(card, priv->mf, DO_KDF, &kdf_blob) != SC_SUCCESS) || (kdf_blob->len < 3)) {
  ------------------
  |  |  159|     17|#define DO_KDF                   0xf9
  ------------------
              	if ((pgp_get_blob(card, priv->mf, DO_KDF, &kdf_blob) != SC_SUCCESS) || (kdf_blob->len < 3)) {
  ------------------
  |  |   28|     17|#define SC_SUCCESS				0
  ------------------
  |  Branch (818:6): [True: 0, False: 17]
  |  Branch (818:73): [True: 4, False: 13]
  ------------------
  819|      4|		sc_log(card->ctx, "KDF DO does not exists or contains invalid data but card claims to support it");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  820|      4|		goto out;
  821|      4|	}
  822|       |
  823|     13|	data = kdf_blob->data;
  824|     13|	data_len = kdf_blob->len;
  825|     13|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x81, &tag_len);
  826|     13|	if (!p) {
  ------------------
  |  Branch (826:6): [True: 3, False: 10]
  ------------------
  827|      3|		sc_log(card->ctx, "KDF algorithm byte not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  828|      3|		goto out;
  829|      3|	}
  830|     10|	if (tag_len != 1) {
  ------------------
  |  Branch (830:6): [True: 1, False: 9]
  ------------------
  831|      1|		sc_log(card->ctx, "Unexpected KDF algorithm byte length, expects 1, got %" SC_FORMAT_LEN_SIZE_T "u", 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__
  |  |  ------------------
  ------------------
  832|      1|		goto out;
  833|      1|	}
  834|       |
  835|      9|	if (*p != 0x3) {
  ------------------
  |  Branch (835:6): [True: 1, False: 8]
  ------------------
  836|      1|		if (*p == 0x0) {
  ------------------
  |  Branch (836:7): [True: 0, False: 1]
  ------------------
  837|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  838|      0|			sc_log(card->ctx, "KDF derived PIN format disabled");
  ------------------
  |  |   71|      0|#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|      1|		} else {
  840|      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__
  |  |  ------------------
  ------------------
  841|      1|		}
  842|      1|		goto out;
  843|      1|	}
  844|       |
  845|      8|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x82, &tag_len);
  846|      8|	if (!p) {
  ------------------
  |  Branch (846:6): [True: 1, False: 7]
  ------------------
  847|      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__
  |  |  ------------------
  ------------------
  848|      1|		goto out;
  849|      1|	}
  850|      7|	if (tag_len != 1) {
  ------------------
  |  Branch (850:6): [True: 1, False: 6]
  ------------------
  851|      1|		sc_log(card->ctx, "Unexpected KDF hash algorithm byte length, expects 1, got %" SC_FORMAT_LEN_SIZE_T "u", 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__
  |  |  ------------------
  ------------------
  852|      1|		goto out;
  853|      1|	}
  854|       |
  855|      6|	switch (*p) {
  856|      3|	case 0x08:
  ------------------
  |  Branch (856:2): [True: 3, False: 3]
  ------------------
  857|      3|		pin_kdf_info->hash_algo = "SHA256";
  858|      3|		break;
  859|      2|	case 0x0A:
  ------------------
  |  Branch (859:2): [True: 2, False: 4]
  ------------------
  860|      2|		pin_kdf_info->hash_algo = "SHA512";
  861|      2|		break;
  862|      1|	default:
  ------------------
  |  Branch (862:2): [True: 1, False: 5]
  ------------------
  863|      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__
  |  |  ------------------
  ------------------
  864|      1|		goto out;
  865|      6|	}
  866|       |
  867|      5|	p = sc_asn1_find_tag(card->ctx, data, data_len, 0x83, &tag_len);
  868|      5|	if (!p) {
  ------------------
  |  Branch (868:6): [True: 1, False: 4]
  ------------------
  869|      1|		sc_log(card->ctx, "KDF iteration count 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__
  |  |  ------------------
  ------------------
  870|      1|		goto out;
  871|      1|	}
  872|      4|	if (tag_len != 4) {
  ------------------
  |  Branch (872:6): [True: 1, False: 3]
  ------------------
  873|      1|		sc_log(card->ctx, "Unexpected KDF iteration count length, expects 4, got %" SC_FORMAT_LEN_SIZE_T "u", 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__
  |  |  ------------------
  ------------------
  874|      1|		goto out;
  875|      1|	}
  876|      3|	pin_kdf_info->iterations = (uint32_t)bebytes2ulong(p);
  877|       |
  878|      3|	r = pgp_get_blob(card, kdf_blob, 0x84, &blob);
  879|      3|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  |  Branch (879:6): [True: 1, False: 2]
  ------------------
  880|      1|		sc_log(card->ctx, "Failed to get salt bytes of user 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__
  |  |  ------------------
  ------------------
  881|      1|		goto out;
  882|      1|	}
  883|      2|	pin_kdf_info->userpw_salt = blob;
  884|       |
  885|      2|	r = pgp_get_blob(card, kdf_blob, 0x86, &blob);
  886|      2|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
  |  Branch (886:6): [True: 1, False: 1]
  ------------------
  887|      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__
  |  |  ------------------
  ------------------
  888|      1|		goto out;
  889|      1|	}
  890|      1|	pin_kdf_info->adminpw_salt = blob;
  891|       |
  892|      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__
  |  |  ------------------
  ------------------
  893|      1|	priv->pin_kdf_info = pin_kdf_info;
  894|      1|	return r;
  895|     16|out:
  896|     16|	free(pin_kdf_info);
  897|     16|	return r;
  898|      2|}
card-openpgp.c:pgp_finish:
 1112|    331|{
 1113|    331|	if (card != NULL) {
  ------------------
  |  Branch (1113:6): [True: 331, False: 0]
  ------------------
 1114|    331|		struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    331|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1115|       |
 1116|    331|		if (priv != NULL) {
  ------------------
  |  Branch (1116:7): [True: 331, False: 0]
  ------------------
 1117|       |			/* delete fake file hierarchy */
 1118|    331|			pgp_free_blobs(priv->mf);
 1119|       |
 1120|       |			/* delete kdf do related data if exists */
 1121|    331|			free(priv->pin_kdf_info);
 1122|       |
 1123|       |			/* delete private data */
 1124|    331|			free(priv);
 1125|    331|		}
 1126|    331|		card->drv_data = NULL;
 1127|    331|	}
 1128|    331|	return SC_SUCCESS;
  ------------------
  |  |   28|    331|#define SC_SUCCESS				0
  ------------------
 1129|    331|}
card-openpgp.c:pgp_free_blobs:
 1325|  45.9k|{
 1326|  45.9k|	if (blob) {
  ------------------
  |  Branch (1326:6): [True: 45.9k, False: 2]
  ------------------
 1327|  45.9k|		pgp_blob_t *child = blob->files;
 1328|       |
 1329|  91.5k|		while (child != NULL) {
  ------------------
  |  Branch (1329:10): [True: 45.6k, False: 45.9k]
  ------------------
 1330|  45.6k|			pgp_blob_t *next = child->next;
 1331|       |
 1332|  45.6k|			pgp_free_blobs(child);
 1333|  45.6k|			child = next;
 1334|  45.6k|		}
 1335|  45.9k|		pgp_free_blob(blob);
 1336|  45.9k|	}
 1337|  45.9k|}
card-openpgp.c:pgp_free_blob:
 1300|  45.9k|{
 1301|  45.9k|	if (blob) {
  ------------------
  |  Branch (1301:6): [True: 45.9k, False: 0]
  ------------------
 1302|  45.9k|		if (blob->parent) {
  ------------------
  |  Branch (1302:7): [True: 45.6k, False: 329]
  ------------------
 1303|  45.6k|			pgp_blob_t **p;
 1304|       |
 1305|       |			/* remove blob from list of parent's children */
 1306|  45.6k|			for (p = &blob->parent->files; *p != NULL && *p != blob; p = &(*p)->next)
  ------------------
  |  Branch (1306:35): [True: 45.6k, False: 0]
  |  Branch (1306:49): [True: 0, False: 45.6k]
  ------------------
 1307|      0|				;
 1308|  45.6k|			if (*p == blob)
  ------------------
  |  Branch (1308:8): [True: 45.6k, False: 0]
  ------------------
 1309|  45.6k|				*p = blob->next;
 1310|  45.6k|		}
 1311|       |
 1312|  45.9k|		sc_file_free(blob->file);
 1313|  45.9k|		if (blob->data)
  ------------------
  |  Branch (1313:7): [True: 23.5k, False: 22.4k]
  ------------------
 1314|  23.5k|			free(blob->data);
 1315|  45.9k|		free(blob);
 1316|  45.9k|	}
 1317|  45.9k|}
card-openpgp.c:pgp_select_file:
 1611|  2.79k|{
 1612|  2.79k|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|  2.79k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1613|  2.79k|	pgp_blob_t	*blob;
 1614|  2.79k|	unsigned int	path_start = 0;
 1615|  2.79k|	unsigned int	n;
 1616|  2.79k|	sc_path_t dummy_path;
 1617|       |
 1618|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1619|       |
 1620|  2.79k|	if (path->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  2.79k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (1620:6): [True: 859, False: 1.93k]
  ------------------
 1621|  2.79k|		LOG_FUNC_RETURN(card->ctx, iso_ops->select_file(card, path, ret));
  ------------------
  |  |  164|    859|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    859|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    859|	int _ret = r; \
  |  |  |  |  155|    859|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 859, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    859|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    506|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 506, False: 353]
  |  |  |  |  ------------------
  |  |  |  |  157|    859|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    859|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    859|	return _ret; \
  |  |  |  |  163|    859|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1622|       |
 1623|  1.93k|	if (path->len < 2 || (path->len & 1))
  ------------------
  |  Branch (1623:6): [True: 0, False: 1.93k]
  |  Branch (1623:23): [True: 0, False: 1.93k]
  ------------------
 1624|  1.93k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1625|  1.93k|				"invalid path length");
 1626|       |
 1627|  1.93k|	if (path->type == SC_PATH_TYPE_FILE_ID && path->len != 2)
  ------------------
  |  |  117|  3.86k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (1627:6): [True: 0, False: 1.93k]
  |  Branch (1627:44): [True: 0, False: 0]
  ------------------
 1628|  1.93k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1629|  1.93k|				"invalid path type");
 1630|       |
 1631|       |	/* Due to pkcs15init implementation, sometimes a file at path "11001101"
 1632|       |	 * need to be written (one use case is when importing key&cert from p12 file).
 1633|       |	 * This file does not exist in OpenPGP but pkcs15 requires that
 1634|       |	 * writing this file must be successful.
 1635|       |	 * So, we pretend that selecting & writing this file is successful.
 1636|       |	 * The "11001101"is defined in sc_pkcs15emu_get_df() function, pkcs15-sync.c file. */
 1637|  1.93k|	sc_format_path("11001101", &dummy_path);
 1638|  1.93k|	if (sc_compare_path(path, &dummy_path)) {
  ------------------
  |  Branch (1638:6): [True: 0, False: 1.93k]
  ------------------
 1639|      0|		if (ret != NULL) {
  ------------------
  |  Branch (1639:7): [True: 0, False: 0]
  ------------------
 1640|      0|			*ret = sc_file_new();
 1641|       |			/* One use case of this dummy file is after writing certificate in pkcs15init.
 1642|       |			 * So we set its size to be the same as max certificate size the card supports. */
 1643|      0|			(*ret)->size = priv->max_cert_size;
 1644|      0|		}
 1645|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1646|      0|	}
 1647|       |
 1648|       |	/* ignore explicitly mentioned MF at the path's beginning */
 1649|  1.93k|	path_start = pgp_strip_path(card, path);
 1650|       |
 1651|       |	/* starting with the MF ... */
 1652|  1.93k|	blob = priv->mf;
 1653|       |	/* ... recurse through the tree following the path */
 1654|  2.96k|	for (n = path_start; n < path->len; n += 2) {
  ------------------
  |  Branch (1654:23): [True: 2.26k, False: 707]
  ------------------
 1655|  2.26k|		unsigned int	id = bebytes2ushort(path->value + n);
 1656|  2.26k|		int		r = pgp_get_blob(card, blob, id, &blob);
 1657|       |
 1658|       |		/* This file ID is referred when importing key&certificate via pkcs15init, like above.
 1659|       |		 * We pretend to successfully find this inexistent file. */
 1660|  2.26k|		if (id == 0x4402 || id == 0x5f48) {
  ------------------
  |  Branch (1660:7): [True: 0, False: 2.26k]
  |  Branch (1660:23): [True: 0, False: 2.26k]
  ------------------
 1661|      0|			if (ret == NULL)
  ------------------
  |  Branch (1661:8): [True: 0, False: 0]
  ------------------
 1662|       |				/* No need to return file */
 1663|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1664|       |
 1665|       |			/* Else, need to return file */
 1666|      0|			*ret = sc_file_new();
 1667|      0|			(*ret)->size = priv->max_cert_size;
 1668|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1669|      0|		}
 1670|       |
 1671|  2.26k|		if (r < 0) {	/* failure */
  ------------------
  |  Branch (1671:7): [True: 1.22k, False: 1.03k]
  ------------------
 1672|  1.22k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.22k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.22k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.22k|	int _ret = r; \
  |  |  |  |  155|  1.22k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.22k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|  1.22k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.22k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.22k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.22k|	return _ret; \
  |  |  |  |  163|  1.22k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1673|  1.22k|		}
 1674|  2.26k|	}
 1675|       |
 1676|       |	/* success: select file = set "current" pointer to blob found */
 1677|    707|	priv->current = blob;
 1678|       |
 1679|    707|	if (ret)
  ------------------
  |  Branch (1679:6): [True: 385, False: 322]
  ------------------
 1680|    385|		sc_file_dup(ret, blob->file);
 1681|       |
 1682|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1683|    707|}
card-openpgp.c:pgp_strip_path:
 1592|  1.93k|{
 1593|  1.93k|	unsigned int start_point = 0;
 1594|       |	/* start_point will move through the path string */
 1595|  1.93k|	if (path->len == 0)
  ------------------
  |  Branch (1595:6): [True: 0, False: 1.93k]
  ------------------
 1596|      0|		return 0;
 1597|       |
 1598|       |	/* ignore 3F00 (MF) at the beginning */
 1599|  1.93k|	start_point = (memcmp(path->value, "\x3f\x00", 2) == 0) ? 2 : 0;
  ------------------
  |  Branch (1599:16): [True: 1.15k, False: 783]
  ------------------
 1600|       |	/* strip path of PKCS15-App DF (5015) */
 1601|  1.93k|	start_point += (memcmp(path->value + start_point, "\x50\x15", 2) == 0) ? 2 : 0;
  ------------------
  |  Branch (1601:17): [True: 973, False: 960]
  ------------------
 1602|  1.93k|	return start_point;
 1603|  1.93k|}
card-openpgp.c:pgp_read_binary:
 1752|    441|{
 1753|    441|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    441|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1754|    441|	pgp_blob_t	*blob;
 1755|    441|	int		r;
 1756|       |
 1757|    441|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    441|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    441|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    441|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    441|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 441]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1758|       |
 1759|       |	/* jump to selected file */
 1760|    441|	blob = priv->current;
 1761|       |
 1762|    441|	if (blob == NULL)
  ------------------
  |  Branch (1762:6): [True: 0, False: 441]
  ------------------
 1763|    441|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1764|       |
 1765|    441|	if (blob->file->type != SC_FILE_TYPE_WORKING_EF)
  ------------------
  |  |  216|    441|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1765:6): [True: 0, False: 441]
  ------------------
 1766|    441|		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|    441|	if ((r = pgp_read_blob(card, blob)) < 0)
  ------------------
  |  Branch (1768:6): [True: 134, False: 307]
  ------------------
 1769|    441|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    134|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    134|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    134|	int _ret = r; \
  |  |  |  |  155|    134|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 134, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    134|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    134|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 134, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    134|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    134|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    134|	return _ret; \
  |  |  |  |  163|    134|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1770|       |
 1771|    307|	if (idx > blob->len)
  ------------------
  |  Branch (1771:6): [True: 0, False: 307]
  ------------------
 1772|    307|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1773|       |
 1774|    307|	if (idx + count > blob->len)
  ------------------
  |  Branch (1774:6): [True: 43, False: 264]
  ------------------
 1775|     43|		count = blob->len - idx;
 1776|    307|	memcpy(buf, blob->data + idx, count);
 1777|       |
 1778|    307|	LOG_FUNC_RETURN(card->ctx, (int)count);
  ------------------
  |  |  164|    307|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    307|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    307|	int _ret = r; \
  |  |  |  |  155|    307|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 33, False: 274]
  |  |  |  |  ------------------
  |  |  |  |  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|    274|	} else { \
  |  |  |  |  159|    274|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    274|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    274|	} \
  |  |  |  |  162|    307|	return _ret; \
  |  |  |  |  163|    307|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1779|    307|}
card-openpgp.c:pgp_pin_cmd:
 2389|    189|{
 2390|    189|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    189|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2391|    189|	struct sc_card_operations ops = {.pin_cmd = iso_ops->pin_cmd};
 2392|       |
 2393|    189|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2394|       |
 2395|    189|	if (data->pin_type != SC_AC_CHV)
  ------------------
  |  |  151|    189|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (2395:6): [True: 0, False: 189]
  ------------------
 2396|    189|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2397|    189|				"invalid PIN type");
 2398|       |
 2399|       |	/* In general, the PIN Reference is extracted from the key-id,
 2400|       |	 * for example, CHV0 -> Ref=0, CHV1 -> Ref=1.
 2401|       |	 * However, in the case of OpenPGP, the PIN Ref to compose APDU
 2402|       |	 * must be 81, 82, 83.
 2403|       |	 * So, if we receive Ref=1, Ref=2, we must convert to 81, 82...
 2404|       |	 * In OpenPGP v1, the PINs are named CHV1, CHV2, CHV3.
 2405|       |	 * In v2, they are named PW1, PW3 (PW1 operates in 2 modes).
 2406|       |	 *
 2407|       |	 * The PIN references (P2 in APDU) for "VERIFY" are the same in both versions:
 2408|       |	 * 81 (CHV1 or PW1), 82 (CHV2 or PW1-mode 2), 83 (CHV3 or PW3),
 2409|       |	 * On the other hand from version 2.0 "CHANGE REFERENCE DATA" and
 2410|       |	 * "RESET RETRY COUNTER" don't support PW1-mode 2 (82) and need this
 2411|       |	 * value changed to PW1 (81).
 2412|       |	 * Both of these commands also differ between card versions in that
 2413|       |	 * v1 cards can use only implicit old PIN or CHV3 test for both commands
 2414|       |	 * whereas v2 can use both implicit (for PW3) and explicit
 2415|       |	 * (for special "Resetting Code") PIN test for "RESET RETRY COUNTER"
 2416|       |	 * and only explicit test for "CHANGE REFERENCE DATA".
 2417|       |	 *
 2418|       |	 * Note that if this function is called from sc_pkcs15_verify_pin() in pkcs15-pin.c,
 2419|       |	 * the Ref is already 81, 82, 83.
 2420|       |	 */
 2421|       |
 2422|       |	/* convert the PIN Reference if needed */
 2423|    189|	data->pin_reference |= 0x80;
 2424|       |
 2425|       |	/* check version-dependent constraints */
 2426|    189|	if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  423|    378|#define SC_PIN_CMD_CHANGE	1
  ------------------
              	if (data->cmd == SC_PIN_CMD_CHANGE || data->cmd == SC_PIN_CMD_UNBLOCK) {
  ------------------
  |  |  424|    189|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2426:6): [True: 0, False: 189]
  |  Branch (2426:40): [True: 0, False: 189]
  ------------------
 2427|      0|		if (priv->bcd_version >= OPENPGP_CARD_2_0) {
  ------------------
  |  Branch (2427:7): [True: 0, False: 0]
  ------------------
 2428|      0|			if (data->pin_reference == 0x82)
  ------------------
  |  Branch (2428:8): [True: 0, False: 0]
  ------------------
 2429|      0|				data->pin_reference = 0x81;
 2430|       |
 2431|      0|			if (data->cmd == SC_PIN_CMD_CHANGE) {
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (2431:8): [True: 0, False: 0]
  ------------------
 2432|      0|				if (data->pin1.len == 0 &&
  ------------------
  |  Branch (2432:9): [True: 0, False: 0]
  ------------------
 2433|      0|				    !(data->flags & SC_PIN_CMD_USE_PINPAD))
  ------------------
  |  |  428|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (2433:9): [True: 0, False: 0]
  ------------------
 2434|      0|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2435|      0|							"v2 cards don't support implicit old PIN for PIN change");
 2436|       |
 2437|      0|				data->flags &= ~SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  430|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 2438|      0|			}
 2439|      0|		} else {
 2440|      0|			if (data->pin1.len != 0) {
  ------------------
  |  Branch (2440:8): [True: 0, False: 0]
  ------------------
 2441|      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__
  |  |  ------------------
  ------------------
 2442|      0|				       "v1 cards don't support explicit old or CHV3 PIN, PIN ignored.");
 2443|      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__
  |  |  ------------------
  ------------------
 2444|      0|				       "please make sure that you have verified the relevant PIN first.");
 2445|      0|				data->pin1.len = 0;
 2446|      0|			}
 2447|       |
 2448|      0|			data->flags |= SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  430|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 2449|      0|		}
 2450|      0|	}
 2451|       |
 2452|    189|	if (data->cmd == SC_PIN_CMD_UNBLOCK && data->pin2.len == 0 &&
  ------------------
  |  |  424|    378|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (2452:6): [True: 0, False: 189]
  |  Branch (2452:41): [True: 0, False: 0]
  ------------------
 2453|      0|	    !(data->flags & SC_PIN_CMD_USE_PINPAD))
  ------------------
  |  |  428|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (2453:6): [True: 0, False: 0]
  ------------------
 2454|    189|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2455|    189|				"new PIN must be provided for unblock operation");
 2456|       |
 2457|       |	/* ensure pin_reference is 81, 82, 83 */
 2458|    189|	if (data->pin_reference < 0x81 || data->pin_reference > 0x83)
  ------------------
  |  Branch (2458:6): [True: 0, False: 189]
  |  Branch (2458:36): [True: 0, False: 189]
  ------------------
 2459|    189|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2460|    189|				"Invalid key ID; must be 1, 2, or 3");
 2461|       |
 2462|       |	/* emulate SC_PIN_CMD_GET_INFO command for cards not supporting it */
 2463|    189|	if (data->cmd == SC_PIN_CMD_GET_INFO && (card->caps & SC_CARD_CAP_ISO7816_PIN_INFO) == 0) {
  ------------------
  |  |  425|    378|#define SC_PIN_CMD_GET_INFO	3
  ------------------
              	if (data->cmd == SC_PIN_CMD_GET_INFO && (card->caps & SC_CARD_CAP_ISO7816_PIN_INFO) == 0) {
  ------------------
  |  |  560|    189|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  |  Branch (2463:6): [True: 189, False: 0]
  |  Branch (2463:42): [True: 12, False: 177]
  ------------------
 2464|     12|		u8 c4data[10];
 2465|     12|		int r;
 2466|       |
 2467|     12|		r = sc_get_data(card, 0x00c4, c4data, sizeof(c4data));
 2468|     12|		LOG_TEST_RET(card->ctx, r, "reading CHV status bytes 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: 11, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2469|       |
 2470|      1|		if (r != 7)
  ------------------
  |  Branch (2470:7): [True: 1, False: 0]
  ------------------
 2471|      1|			LOG_TEST_RET(card->ctx, SC_ERROR_OBJECT_NOT_VALID,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2472|      0|				"CHV status bytes have unexpected length");
 2473|       |
 2474|       |		/* The definition of fields of DO C4 changed between OpenPGP
 2475|       |		 * card specification v1.1 and v2.0. There is no longer a separate
 2476|       |		 * CHV2 retry counter but only one retry counter for both PW1 mode 1
 2477|       |		 * and mode 2 at byte 5 (count from 1) of the DO.
 2478|       |		 */
 2479|      0|		if (priv->bcd_version >= OPENPGP_CARD_2_0 && data->pin_reference == 0x82)
  ------------------
  |  Branch (2479:7): [True: 0, False: 0]
  |  Branch (2479:48): [True: 0, False: 0]
  ------------------
 2480|      0|			data->pin_reference = 0x81;
 2481|       |
 2482|      0|		data->pin1.tries_left = c4data[3 + (data->pin_reference & 0x0F)];
 2483|      0|		data->pin1.max_tries = 3;
 2484|      0|		data->pin1.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  437|      0|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 2485|       |
 2486|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2487|      0|	}
 2488|       |
 2489|    177|#ifdef ENABLE_OPENSSL
 2490|    177|	if (priv->pin_kdf_info) {
  ------------------
  |  Branch (2490:6): [True: 0, False: 177]
  ------------------
 2491|      0|		ops.pin_cmd = &pgp_kdf_do_pin_cmd;
 2492|      0|	}
 2493|    177|#endif /* ENABLE_OPENSSL */
 2494|       |
 2495|    177|	LOG_FUNC_RETURN(card->ctx, ops.pin_cmd(card, data));
  ------------------
  |  |  164|    177|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    177|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    177|	int _ret = r; \
  |  |  |  |  155|    177|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 177, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    177|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 65]
  |  |  |  |  ------------------
  |  |  |  |  157|    177|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    177|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    177|	return _ret; \
  |  |  |  |  163|    177|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2496|    177|}
card-openpgp.c:pgp_get_data:
 1991|  3.74k|{
 1992|  3.74k|	sc_apdu_t	apdu;
 1993|  3.74k|	int		r;
 1994|       |
 1995|  3.74k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  3.74k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.74k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.74k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.74k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.74k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1996|       |
 1997|  3.74k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xCA, tag >> 8, tag);
  ------------------
  |  |  301|  3.74k|#define SC_APDU_CASE_2			0x22
  ------------------
 1998|  3.74k|	apdu.le = ((buf_len >= 256) && !(card->caps & SC_CARD_CAP_APDU_EXT)) ? 256 : buf_len;
  ------------------
  |  |  554|  3.07k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (1998:13): [True: 3.07k, False: 674]
  |  Branch (1998:33): [True: 2.79k, False: 280]
  ------------------
 1999|  3.74k|	apdu.resp = buf;
 2000|  3.74k|	apdu.resplen = buf_len;
 2001|       |
 2002|  3.74k|	r = sc_transmit_apdu(card, &apdu);
 2003|  3.74k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  3.74k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.74k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.74k|	int _ret = (r); \
  |  |  |  |  168|  3.74k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 129, False: 3.61k]
  |  |  |  |  ------------------
  |  |  |  |  169|    129|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    129|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    129|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    129|		return _ret; \
  |  |  |  |  172|    129|	} \
  |  |  |  |  173|  3.74k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.61k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2004|       |
 2005|  3.61k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2006|       |
 2007|       |	/* Gnuk returns an error instead of empty data if there is no certificate or private DO.
 2008|       |	 * So, for this case, we ignore error and consider success */
 2009|  3.61k|	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK &&
  ------------------
  |  Branch (2009:6): [True: 0, False: 3.61k]
  ------------------
 2010|      0|	    (tag == DO_CERT  ||
  ------------------
  |  |  138|      0|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (2010:7): [True: 0, False: 0]
  ------------------
 2011|      0|	     tag == DO_PRIV1 ||
  ------------------
  |  |  149|      0|#define DO_PRIV1                 0x0101
  ------------------
  |  Branch (2011:7): [True: 0, False: 0]
  ------------------
 2012|      0|	     tag == DO_PRIV2 ||
  ------------------
  |  |  150|      0|#define DO_PRIV2                 0x0102
  ------------------
  |  Branch (2012:7): [True: 0, False: 0]
  ------------------
 2013|      0|	     tag == DO_PRIV3 ||
  ------------------
  |  |  151|      0|#define DO_PRIV3                 0x0103
  ------------------
  |  Branch (2013:7): [True: 0, False: 0]
  ------------------
 2014|      0|	     tag == DO_PRIV4)) {
  ------------------
  |  |  152|      0|#define DO_PRIV4                 0x0104
  ------------------
  |  Branch (2014:7): [True: 0, False: 0]
  ------------------
 2015|      0|		if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (2015:7): [True: 0, False: 0]
  ------------------
 2016|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2017|      0|			apdu.resplen = 0;
 2018|      0|		}
 2019|      0|	}
 2020|  3.61k|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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: 1.91k, False: 1.70k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.91k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.91k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.91k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.91k|		return _ret; \
  |  |  |  |  172|  1.91k|	} \
  |  |  |  |  173|  3.61k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.70k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2021|       |
 2022|  1.70k|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  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: 522, False: 1.18k]
  |  |  |  |  ------------------
  |  |  |  |  156|    522|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 522]
  |  |  |  |  ------------------
  |  |  |  |  157|    522|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.18k|	} else { \
  |  |  |  |  159|  1.18k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.18k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.18k|	} \
  |  |  |  |  162|  1.70k|	return _ret; \
  |  |  |  |  163|  1.70k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2023|  1.70k|}
card-openpgp.c:pgp_put_data:
 2140|    236|{
 2141|    236|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    236|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2142|    236|	pgp_blob_t *affected_blob = NULL;
 2143|    236|	pgp_do_info_t *dinfo = NULL;
 2144|    236|	int r;
 2145|       |
 2146|    236|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    236|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    236|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    236|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    236|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 236]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2147|       |
 2148|       |	/* Check if there is a blob for the given tag */
 2149|    236|	affected_blob = pgp_find_blob(card, tag);
 2150|       |
 2151|       |	/* Non-readable DOs have no represented blob, we have to check from pgp_get_info_by_tag */
 2152|    236|	if (affected_blob == NULL)
  ------------------
  |  Branch (2152:6): [True: 89, False: 147]
  ------------------
 2153|     89|		dinfo = pgp_get_info_by_tag(card, tag);
 2154|    147|	else
 2155|    147|		dinfo = affected_blob->info;
 2156|       |
 2157|       |	/* Make sure the DO exists and is writeable */
 2158|    236|	if (dinfo == NULL) {
  ------------------
  |  Branch (2158:6): [True: 0, False: 236]
  ------------------
 2159|      0|		sc_log(card->ctx, "The DO %04X does not exist.", 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__
  |  |  ------------------
  ------------------
 2160|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2161|      0|	}
 2162|    236|	else if ((dinfo->access & WRITE_MASK) == WRITE_NEVER) {
  ------------------
  |  Branch (2162:11): [True: 0, False: 236]
  ------------------
 2163|      0|		sc_log(card->ctx, "DO %04X is not writable.", 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__
  |  |  ------------------
  ------------------
 2164|      0|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_ALLOWED);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2165|      0|	}
 2166|       |
 2167|       |	/* Check data size.
 2168|       |	 * We won't check other DOs than 7F21 (certificate), because their capacity
 2169|       |	 * is hard-coded and may change in various version of the card.
 2170|       |	 * If we check here, the driver may be stuck to a limit version number of card.
 2171|       |	 * 7F21 size is soft-coded, so we can check it. */
 2172|    236|	if (tag == DO_CERT && buf_len > priv->max_cert_size) {
  ------------------
  |  |  138|    472|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (2172:6): [True: 0, False: 236]
  |  Branch (2172:24): [True: 0, False: 0]
  ------------------
 2173|      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__
  |  |  ------------------
  ------------------
 2174|      0|		       "Data size %"SC_FORMAT_LEN_SIZE_T"u exceeds DO size limit %"SC_FORMAT_LEN_SIZE_T"u.",
 2175|      0|		       buf_len, priv->max_cert_size);
 2176|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2177|      0|	}
 2178|       |
 2179|    236|	if (tag == DO_CERT && card->type == SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  |  138|    472|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (2179:6): [True: 0, False: 236]
  |  Branch (2179:24): [True: 0, False: 0]
  ------------------
 2180|       |		/* Gnuk need a special way to write certificate. */
 2181|      0|		r = gnuk_write_certificate(card, buf, buf_len);
 2182|      0|	}
 2183|    236|	else {
 2184|    236|		r = pgp_put_data_plain(card, tag, buf, buf_len);
 2185|    236|	}
 2186|       |
 2187|       |	/* instruct more in case of error */
 2188|    236|	if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
  ------------------
  |  |   61|    236|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (2188:6): [True: 0, False: 236]
  ------------------
 2189|      0|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Please verify PIN first.");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2190|      0|	}
 2191|    236|	LOG_TEST_RET(card->ctx, r, "PUT DATA returned error");
  ------------------
  |  |  174|    236|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    236|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    236|	int _ret = (r); \
  |  |  |  |  168|    236|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 124, False: 112]
  |  |  |  |  ------------------
  |  |  |  |  169|    124|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    124|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    124|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    124|		return _ret; \
  |  |  |  |  172|    124|	} \
  |  |  |  |  173|    236|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2192|       |
 2193|    112|	if (affected_blob) {
  ------------------
  |  Branch (2193:6): [True: 90, False: 22]
  ------------------
 2194|       |		/* update the corresponding file */
 2195|     90|		sc_log(card->ctx, "Updating the corresponding blob data");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2196|     90|		r = pgp_set_blob(affected_blob, buf, buf_len);
 2197|     90|		if (r < 0)
  ------------------
  |  Branch (2197:7): [True: 0, False: 90]
  ------------------
 2198|      0|			sc_log(card->ctx, "Failed to update blob %04X. Error %d.", affected_blob->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__
  |  |  ------------------
  ------------------
 2199|       |		/* pgp_set_blob()'s failures do not impact pgp_put_data()'s result */
 2200|     90|	}
 2201|       |
 2202|    112|	LOG_FUNC_RETURN(card->ctx, (int)buf_len);
  ------------------
  |  |  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: 0, False: 112]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    112|	} else { \
  |  |  |  |  159|    112|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    112|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    112|	} \
  |  |  |  |  162|    112|	return _ret; \
  |  |  |  |  163|    112|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2203|    112|}
card-openpgp.c:pgp_find_blob:
 1549|    251|{
 1550|    251|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    251|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1551|    251|	pgp_blob_t *blob = NULL;
 1552|    251|	int r;
 1553|       |
 1554|       |	/* check if current selected blob is which we want to test */
 1555|    251|	if (priv->current->id == tag) {
  ------------------
  |  Branch (1555:6): [True: 13, False: 238]
  ------------------
 1556|     13|		return priv->current;
 1557|     13|	}
 1558|       |	/* look for the blob representing the DO */
 1559|    238|	r = pgp_seek_blob(card, priv->mf, tag, &blob);
 1560|    238|	if (r < 0) {
  ------------------
  |  Branch (1560:6): [True: 98, False: 140]
  ------------------
 1561|     98|		sc_log(card->ctx, "Failed to seek the blob representing the tag %04X. Error %d.", tag, r);
  ------------------
  |  |   71|     98|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1562|     98|		return NULL;
 1563|     98|	}
 1564|    140|	return blob;
 1565|    238|}
card-openpgp.c:pgp_seek_blob:
 1521|  14.5k|{
 1522|  14.5k|	pgp_blob_t	*child;
 1523|  14.5k|	int			r;
 1524|       |
 1525|  14.5k|	if ((r = pgp_get_blob(card, root, id, ret)) == 0)
  ------------------
  |  Branch (1525:6): [True: 272, False: 14.2k]
  ------------------
 1526|       |		/* the sought blob is right under root */
 1527|    272|		return r;
 1528|       |
 1529|       |	/* not found, seek deeper */
 1530|  31.2k|	for (child = root->files; child; child = child->next) {
  ------------------
  |  Branch (1530:28): [True: 17.6k, False: 13.6k]
  ------------------
 1531|       |		/* The DO of SIMPLE type or the DO holding certificate
 1532|       |		 * does not contain children */
 1533|  17.6k|		if ((child->info && child->info->type == SIMPLE) || child->id == DO_CERT)
  ------------------
  |  |  138|  14.1k|#define DO_CERT                  0x7f21
  ------------------
  |  Branch (1533:8): [True: 6.81k, False: 10.8k]
  |  Branch (1533:23): [True: 3.47k, False: 3.33k]
  |  Branch (1533:55): [True: 0, False: 14.1k]
  ------------------
 1534|  3.47k|			continue;
 1535|  14.1k|		r = pgp_seek_blob(card, child, id, ret);
 1536|  14.1k|		if (r == 0)
  ------------------
  |  Branch (1536:7): [True: 583, False: 13.5k]
  ------------------
 1537|    583|			return r;
 1538|  14.1k|	}
 1539|       |
 1540|  13.6k|	return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  13.6k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 1541|  14.2k|}
card-openpgp.c:pgp_get_info_by_tag:
 1573|     89|{
 1574|     89|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|     89|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 1575|     89|	pgp_do_info_t *info;
 1576|       |
 1577|  3.73k|	for (info = priv->pgp_objects; (info != NULL) && (info->id > 0); info++)
  ------------------
  |  Branch (1577:33): [True: 3.73k, False: 0]
  |  Branch (1577:51): [True: 3.73k, False: 0]
  ------------------
 1578|  3.73k|		if (tag == info->id)
  ------------------
  |  Branch (1578:7): [True: 89, False: 3.65k]
  ------------------
 1579|     89|			return info;
 1580|       |
 1581|      0|	return NULL;
 1582|     89|}
card-openpgp.c:pgp_put_data_plain:
 2088|    236|{
 2089|    236|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    236|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2090|    236|	sc_apdu_t apdu;
 2091|    236|	u8 ins = 0xDA;
 2092|    236|	u8 p1 = tag >> 8;
 2093|    236|	u8 p2 = tag & 0xFF;
 2094|    236|	u8 apdu_case = (card->type == SC_CARD_TYPE_OPENPGP_GNUK)
  ------------------
  |  Branch (2094:17): [True: 0, False: 236]
  ------------------
 2095|    236|			? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_3;
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
              			? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_3;
  ------------------
  |  |  302|    472|#define SC_APDU_CASE_3			0x23
  ------------------
 2096|    236|	int r;
 2097|       |
 2098|    236|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    236|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    236|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    236|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    236|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 236]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2099|       |
 2100|       |	/* Extended Header list (DO 004D) needs a variant of PUT DATA command */
 2101|    236|	if (tag == 0x004D) {
  ------------------
  |  Branch (2101:6): [True: 0, False: 236]
  ------------------
 2102|      0|		ins = 0xDB;
 2103|      0|		p1 = 0x3F;
 2104|      0|		p2 = 0xFF;
 2105|      0|	}
 2106|       |
 2107|       |	/* build APDU */
 2108|    236|	if (buf != NULL && buf_len > 0) {
  ------------------
  |  Branch (2108:6): [True: 236, False: 0]
  |  Branch (2108:21): [True: 236, False: 0]
  ------------------
 2109|    236|		sc_format_apdu(card, &apdu, apdu_case, ins, p1, p2);
 2110|       |
 2111|       |		/* if card/reader does not support extended APDUs, but chaining, then set it */
 2112|    236|		if (((card->caps & SC_CARD_CAP_APDU_EXT) == 0) && (priv->ext_caps & EXT_CAP_CHAINING))
  ------------------
  |  |  554|    236|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (2112:7): [True: 213, False: 23]
  |  Branch (2112:53): [True: 8, False: 205]
  ------------------
 2113|      8|			apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|      8|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 2114|       |
 2115|    236|		apdu.data = (u8 *)buf;
 2116|    236|		apdu.datalen = buf_len;
 2117|    236|		apdu.lc = buf_len;
 2118|    236|	}
 2119|      0|	else {
 2120|       |		/* This case is to empty DO */
 2121|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, ins, p1, p2);
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 2122|      0|	}
 2123|       |
 2124|       |	/* send APDU to card */
 2125|    236|	r = sc_transmit_apdu(card, &apdu);
 2126|    236|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    236|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    236|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    236|	int _ret = (r); \
  |  |  |  |  168|    236|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 236]
  |  |  |  |  ------------------
  |  |  |  |  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|    236|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 236]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2127|       |	/* check response */
 2128|    236|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 2129|    236|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|    236|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    236|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    236|	int _ret = (r); \
  |  |  |  |  168|    236|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 124, False: 112]
  |  |  |  |  ------------------
  |  |  |  |  169|    124|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    124|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    124|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    124|		return _ret; \
  |  |  |  |  172|    124|	} \
  |  |  |  |  173|    236|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 112]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2130|       |
 2131|    112|	LOG_FUNC_RETURN(card->ctx, (int)buf_len);
  ------------------
  |  |  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: 0, False: 112]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    112|	} else { \
  |  |  |  |  159|    112|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    112|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    112|	} \
  |  |  |  |  162|    112|	return _ret; \
  |  |  |  |  163|    112|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2132|    112|}
card-openpgp.c:pgp_card_ctl:
 4011|    652|{
 4012|    652|	int r;
 4013|       |
 4014|    652|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    652|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    652|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    652|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    652|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 652]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4015|       |
 4016|    652|	switch(cmd) {
  ------------------
  |  Branch (4016:9): [True: 323, False: 329]
  ------------------
 4017|    172|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (4017:2): [True: 172, False: 480]
  ------------------
 4018|    172|		memmove((sc_serial_number_t *) ptr, &card->serialnr, sizeof(card->serialnr));
 4019|    172|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    172|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    172|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    172|	int _ret = r; \
  |  |  |  |  155|    172|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 172, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    172|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 172]
  |  |  |  |  ------------------
  |  |  |  |  157|    172|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    172|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    172|	return _ret; \
  |  |  |  |  163|    172|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4020|      0|		break;
 4021|      0|	case SC_CARDCTL_OPENPGP_SELECT_DATA:
  ------------------
  |  Branch (4021:2): [True: 0, False: 652]
  ------------------
 4022|      0|		r = pgp_select_data(card, *((u8 *) ptr));
 4023|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4024|      0|		break;
 4025|      0|#ifdef ENABLE_OPENSSL
 4026|    151|	case SC_CARDCTL_OPENPGP_GENERATE_KEY:
  ------------------
  |  Branch (4026:2): [True: 151, False: 501]
  ------------------
 4027|    151|		r = pgp_gen_key(card, (sc_cardctl_openpgp_key_gen_store_info_t *)ptr);
 4028|    151|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|    147|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 147, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4029|      0|		break;
 4030|      0|	case SC_CARDCTL_OPENPGP_STORE_KEY:
  ------------------
  |  Branch (4030:2): [True: 0, False: 652]
  ------------------
 4031|      0|		r = pgp_store_key(card, (sc_cardctl_openpgp_key_gen_store_info_t *)ptr);
 4032|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4033|      0|		break;
 4034|      0|#endif /* ENABLE_OPENSSL */
 4035|      0|	case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (4035:2): [True: 0, False: 652]
  ------------------
 4036|      0|		r = pgp_erase_card(card);
 4037|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4038|      0|		break;
 4039|    652|	}
 4040|       |
 4041|    329|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    329|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    329|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    329|	int _ret = r; \
  |  |  |  |  155|    329|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 329, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    329|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    329|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 329, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    329|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    329|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    329|	return _ret; \
  |  |  |  |  163|    329|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4042|    329|}
card-openpgp.c:pgp_gen_key:
 3428|    151|{
 3429|    151|	sc_apdu_t apdu;
 3430|       |	/* temporary variables to hold APDU params */
 3431|    151|	u8 apdu_case;
 3432|    151|	u8 apdu_data[2] = { 0x00, 0x00 };
 3433|    151|	size_t apdu_le;
 3434|    151|	size_t resplen = 0;
 3435|    151|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    151|#define SC_SUCCESS				0
  ------------------
 3436|    151|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    151|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 3437|       |
 3438|    151|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    151|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    151|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    151|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    151|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 151]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3439|       |
 3440|       |	/* protect incompatible cards against non-RSA */
 3441|    151|	if (key_info->algorithm != SC_OPENPGP_KEYALGO_RSA &&
  ------------------
  |  |  869|    302|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3441:6): [True: 14, False: 137]
  ------------------
 3442|     14|			priv->bcd_version < OPENPGP_CARD_3_0 &&
  ------------------
  |  Branch (3442:4): [True: 1, False: 13]
  ------------------
 3443|      1|			card->type != SC_CARD_TYPE_OPENPGP_GNUK)
  ------------------
  |  Branch (3443:4): [True: 1, False: 0]
  ------------------
 3444|    151|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3445|       |
 3446|       |	/* set Control Reference Template for key */
 3447|    150|	if (key_info->key_id == SC_OPENPGP_KEY_SIGN)
  ------------------
  |  |  865|    150|#define SC_OPENPGP_KEY_SIGN		1
  ------------------
  |  Branch (3447:6): [True: 0, False: 150]
  ------------------
 3448|      0|		ushort2bebytes(apdu_data, DO_SIGN);
  ------------------
  |  |  141|      0|#define DO_SIGN                  0xb600
  ------------------
 3449|    150|	else if (key_info->key_id == SC_OPENPGP_KEY_ENCR)
  ------------------
  |  |  866|    150|#define SC_OPENPGP_KEY_ENCR		2
  ------------------
  |  Branch (3449:11): [True: 0, False: 150]
  ------------------
 3450|      0|		ushort2bebytes(apdu_data, DO_ENCR);
  ------------------
  |  |  142|      0|#define DO_ENCR                  0xb800
  ------------------
 3451|    150|	else if (key_info->key_id == SC_OPENPGP_KEY_AUTH)
  ------------------
  |  |  867|    150|#define SC_OPENPGP_KEY_AUTH		3
  ------------------
  |  Branch (3451:11): [True: 150, False: 0]
  ------------------
 3452|    150|		ushort2bebytes(apdu_data, DO_AUTH);
  ------------------
  |  |  143|    150|#define DO_AUTH                  0xa400
  ------------------
 3453|      0|	else {
 3454|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3455|      0|				"Invalid key ID; must be 1, 2, or 3");
 3456|      0|	}
 3457|       |
 3458|       |	/* set attributes for new-generated key */
 3459|    150|	r = pgp_update_new_algo_attr(card, key_info);
 3460|    150|	LOG_TEST_RET(card->ctx, r, "Cannot set attributes for new-generated key");
  ------------------
  |  |  174|    150|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    150|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    150|	int _ret = (r); \
  |  |  |  |  168|    150|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 76, False: 74]
  |  |  |  |  ------------------
  |  |  |  |  169|     76|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     76|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     76|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     76|		return _ret; \
  |  |  |  |  172|     76|	} \
  |  |  |  |  173|    150|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 74]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3461|       |
 3462|       |	/* Test whether we will need extended APDU. 1900 is an
 3463|       |	 * arbitrary modulus length which for sure fits into a short APDU.
 3464|       |	 * This idea is borrowed from GnuPG code.  */
 3465|     74|	if (card->caps & SC_CARD_CAP_APDU_EXT
  ------------------
  |  |  554|    148|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (3465:6): [True: 4, False: 70]
  ------------------
 3466|      4|		&& key_info->u.rsa.modulus_len > 1900
  ------------------
  |  Branch (3466:6): [True: 0, False: 4]
  ------------------
 3467|      0|		&& card->type != SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  Branch (3467:6): [True: 0, False: 0]
  ------------------
 3468|       |		/* We won't store to apdu variable yet, because it will be reset in
 3469|       |		 * sc_format_apdu() */
 3470|      0|		apdu_le = card->max_recv_size;
 3471|      0|		apdu_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
  |  |  ------------------
  ------------------
 3472|      0|	}
 3473|     74|	else {
 3474|     74|		apdu_case = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|     74|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
 3475|     74|		apdu_le = 256;
 3476|     74|		resplen = MAXLEN_RESP_PUBKEY;
  ------------------
  |  |  164|     74|#define MAXLEN_RESP_PUBKEY       527
  ------------------
 3477|     74|	}
 3478|     74|	if (card->type == SC_CARD_TYPE_OPENPGP_GNUK) {
  ------------------
  |  Branch (3478:6): [True: 0, False: 74]
  ------------------
 3479|      0|		resplen = MAXLEN_RESP_PUBKEY_GNUK;
  ------------------
  |  |  166|      0|#define MAXLEN_RESP_PUBKEY_GNUK  271
  ------------------
 3480|      0|	}
 3481|       |
 3482|       |	/* prepare APDU */
 3483|     74|	sc_format_apdu(card, &apdu, apdu_case, 0x47, 0x80, 0);
 3484|     74|	apdu.data = apdu_data;
 3485|     74|	apdu.datalen = sizeof(apdu_data);
 3486|     74|	apdu.lc = sizeof(apdu_data);
 3487|     74|	apdu.le = apdu_le;
 3488|       |
 3489|       |	/* buffer to receive response */
 3490|     74|	apdu.resplen = (resplen > 0) ? resplen : apdu_le;
  ------------------
  |  Branch (3490:17): [True: 74, False: 0]
  ------------------
 3491|     74|	apdu.resp = calloc(1, apdu.resplen);
 3492|     74|	if (apdu.resp == NULL) {
  ------------------
  |  Branch (3492:6): [True: 0, False: 74]
  ------------------
 3493|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3494|      0|	}
 3495|       |
 3496|       |	/* send */
 3497|     74|	sc_log(card->ctx, "Waiting for the card to generate key...");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3498|     74|	r = sc_transmit_apdu(card, &apdu);
 3499|     74|	sc_log(card->ctx, "Card has done key generation.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3500|     74|	LOG_TEST_GOTO_ERR(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  184|     74|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     74|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     74|	int _ret = (r); \
  |  |  |  |  178|     74|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 73]
  |  |  |  |  ------------------
  |  |  |  |  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|     74|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 73]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3501|       |
 3502|       |	/* check response */
 3503|     73|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 3504|       |	/* instruct more in case of error */
 3505|     73|	if (r == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED) {
  ------------------
  |  |   61|     73|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (3505:6): [True: 0, False: 73]
  ------------------
 3506|      0|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE, "Please verify PIN first.");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3507|      0|		goto err;
 3508|      0|	}
 3509|     73|	LOG_TEST_GOTO_ERR(card->ctx, r, "Card returned error");
  ------------------
  |  |  184|     73|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     73|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     73|	int _ret = (r); \
  |  |  |  |  178|     73|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 73]
  |  |  |  |  ------------------
  |  |  |  |  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|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 73]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3510|       |
 3511|       |	/* parse response data and set output */
 3512|     73|	r = pgp_parse_and_set_pubkey_output(card, apdu.resp, apdu.resplen, key_info);
 3513|     73|	LOG_TEST_GOTO_ERR(card->ctx, r, "Failed to parse pubkey output");
  ------------------
  |  |  184|     73|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     73|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     73|	int _ret = (r); \
  |  |  |  |  178|     73|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 69, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     69|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     69|		goto err; \
  |  |  |  |  182|     69|	} \
  |  |  |  |  183|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3514|      4|	r = pgp_update_card_algorithms(card, key_info);
 3515|       |
 3516|     74|err:
 3517|     74|	free(apdu.resp);
 3518|     74|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|     70|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 70, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3519|     74|}
card-openpgp.c:pgp_update_new_algo_attr:
 2851|    150|{
 2852|    150|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|    150|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 2853|    150|	pgp_blob_t *algo_blob = NULL;
 2854|    150|	const unsigned int tag = 0x00C0 | key_info->key_id;
 2855|    150|	int r = SC_SUCCESS;
  ------------------
  |  |   28|    150|#define SC_SUCCESS				0
  ------------------
 2856|    150|	unsigned int i;
 2857|       |
 2858|    150|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    150|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    150|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    150|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    150|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 150]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2859|       |
 2860|    150|	r = pgp_seek_blob(card, priv->mf, tag, &algo_blob);
 2861|    150|	LOG_TEST_RET(card->ctx, r, "Cannot get old algorithm attributes");
  ------------------
  |  |  174|    150|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    150|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    150|	int _ret = (r); \
  |  |  |  |  168|    150|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 18, False: 132]
  |  |  |  |  ------------------
  |  |  |  |  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|    150|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 132]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2862|       |
 2863|    132|	if (priv->ext_caps & EXT_CAP_ALG_ATTR_CHANGEABLE) {
  ------------------
  |  Branch (2863:6): [True: 121, False: 11]
  ------------------
 2864|       |		/* ECDSA and ECDH */
 2865|    121|		if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH
  ------------------
  |  |  870|    242|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (2865:7): [True: 0, False: 121]
  ------------------
 2866|    121|				|| key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA
  ------------------
  |  |  871|    242|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (2866:8): [True: 3, False: 118]
  ------------------
 2867|    118|				|| key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA){
  ------------------
  |  |  872|    118|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (2867:8): [True: 0, False: 118]
  ------------------
 2868|       |			/* Note OpenPGP or current cards do not support 448 size keys yet */
 2869|      3|			unsigned char *aoid = NULL; /* ASN1 */
 2870|      3|			size_t aoid_len;
 2871|      3|			struct sc_object_id *scoid = NULL;
 2872|       |
 2873|      3|			scoid = &key_info->u.ec.oid;
 2874|       |			/*
 2875|       |			 * Current OpenPGP cards use pre RFC8410 OIDs for ECDH and EdDSA
 2876|       |			 * so convert to older versions of the OIDs.
 2877|       |			 */
 2878|      9|			for (i = 0; ec_curves_alt[i].size > 0; i++) {
  ------------------
  |  Branch (2878:16): [True: 6, False: 3]
  ------------------
 2879|      6|				if (sc_compare_oid(scoid, &ec_curves_alt[i].oid_alt)) {
  ------------------
  |  Branch (2879:9): [True: 0, False: 6]
  ------------------
 2880|      0|					scoid = &ec_curves_alt[i].oid;
 2881|      0|					break;
 2882|      0|				}
 2883|      6|			}
 2884|       |
 2885|      3|			r = sc_encode_oid(card->ctx, scoid, &aoid, &aoid_len);
 2886|      3|			LOG_TEST_RET(card->ctx, r, "invalid ec oid");
  ------------------
  |  |  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: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2887|      3|			if (aoid == NULL || aoid_len < 3 || aoid[1] > 127) {
  ------------------
  |  Branch (2887:8): [True: 0, False: 3]
  |  Branch (2887:24): [True: 0, False: 3]
  |  Branch (2887:40): [True: 0, False: 3]
  ------------------
 2888|      0|				free(aoid);
 2889|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2890|      0|			}
 2891|       |
 2892|      3|			key_info->data_len = aoid_len + 1 - 2; /* +1 for algorithm -2 drop 06 len */
 2893|      3|			key_info->data = malloc(key_info->data_len);
 2894|      3|			if (!key_info->data) {
  ------------------
  |  Branch (2894:8): [True: 0, False: 3]
  ------------------
 2895|      0|				free(aoid);
 2896|      0|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2897|      0|			}
 2898|       |
 2899|      3|			key_info->data[0] = key_info->algorithm;
 2900|     27|			for (i = 0; i < aoid_len - 2; i++)
  ------------------
  |  Branch (2900:16): [True: 24, False: 3]
  ------------------
 2901|     24|				key_info->data[i + 1] = aoid[i + 2];
 2902|       |
 2903|      3|			free(aoid);
 2904|      3|		}
 2905|       |
 2906|       |		/* RSA */
 2907|    118|		else if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA){
  ------------------
  |  |  869|    118|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (2907:12): [True: 118, False: 0]
  ------------------
 2908|       |
 2909|       |			/* We can not rely on previous key attributes anymore, as it might be ECC */
 2910|    118|			if (key_info->u.rsa.exponent_len == 0 || key_info->u.rsa.modulus_len == 0)
  ------------------
  |  Branch (2910:8): [True: 0, False: 118]
  |  Branch (2910:45): [True: 0, False: 118]
  ------------------
 2911|    118|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2912|       |
 2913|    118|			key_info->data_len = 6;
 2914|    118|			key_info->data = malloc(key_info->data_len);
 2915|    118|			if (!key_info->data)
  ------------------
  |  Branch (2915:8): [True: 0, False: 118]
  ------------------
 2916|    118|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2917|       |
 2918|    118|			key_info->data[0] = key_info->algorithm;
 2919|    118|			ushort2bebytes(key_info->data + 1, key_info->u.rsa.modulus_len);
 2920|       |			/* OpenPGP Card only accepts 32bit as exponent length field,
 2921|       |			 * although you can import keys with smaller exponent;
 2922|       |			 * thus we don't change rsa.exponent_len, but ignore it here */
 2923|    118|			ushort2bebytes(key_info->data + 3, SC_OPENPGP_MAX_EXP_BITS);
  ------------------
  |  |  882|    118|#define SC_OPENPGP_MAX_EXP_BITS		0x20 /* maximum exponent length supported in bits */
  ------------------
 2924|       |			/* Import-Format of private key (e,p,q) */
 2925|    118|			key_info->data[5] = SC_OPENPGP_KEYFORMAT_RSA_STD;
  ------------------
  |  |  874|    118|#define SC_OPENPGP_KEYFORMAT_RSA_STD	0    /* See 4.3.3.6 Algorithm Attributes */
  ------------------
 2926|    118|		}
 2927|      0|		else {
 2928|      0|			sc_log(card->ctx, "Unknown algorithm 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__
  |  |  ------------------
  ------------------
 2929|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2930|      0|		}
 2931|       |
 2932|    121|		r = pgp_put_data(card, tag, key_info->data, key_info->data_len);
 2933|       |		/* Note: pgp_put_data calls pgp_set_blob */
 2934|    121|		LOG_TEST_RET(card->ctx, r, "Cannot set new algorithm attributes");
  ------------------
  |  |  174|    121|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    121|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    121|	int _ret = (r); \
  |  |  |  |  168|    121|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 53, False: 68]
  |  |  |  |  ------------------
  |  |  |  |  169|     53|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     53|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     53|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     53|		return _ret; \
  |  |  |  |  172|     53|	} \
  |  |  |  |  173|    121|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 68]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2935|    121|	} else {
 2936|     11|		sc_cardctl_openpgp_key_gen_store_info_t old_key_info;
 2937|       |
 2938|     11|		if (pgp_parse_algo_attr_blob(card, algo_blob, &old_key_info) != SC_SUCCESS
  ------------------
  |  |   28|     22|#define SC_SUCCESS				0
  ------------------
  |  Branch (2938:7): [True: 1, False: 10]
  ------------------
 2939|     10|				|| old_key_info.algorithm != key_info->algorithm)
  ------------------
  |  Branch (2939:8): [True: 4, False: 6]
  ------------------
 2940|     11|			LOG_TEST_RET(card->ctx, SC_ERROR_NO_CARD_SUPPORT,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2941|     11|					"Requested algorithm not supported");
 2942|       |		/* FIXME check whether the static parameters match the requested ones. */
 2943|     11|	}
 2944|       |
 2945|     74|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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: 6, False: 68]
  |  |  |  |  ------------------
  |  |  |  |  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|     68|	} else { \
  |  |  |  |  159|     68|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     68|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     68|	} \
  |  |  |  |  162|     74|	return _ret; \
  |  |  |  |  163|     74|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2946|     74|}
card-openpgp.c:pgp_parse_and_set_pubkey_output:
 3257|     73|{
 3258|     73|	time_t ctime = 0;
 3259|     73|	u8 *in = data;
 3260|     73|	int r;
 3261|     73|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3262|       |
 3263|       |	/* store creation time */
 3264|     73|	r = pgp_store_creationtime(card, key_info->key_id, &ctime);
 3265|     73|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     73|#define SC_SUCCESS				0
  ------------------
  |  Branch (3265:6): [True: 73, False: 0]
  ------------------
 3266|       |		/* TODO for now with GNUK at least, log but do not return error */
 3267|     73|		sc_log(card->ctx, "Cannot store creation time");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3268|     73|	}
 3269|       |
 3270|       |	/* parse response. Ref: pgp_enumerate_blob() */
 3271|    791|	while (data_len > (size_t) (in - data)) {
  ------------------
  |  Branch (3271:9): [True: 757, False: 34]
  ------------------
 3272|    757|		unsigned int cla, tag, tmptag;
 3273|    757|		size_t		len;
 3274|    757|		u8	*part = in;
 3275|       |
 3276|       |		/* parse TLV structure */
 3277|    757|		r = sc_asn1_read_tag((const u8**)&part, data_len - (in - data), &cla, &tag, &len);
 3278|    757|		if (part == NULL)
  ------------------
  |  Branch (3278:7): [True: 28, False: 729]
  ------------------
 3279|     28|			r = SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|     28|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
 3280|    757|		LOG_TEST_RET(card->ctx, r, "Unexpected end of contents");
  ------------------
  |  |  174|    757|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    757|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    757|	int _ret = (r); \
  |  |  |  |  168|    757|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 36, False: 721]
  |  |  |  |  ------------------
  |  |  |  |  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|    757|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 721]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3281|       |		/* undo ASN1's split of tag & class */
 3282|    816|		for (tmptag = tag; tmptag > 0x0FF; tmptag >>= 8) {
  ------------------
  |  Branch (3282:22): [True: 95, False: 721]
  ------------------
 3283|     95|			cla <<= 8;
 3284|     95|		}
 3285|    721|		tag |= cla;
 3286|       |
 3287|       |		/* RSA modulus */
 3288|    721|		if (tag == 0x0081) {
  ------------------
  |  Branch (3288:7): [True: 63, False: 658]
  ------------------
 3289|     63|			if (key_info->algorithm != SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  869|     63|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3289:8): [True: 1, False: 62]
  ------------------
 3290|      1|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3291|      1|			}
 3292|     62|			if ((BYTES4BITS(key_info->u.rsa.modulus_len) < len)  /* modulus_len is in bits */
  ------------------
  |  |  146|     62|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  |  Branch (3292:8): [True: 15, False: 47]
  ------------------
 3293|     47|				|| key_info->u.rsa.modulus == NULL) {
  ------------------
  |  Branch (3293:8): [True: 0, False: 47]
  ------------------
 3294|       |
 3295|     15|				free(key_info->u.rsa.modulus);
 3296|     15|				key_info->u.rsa.modulus = malloc(len);
 3297|     15|				if (key_info->u.rsa.modulus == NULL)
  ------------------
  |  Branch (3297:9): [True: 0, False: 15]
  ------------------
 3298|     15|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3299|     15|			}
 3300|       |
 3301|       |			/* set values */
 3302|     62|			memcpy(key_info->u.rsa.modulus, part, len);
 3303|     62|			key_info->u.rsa.modulus_len = len * 8; /* store length in bits */
 3304|     62|		}
 3305|       |		/* RSA public exponent */
 3306|    658|		else if (tag == 0x0082) {
  ------------------
  |  Branch (3306:12): [True: 93, False: 565]
  ------------------
 3307|     93|			if (key_info->algorithm != SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  869|     93|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3307:8): [True: 1, False: 92]
  ------------------
 3308|      1|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3309|      1|			}
 3310|     92|			if ((BYTES4BITS(key_info->u.rsa.exponent_len) < len)  /* exponent_len is in bits */
  ------------------
  |  |  146|     92|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  |  Branch (3310:8): [True: 10, False: 82]
  ------------------
 3311|     82|				|| key_info->u.rsa.exponent == NULL) {
  ------------------
  |  Branch (3311:8): [True: 0, False: 82]
  ------------------
 3312|       |
 3313|     10|				free(key_info->u.rsa.exponent);
 3314|     10|				key_info->u.rsa.exponent = malloc(len);
 3315|     10|				if (key_info->u.rsa.exponent == NULL)
  ------------------
  |  Branch (3315:9): [True: 0, False: 10]
  ------------------
 3316|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3317|     10|			}
 3318|       |
 3319|       |			/* set values */
 3320|     92|			memcpy(key_info->u.rsa.exponent, part, len);
 3321|     92|			key_info->u.rsa.exponent_len = len * 8; /* store length in bits */
 3322|     92|		}
 3323|       |		/* ECC or EDDSA public key */
 3324|    565|		else if (tag == 0x0086) {
  ------------------
  |  Branch (3324:12): [True: 1, False: 564]
  ------------------
 3325|       |			/* Note: SC_OPENPGP_KEYALGO_ECDH could be either EC or XEDDSA */
 3326|      1|			if (key_info->algorithm != SC_OPENPGP_KEYALGO_ECDSA &&
  ------------------
  |  |  871|      2|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3326:8): [True: 0, False: 1]
  ------------------
 3327|      0|					key_info->algorithm != SC_OPENPGP_KEYALGO_ECDH &&
  ------------------
  |  |  870|      1|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3327:6): [True: 0, False: 0]
  ------------------
 3328|      0|					key_info->algorithm != SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3328:6): [True: 0, False: 0]
  ------------------
 3329|      0|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3330|      0|			}
 3331|       |			/* set the output data */
 3332|       |			/* key_info->u.ec.ecpoint_len is already set based on
 3333|       |			 * key_info->key_type
 3334|       |			 * EC is in 04||x||y format i.e.
 3335|       |			 *    (field_length + 7)/8 * 2 + 1 in bytes
 3336|       |			 *    len is ecpoint length + format byte
 3337|       |			 *    see section 7.2.14 of 3.3.1 specs
 3338|       |			 * EDDSA and XEDDSA have no format byte and one number
 3339|       |			 *    (field_length + 7)/8 in bytes
 3340|       |			 */
 3341|       |			/* GNUK returns 04||x||y */
 3342|       |
 3343|      1|			if (len != key_info->u.ec.ecpointQ_len)
  ------------------
  |  Branch (3343:8): [True: 1, False: 0]
  ------------------
 3344|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3345|       |
 3346|      0|			switch (key_info->key_type) {
 3347|      0|			case SC_ALGORITHM_EC:
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (3347:4): [True: 0, False: 0]
  ------------------
 3348|      0|			case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (3348:4): [True: 0, False: 0]
  ------------------
 3349|      0|			case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (3349:4): [True: 0, False: 0]
  ------------------
 3350|      0|				key_info->u.ec.ecpointQ = malloc(len);
 3351|      0|				if (key_info->u.ec.ecpointQ == NULL)
  ------------------
  |  Branch (3351:9): [True: 0, False: 0]
  ------------------
 3352|      0|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3353|      0|				memcpy(key_info->u.ec.ecpointQ, part, len);
 3354|      0|				key_info->u.ec.ecpointQ_len = len;
 3355|      0|				break;
 3356|      0|			default:
  ------------------
  |  Branch (3356:4): [True: 0, False: 0]
  ------------------
 3357|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3358|      0|			}
 3359|      0|		}
 3360|       |
 3361|       |		/* go to next part to parse */
 3362|       |		/* This will be different from pgp_enumerate_blob() a bit */
 3363|    718|		in = part + ((tag != 0x7F49) ? len : 0);
  ------------------
  |  Branch (3363:16): [True: 714, False: 4]
  ------------------
 3364|    718|	}
 3365|       |
 3366|       |	/* calculate and store fingerprint */
 3367|     34|	sc_log(card->ctx, "Calculate and store fingerprint");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3368|     34|	r = pgp_calculate_and_store_fingerprint(card, ctime, key_info);
 3369|     34|	LOG_TEST_RET(card->ctx, r, "Cannot store fingerprint");
  ------------------
  |  |  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: 30, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3370|       |	/* TODO only try and update pubkey if present */
 3371|       |
 3372|       |	/* update pubkey blobs (B601, B801, A401) */
 3373|      4|	sc_log(card->ctx, "Update blobs holding pubkey info.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3374|      4|	r = pgp_update_pubkey_blob(card, key_info);
 3375|       |
 3376|      4|	LOG_FUNC_RETURN(card->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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3377|      4|}
card-openpgp.c:pgp_store_creationtime:
 2957|     73|{
 2958|     73|	int r;
 2959|     73|	time_t createtime = 0;
 2960|     73|	const size_t timestrlen = 64;
 2961|     73|	char timestring[65];
 2962|     73|	u8 buf[4];
 2963|     73|	struct tm tm;
 2964|       |
 2965|     73|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2966|       |
 2967|     73|	if (key_id < 1 || key_id > 3)
  ------------------
  |  Branch (2967:6): [True: 0, False: 73]
  |  Branch (2967:20): [True: 0, False: 73]
  ------------------
 2968|     73|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2969|     73|				"Invalid key ID; must be 1, 2, or 3");
 2970|       |
 2971|     73|	if (outtime != NULL && *outtime != 0)
  ------------------
  |  Branch (2971:6): [True: 73, False: 0]
  |  Branch (2971:25): [True: 0, False: 73]
  ------------------
 2972|      0|		createtime = *outtime;
 2973|     73|	else if (outtime != NULL)
  ------------------
  |  Branch (2973:11): [True: 73, False: 0]
  ------------------
 2974|       |		/* set output */
 2975|     73|		*outtime = createtime = time(NULL);
 2976|       |
 2977|       |#ifdef _WIN32
 2978|       |	if (0 != gmtime_s(&tm, &createtime))
 2979|       |		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INTERNAL);
 2980|       |#else
 2981|     73|	if (NULL == gmtime_r(&createtime, &tm))
  ------------------
  |  Branch (2981:6): [True: 0, False: 73]
  ------------------
 2982|     73|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2983|     73|#endif
 2984|     73|	strftime(timestring, timestrlen, "%c %Z", &tm);
 2985|     73|	sc_log(card->ctx, "Creation time %s.", timestring);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2986|       |	/* Code borrowed from GnuPG */
 2987|     73|	ulong2bebytes(buf, (unsigned long)createtime);
 2988|     73|	r = pgp_put_data(card, 0x00CD + key_id, buf, 4);
 2989|     73|	LOG_TEST_RET(card->ctx, r, "Cannot write to DO");
  ------------------
  |  |  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: 54, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  169|     54|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     54|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     54|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     54|		return _ret; \
  |  |  |  |  172|     54|	} \
  |  |  |  |  173|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2990|     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: 0, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     19|	} 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|     19|	return _ret; \
  |  |  |  |  163|     19|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2991|     19|}
card-openpgp.c:pgp_calculate_and_store_fingerprint:
 3001|     34|{
 3002|     34|	u8 fingerprint[SHA_DIGEST_LENGTH];
 3003|     34|	u8 *fp_buffer = NULL;  /* fingerprint buffer, not hashed */
 3004|     34|	size_t fp_buffer_len;
 3005|     34|	u8 *p; /* use this pointer to set fp_buffer content */
 3006|     34|	size_t pk_packet_len;
 3007|     34|	unsigned int tag = 0x00C6 + key_info->key_id;
 3008|     34|	pgp_blob_t *fpseq_blob = NULL;
 3009|     34|	u8 *newdata = NULL;
 3010|     34|	int r;
 3011|       |
 3012|     34|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     34|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     34|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     34|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     34|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3013|       |
 3014|       |	/* constructing public-key packet length */
 3015|       |	/* RSA */
 3016|     34|	if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  869|     34|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3016:6): [True: 31, False: 3]
  ------------------
 3017|       |
 3018|     31|		if (key_info->u.rsa.modulus == NULL
  ------------------
  |  Branch (3018:7): [True: 0, False: 31]
  ------------------
 3019|     31|			|| key_info->u.rsa.exponent == NULL
  ------------------
  |  Branch (3019:7): [True: 0, False: 31]
  ------------------
 3020|     31|			|| (key_info->u.rsa.modulus_len) == 0
  ------------------
  |  Branch (3020:7): [True: 1, False: 30]
  ------------------
 3021|     30|			|| (key_info->u.rsa.exponent_len) == 0) {
  ------------------
  |  Branch (3021:7): [True: 1, False: 29]
  ------------------
 3022|       |
 3023|      2|			sc_log(card->ctx, "Null data (modulus or exponent)");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3024|      2|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3025|      2|		}
 3026|       |
 3027|       |		/* https://tools.ietf.org/html/rfc4880  page 41, 72 */
 3028|     29|		pk_packet_len =   1   /* version number */
 3029|     29|				+ 4   /* creation time */
 3030|     29|				+ 1   /* algorithm */
 3031|     29|				+ 2   /* algorithm-specific fields: RSA modulus+exponent */
 3032|     29|				+ (BYTES4BITS(key_info->u.rsa.modulus_len))
  ------------------
  |  |  146|     29|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3033|     29|				+ 2
 3034|     29|				+ (BYTES4BITS(key_info->u.rsa.exponent_len));
  ------------------
  |  |  146|     29|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3035|       |
 3036|     29|	}
 3037|       |	/* ECC */
 3038|      3|	else if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH || /* also includes XEDDSA */
  ------------------
  |  |  870|      6|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3038:11): [True: 0, False: 3]
  ------------------
 3039|      3|			key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  871|      6|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3039:4): [True: 3, False: 0]
  ------------------
 3040|      3|			key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3040:4): [True: 0, False: 0]
  ------------------
 3041|      3|		if (key_info->u.ec.ecpointQ == NULL || (key_info->u.ec.ecpointQ_len) == 0) {
  ------------------
  |  Branch (3041:7): [True: 3, False: 0]
  |  Branch (3041:42): [True: 0, False: 0]
  ------------------
 3042|      3|			sc_log(card->ctx, "Error: ecpoint required!");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3043|      3|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3044|      3|		}
 3045|       |
 3046|       |		/* https://tools.ietf.org/html/rfc4880  page 41, 72
 3047|       |		 * and https://tools.ietf.org/html/rfc6637 section 9 (page 8 and 9) */
 3048|      0|		pk_packet_len = 1			       /* version number */
 3049|      0|				+ 4			       /* creation time */
 3050|      0|				+ 1			       /* algorithm */
 3051|      0|				+ 1			       /* oid len */
 3052|      0|				+ key_info->u.ec.oidv_len      /* oid */
 3053|      0|				+ key_info->u.ec.ecpointQ_len; /* ecpoint */
 3054|       |
 3055|       |		/* KDF parameters for ECDH */
 3056|      0|		if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH) {
  ------------------
  |  |  870|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3056:7): [True: 0, False: 0]
  ------------------
 3057|       |			/* https://tools.ietf.org/html/rfc6637#section-8 */
 3058|      0|			pk_packet_len +=   1	/* number of bytes */
 3059|      0|					 + 1	/* version number */
 3060|      0|					 + 1	/* KDF algo */
 3061|      0|					 + 1;	/* KEK algo */
 3062|      0|		}
 3063|      0|	} else
 3064|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3065|     29|	sc_log(card->ctx, "pk_packet_len is %"SC_FORMAT_LEN_SIZE_T"u", pk_packet_len);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3066|       |
 3067|     29|	fp_buffer_len = 3 + pk_packet_len;
 3068|     29|	p = fp_buffer = calloc(1, fp_buffer_len);
 3069|     29|	if (p == NULL)
  ------------------
  |  Branch (3069:6): [True: 0, False: 29]
  ------------------
 3070|     29|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3071|       |
 3072|       |	/* constructing public-key packet */
 3073|     29|	p[0] = 0x99;   /* http://tools.ietf.org/html/rfc4880  page 71 */
 3074|     29|	ushort2bebytes(++p, (unsigned short)pk_packet_len);
 3075|       |	/* start pk_packet */
 3076|     29|	p += 2;
 3077|     29|	*p = 4;        /* Version 4 key */
 3078|     29|	ulong2bebytes(++p, (unsigned long)ctime);    /* Creation time */
 3079|     29|	p += 4;
 3080|       |
 3081|       |	/* RSA */
 3082|     29|	if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  869|     29|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3082:6): [True: 29, False: 0]
  ------------------
 3083|     29|		unsigned short bytes_length = 0;
 3084|       |
 3085|     29|		*p = 1; /* Algorithm ID, RSA */
 3086|     29|		p += 1;
 3087|       |
 3088|       |		/* Modulus */
 3089|     29|		bytes_length = BYTES4BITS(key_info->u.rsa.modulus_len);
  ------------------
  |  |  146|     29|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3090|     29|		ushort2bebytes(p, (unsigned short)key_info->u.rsa.modulus_len);
 3091|     29|		p += 2;
 3092|     29|		memcpy(p, key_info->u.rsa.modulus, bytes_length);
 3093|     29|		p += bytes_length;
 3094|       |
 3095|       |		/* Exponent */
 3096|     29|		bytes_length = BYTES4BITS(key_info->u.rsa.exponent_len);
  ------------------
  |  |  146|     29|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3097|     29|		ushort2bebytes(p, (unsigned short)key_info->u.rsa.exponent_len);
 3098|     29|		p += 2;
 3099|     29|		memcpy(p, key_info->u.rsa.exponent, bytes_length);
 3100|     29|	}
 3101|       |	/* ECC */
 3102|      0|	else if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH || /* includes XEDDSA */
  ------------------
  |  |  870|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3102:11): [True: 0, False: 0]
  ------------------
 3103|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3103:4): [True: 0, False: 0]
  ------------------
 3104|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3104:4): [True: 0, False: 0]
  ------------------
 3105|       |		/* Algorithm ID, see https://tools.ietf.org/html/rfc6637#section-5 */
 3106|      0|		*p = key_info->algorithm + 6;
 3107|      0|		p += 1;
 3108|      0|		*p = key_info->u.ec.oidv_len;
 3109|      0|		p += 1;
 3110|      0|		memcpy(p, key_info->u.ec.oidv.value, key_info->u.ec.oidv_len);
 3111|      0|		p += key_info->u.ec.oidv_len;
 3112|      0|		memcpy(p, key_info->u.ec.ecpointQ, key_info->u.ec.ecpointQ_len);
 3113|       |
 3114|       |		/* KDF parameters for ECDH */
 3115|      0|		if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH) {
  ------------------
  |  |  870|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3115:7): [True: 0, False: 0]
  ------------------
 3116|       |			/* https://tools.ietf.org/html/rfc6637#section-8
 3117|       |			 * This is copied from GnuPG's ecdh_params() function in app-openpgp.c */
 3118|      0|			p += BYTES4BITS(key_info->u.ec.ecpointQ_len);
  ------------------
  |  |  146|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3119|      0|			*p = 0x03; /* number of bytes following */
 3120|      0|			p += 1;
 3121|      0|			*p = 0x01; /* version of this format */
 3122|      0|			p += 1;
 3123|      0|			if (key_info->u.ec.key_length <= 256) { /* ec bit size <= 256 */
  ------------------
  |  Branch (3123:8): [True: 0, False: 0]
  ------------------
 3124|      0|				*p = 0x08;	/* KDF algo */
 3125|      0|				*(p+1) = 0x07;	/* KEK algo */
 3126|      0|			} else if (key_info->u.ec.key_length <= 384) { /* ec bit size <= 384 */
  ------------------
  |  Branch (3126:15): [True: 0, False: 0]
  ------------------
 3127|      0|				*p = 0x09;	/* KDF algo */
 3128|      0|				*(p+1) = 0x08;	/* KEK algo */
 3129|      0|			} else {		/* ec bit size = 512 or 521*/
 3130|      0|				*p = 0x0a;	/* KDF algo */
 3131|      0|				*(p+1) = 0x09;	/* KEK algo */
 3132|      0|			}
 3133|      0|		}
 3134|      0|	} else
 3135|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3136|       |
 3137|     29|	p = NULL;
 3138|       |
 3139|       |	/* hash with SHA-1 */
 3140|     29|	SHA1(fp_buffer, fp_buffer_len, fingerprint);
 3141|     29|	free(fp_buffer);
 3142|       |
 3143|       |	/* store to DO */
 3144|     29|	sc_log(card->ctx, "Writing to DO %04X.", tag);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3145|     29|	r = pgp_put_data(card, tag, fingerprint, SHA_DIGEST_LENGTH);
 3146|     29|	LOG_TEST_RET(card->ctx, r, "Cannot write to DO");
  ------------------
  |  |  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: 14, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  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|     29|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3147|       |
 3148|       |	/* update the blob containing fingerprints (00C5) */
 3149|     15|	sc_log(card->ctx, "Updating fingerprint blob 00C5.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3150|     15|	fpseq_blob = pgp_find_blob(card, 0x00C5);
 3151|     15|	if (fpseq_blob == NULL) {
  ------------------
  |  Branch (3151:6): [True: 9, False: 6]
  ------------------
 3152|      9|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      9|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3153|      9|		LOG_TEST_GOTO_ERR(card->ctx, r, "Cannot find blob 00C5");
  ------------------
  |  |  184|      9|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      9|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      9|	int _ret = (r); \
  |  |  |  |  178|      9|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      9|		goto err; \
  |  |  |  |  182|      9|	} \
  |  |  |  |  183|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3154|      9|	}
 3155|      6|	if (20U * key_info->key_id > fpseq_blob->len) {
  ------------------
  |  Branch (3155:6): [True: 2, False: 4]
  ------------------
 3156|      2|		r = SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      2|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
 3157|      2|		LOG_TEST_GOTO_ERR(card->ctx, r, "The 00C5 blob is not large enough");
  ------------------
  |  |  184|      2|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      2|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      2|	int _ret = (r); \
  |  |  |  |  178|      2|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 2, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      2|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      2|		goto err; \
  |  |  |  |  182|      2|	} \
  |  |  |  |  183|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3158|      2|	}
 3159|       |
 3160|       |	/* save the fingerprints sequence */
 3161|      4|	newdata = malloc(fpseq_blob->len);
 3162|      4|	if (newdata == NULL) {
  ------------------
  |  Branch (3162:6): [True: 0, False: 4]
  ------------------
 3163|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3164|      0|		LOG_TEST_GOTO_ERR(card->ctx, r, "Not enough memory to update fingerprint blob 00C5");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3165|      0|	}
 3166|       |
 3167|      4|	memcpy(newdata, fpseq_blob->data, fpseq_blob->len);
 3168|       |	/* move p to the portion holding the fingerprint of the current key */
 3169|      4|	p = newdata + 20 * (key_info->key_id - 1);
 3170|       |	/* copy new fingerprint value */
 3171|      4|	memcpy(p, fingerprint, 20);
 3172|       |	/* set blob's data */
 3173|      4|	pgp_set_blob(fpseq_blob, newdata, fpseq_blob->len);
 3174|      4|	free(newdata);
 3175|       |
 3176|     15|err:
 3177|     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: 11, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      4|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      4|	} \
  |  |  |  |  162|     15|	return _ret; \
  |  |  |  |  163|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3178|     15|}
card-openpgp.c:pgp_update_pubkey_blob:
 3187|      4|{
 3188|      4|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|      4|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 3189|      4|	pgp_blob_t *pk_blob;
 3190|      4|	unsigned int blob_id = 0;
 3191|      4|	sc_pkcs15_pubkey_t p15pubkey;
 3192|      4|	u8 *data = NULL;
 3193|      4|	size_t len;
 3194|      4|	int r;
 3195|       |
 3196|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3197|       |
 3198|      4|	if (key_info->key_id == SC_OPENPGP_KEY_SIGN)
  ------------------
  |  |  865|      4|#define SC_OPENPGP_KEY_SIGN		1
  ------------------
  |  Branch (3198:6): [True: 0, False: 4]
  ------------------
 3199|      0|		blob_id = DO_SIGN_SYM;
  ------------------
  |  |  145|      0|#define DO_SIGN_SYM              0xb601
  ------------------
 3200|      4|	else if (key_info->key_id == SC_OPENPGP_KEY_ENCR)
  ------------------
  |  |  866|      4|#define SC_OPENPGP_KEY_ENCR		2
  ------------------
  |  Branch (3200:11): [True: 0, False: 4]
  ------------------
 3201|      0|		blob_id = DO_ENCR_SYM;
  ------------------
  |  |  146|      0|#define DO_ENCR_SYM              0xb801
  ------------------
 3202|      4|	else if (key_info->key_id == SC_OPENPGP_KEY_AUTH)
  ------------------
  |  |  867|      4|#define SC_OPENPGP_KEY_AUTH		3
  ------------------
  |  Branch (3202:11): [True: 4, False: 0]
  ------------------
 3203|      4|		blob_id = DO_AUTH_SYM;
  ------------------
  |  |  147|      4|#define DO_AUTH_SYM              0xa401
  ------------------
 3204|      0|	else {
 3205|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3206|      0|				"Invalid key ID; must be 1, 2, or 3");
 3207|      0|	}
 3208|       |
 3209|      4|	sc_log(card->ctx, "Retrieving blob %04X.", blob_id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3210|      4|	r = pgp_get_blob(card, priv->mf, blob_id, &pk_blob);
 3211|      4|	LOG_TEST_RET(card->ctx, r, "Cannot get the blob");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3212|       |
 3213|       |	/* encode pubkey */
 3214|       |	/* RSA */
 3215|      4|	if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA){
  ------------------
  |  |  869|      4|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3215:6): [True: 4, False: 0]
  ------------------
 3216|      4|		memset(&p15pubkey, 0, sizeof(p15pubkey));
 3217|      4|		p15pubkey.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      4|#define SC_ALGORITHM_RSA		0
  ------------------
 3218|      4|		p15pubkey.u.rsa.modulus.data  = key_info->u.rsa.modulus;
 3219|      4|		p15pubkey.u.rsa.modulus.len   = BYTES4BITS(key_info->u.rsa.modulus_len);
  ------------------
  |  |  146|      4|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3220|      4|		p15pubkey.u.rsa.exponent.data = key_info->u.rsa.exponent;
 3221|      4|		p15pubkey.u.rsa.exponent.len  = BYTES4BITS(key_info->u.rsa.exponent_len);
  ------------------
  |  |  146|      4|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 3222|      4|	}
 3223|       |	/* ECC */
 3224|      0|	else if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH || /* includes XEDDSA */
  ------------------
  |  |  870|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3224:11): [True: 0, False: 0]
  ------------------
 3225|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3225:4): [True: 0, False: 0]
  ------------------
 3226|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3226:4): [True: 0, False: 0]
  ------------------
 3227|      0|		memset(&p15pubkey, 0, sizeof(p15pubkey));
 3228|      0|		p15pubkey.algorithm = key_info->key_type;
 3229|      0|		p15pubkey.u.ec.ecpointQ.value = key_info->u.ec.ecpointQ;
 3230|      0|		p15pubkey.u.ec.ecpointQ.len = key_info->u.ec.ecpointQ_len;
 3231|      0|	} else
 3232|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3233|       |
 3234|      4|	r = sc_pkcs15_encode_pubkey_as_spki(card->ctx, &p15pubkey, &data, &len);
 3235|       |	/*
 3236|       |	 * key_info is missing an algo_id. sc_pkcs15_encode_pubkey_as_spki
 3237|       |	 * allocates one. Free it here.
 3238|       |	 */
 3239|      4|	free(p15pubkey.alg_id);
 3240|      4|	p15pubkey.alg_id = NULL;
 3241|      4|	LOG_TEST_RET(card->ctx, r, "Cannot encode pubkey");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3242|       |
 3243|      4|	sc_log(card->ctx, "Updating blob %04X's content.", blob_id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3244|      4|	r = pgp_set_blob(pk_blob, data, len);
 3245|      4|	free(data);
 3246|      4|	LOG_TEST_RET(card->ctx, r, "Cannot update blob content");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3247|      4|	LOG_FUNC_RETURN(card->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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3248|      4|}
card-openpgp.c:pgp_update_card_algorithms:
 3385|      4|{
 3386|      4|	sc_algorithm_info_t *algo;
 3387|      4|	u8 id = key_info->key_id;
 3388|      4|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|      4|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 3389|       |
 3390|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3391|       |
 3392|       |	/* protect incompatible cards against non-RSA */
 3393|      4|	if (key_info->algorithm != SC_OPENPGP_KEYALGO_RSA &&
  ------------------
  |  |  869|      8|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3393:6): [True: 0, False: 4]
  ------------------
 3394|      0|			priv->bcd_version < OPENPGP_CARD_3_0 &&
  ------------------
  |  Branch (3394:4): [True: 0, False: 0]
  ------------------
 3395|      0|			card->type != SC_CARD_TYPE_OPENPGP_GNUK)
  ------------------
  |  Branch (3395:4): [True: 0, False: 0]
  ------------------
 3396|      4|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3397|       |
 3398|      4|	if (id > card->algorithm_count) {
  ------------------
  |  Branch (3398:6): [True: 0, False: 4]
  ------------------
 3399|      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__
  |  |  ------------------
  ------------------
 3400|      0|		       "This key ID %u is out of the card's algorithm list.",
 3401|      0|		       (unsigned int)id);
 3402|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3403|      0|	}
 3404|       |
 3405|       |	/* get the algorithm corresponding to the key ID */
 3406|      4|	algo = card->algorithms + (id - 1);
 3407|       |	/* update new key attribute */
 3408|      4|	if (key_info->algorithm == SC_OPENPGP_KEYALGO_RSA) {
  ------------------
  |  |  869|      4|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  |  Branch (3408:6): [True: 4, False: 0]
  ------------------
 3409|      4|		algo->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      4|#define SC_ALGORITHM_RSA		0
  ------------------
 3410|      4|		algo->key_length = (unsigned int)key_info->u.rsa.modulus_len;
 3411|      4|	} else if (key_info->algorithm == SC_OPENPGP_KEYALGO_ECDH || /* includes XEDDSA */
  ------------------
  |  |  870|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  |  Branch (3411:13): [True: 0, False: 0]
  ------------------
 3412|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_ECDSA ||
  ------------------
  |  |  871|      0|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  |  Branch (3412:4): [True: 0, False: 0]
  ------------------
 3413|      0|			key_info->algorithm == SC_OPENPGP_KEYALGO_EDDSA) {
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  |  Branch (3413:4): [True: 0, False: 0]
  ------------------
 3414|      0|		algo->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
 3415|      0|		algo->key_length = (unsigned int)((key_info->u.ec.ecpointQ_len));
 3416|      0|	} else
 3417|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3418|       |
 3419|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3420|      4|}
card-openpgp.c:pgp_update_binary:
 4145|     20|{
 4146|     20|	struct pgp_priv_data *priv = DRVDATA(card);
  ------------------
  |  |  189|     20|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 4147|     20|	pgp_blob_t *blob = priv->current;
 4148|     20|	int r = SC_SUCCESS;
  ------------------
  |  |   28|     20|#define SC_SUCCESS				0
  ------------------
 4149|       |
 4150|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4151|       |
 4152|       |	/* We will use PUT DATA to write to DO.
 4153|       |	 * As PUT DATA does not support idx, we don't either */
 4154|     20|	if (idx > 0)
  ------------------
  |  Branch (4154:6): [True: 7, False: 13]
  ------------------
 4155|     20|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCORRECT_PARAMETERS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4156|       |
 4157|       |	/* When a dummy file, e.g "11001101", is selected, the current blob
 4158|       |	 * is set to NULL. We don't really put data to dummy file. */
 4159|     13|	if (blob != NULL) {
  ------------------
  |  Branch (4159:6): [True: 13, False: 0]
  ------------------
 4160|     13|		r = pgp_put_data(card, blob->id, buf, count);
 4161|     13|	}
 4162|       |
 4163|     13|	LOG_FUNC_RETURN(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: 3, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|	} else { \
  |  |  |  |  159|     10|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     10|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     10|	} \
  |  |  |  |  162|     13|	return _ret; \
  |  |  |  |  163|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4164|     13|}
card-openpgp.c:pgp_card_reader_lock_obtained:
 4171|  5.25k|{
 4172|  5.25k|	struct pgp_priv_data *priv = DRVDATA(card); /* may be null during initialization */
  ------------------
  |  |  189|  5.25k|#define DRVDATA(card)        ((struct pgp_priv_data *) ((card)->drv_data))
  ------------------
 4173|  5.25k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  5.25k|#define SC_SUCCESS				0
  ------------------
 4174|       |
 4175|  5.25k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  5.25k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  5.25k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  5.25k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 5.25k]
  |  |  ------------------
  ------------------
 4176|       |
 4177|  5.25k|	if (card->flags & SC_CARD_FLAG_KEEP_ALIVE
  ------------------
  |  |  544|  10.5k|#define SC_CARD_FLAG_KEEP_ALIVE	0x00000004
  ------------------
  |  Branch (4177:6): [True: 0, False: 5.25k]
  ------------------
 4178|      0|			&& was_reset <= 0
  ------------------
  |  Branch (4178:7): [True: 0, False: 0]
  ------------------
 4179|      0|			&& priv != NULL && priv->mf && priv->mf->file) {
  ------------------
  |  Branch (4179:7): [True: 0, False: 0]
  |  Branch (4179:23): [True: 0, False: 0]
  |  Branch (4179:35): [True: 0, False: 0]
  ------------------
 4180|       |		/* check whether applet is still selected */
 4181|      0|		unsigned char aid[16];
 4182|       |
 4183|      0|		r = sc_get_data(card, 0x004F, aid, sizeof aid);
 4184|      0|		if ((size_t) r != priv->mf->file->namelen
  ------------------
  |  Branch (4184:7): [True: 0, False: 0]
  ------------------
 4185|      0|				|| 0 != memcmp(aid, priv->mf->file->name, r)) {
  ------------------
  |  Branch (4185:8): [True: 0, False: 0]
  ------------------
 4186|       |			/* reselect is required */
 4187|      0|			was_reset = 1;
 4188|      0|		}
 4189|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 4190|      0|	}
 4191|       |
 4192|  5.25k|	if (was_reset > 0) {
  ------------------
  |  Branch (4192:6): [True: 0, False: 5.25k]
  ------------------
 4193|      0|		sc_file_t	*file = NULL;
 4194|      0|		sc_path_t	path;
 4195|       |		/* select application "OpenPGP" */
 4196|      0|		sc_format_path("D276:0001:2401", &path);
 4197|      0|		path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 4198|      0|		r = iso_ops->select_file(card, &path, &file);
 4199|      0|		sc_file_free(file);
 4200|      0|	}
 4201|       |
 4202|  5.25k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  5.25k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.25k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.25k|	int _ret = r; \
  |  |  |  |  155|  5.25k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.25k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 5.25k]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.25k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.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|  5.25k|	return _ret; \
  |  |  |  |  163|  5.25k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4203|  5.25k|}

sc_get_piv_driver:
 6471|  3.69k|{
 6472|  3.69k|	return sc_get_driver();
 6473|  3.69k|}
card-piv.c:sc_get_driver:
 6444|  3.69k|{
 6445|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6446|       |
 6447|  3.69k|	piv_ops = *iso_drv->ops;
 6448|  3.69k|	piv_ops.match_card = piv_match_card;
 6449|  3.69k|	piv_ops.init = piv_init;
 6450|  3.69k|	piv_ops.finish = piv_finish;
 6451|       |
 6452|  3.69k|	piv_ops.select_file = piv_select_file; /* must use get/put, could emulate? */
 6453|  3.69k|	piv_ops.get_challenge = piv_get_challenge;
 6454|  3.69k|	piv_ops.logout = piv_logout;
 6455|  3.69k|	piv_ops.read_binary = piv_read_binary;
 6456|  3.69k|	piv_ops.write_binary = piv_write_binary;
 6457|  3.69k|	piv_ops.set_security_env = piv_set_security_env;
 6458|  3.69k|	piv_ops.restore_security_env = piv_restore_security_env;
 6459|  3.69k|	piv_ops.compute_signature = piv_compute_signature;
 6460|  3.69k|	piv_ops.decipher = piv_decipher;
 6461|  3.69k|	piv_ops.check_sw = piv_check_sw;
 6462|  3.69k|	piv_ops.card_ctl = piv_card_ctl;
 6463|  3.69k|	piv_ops.pin_cmd = piv_pin_cmd;
 6464|  3.69k|	piv_ops.card_reader_lock_obtained = piv_card_reader_lock_obtained;
 6465|       |
 6466|  3.69k|	return &piv_drv;
 6467|  3.69k|}
card-piv.c:piv_match_card:
 5408|    707|{
 5409|    707|	int r = 0;
 5410|       |
 5411|    707|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d\n", card->type);
  ------------------
  |  |   70|    707|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5412|       |	/* piv_match_card may be called with card->type, set by opensc.conf */
 5413|       |	/* user provided card type must be one we know */
 5414|    707|	switch (card->type) {
 5415|    707|	case -1:
  ------------------
  |  Branch (5415:2): [True: 707, False: 0]
  ------------------
 5416|    707|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5416:2): [True: 0, False: 707]
  ------------------
 5417|    707|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5417:2): [True: 0, False: 707]
  ------------------
 5418|    707|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5418:2): [True: 0, False: 707]
  ------------------
 5419|    707|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5419:2): [True: 0, False: 707]
  ------------------
 5420|    707|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5420:2): [True: 0, False: 707]
  ------------------
 5421|    707|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5421:2): [True: 0, False: 707]
  ------------------
 5422|    707|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5422:2): [True: 0, False: 707]
  ------------------
 5423|    707|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5423:2): [True: 0, False: 707]
  ------------------
 5424|    707|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5424:2): [True: 0, False: 707]
  ------------------
 5425|    707|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5425:2): [True: 0, False: 707]
  ------------------
 5426|    707|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5426:2): [True: 0, False: 707]
  ------------------
 5427|    707|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (5427:2): [True: 0, False: 707]
  ------------------
 5428|    707|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (5428:2): [True: 0, False: 707]
  ------------------
 5429|    707|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5429:2): [True: 0, False: 707]
  ------------------
 5430|    707|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5430:2): [True: 0, False: 707]
  ------------------
 5431|    707|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5431:2): [True: 0, False: 707]
  ------------------
 5432|    707|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5432:2): [True: 0, False: 707]
  ------------------
 5433|    707|		break;
 5434|      0|	default:
  ------------------
  |  Branch (5434:2): [True: 0, False: 707]
  ------------------
 5435|      0|		return 0; /* can not handle the card */
 5436|    707|	}
 5437|       |
 5438|    707|	r = sc_lock(card);
 5439|    707|	if (r < 0)
  ------------------
  |  Branch (5439:6): [True: 0, False: 707]
  ------------------
 5440|      0|		return 0;
 5441|       |	/* its one we know, or we can test for it in piv_init */
 5442|    707|	r = piv_match_card_continued(card);
 5443|    707|	sc_unlock(card);
 5444|       |
 5445|    707|	if (r < 0 || !card->drv_data) {
  ------------------
  |  Branch (5445:6): [True: 696, False: 11]
  |  Branch (5445:15): [True: 0, False: 11]
  ------------------
 5446|       |		/* clean up what we left in card */
 5447|    696|		piv_finish(card);
 5448|    696|		return 0; /* match failed */
 5449|    696|	}
 5450|       |
 5451|     11|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r:%d\n", card->type, r);
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5452|     11|	return 1; /* matched */
 5453|    707|}
card-piv.c:piv_match_card_continued:
 5457|    707|{
 5458|    707|	int i, r = 0, r2 = 0;
 5459|    707|	int type = -1;
 5460|    707|	piv_private_data_t *priv = NULL;
 5461|    707|	int saved_type = card->type;
 5462|    707|	sc_apdu_t apdu;
 5463|    707|	u8 yubico_version_buf[3] = {0};
 5464|       |
 5465|       |	/* piv_match_card may be called with card->type, set by opensc.conf */
 5466|       |	/* User provided card type must be one we know */
 5467|       |
 5468|    707|	switch (card->type) {
 5469|    707|	case -1:
  ------------------
  |  Branch (5469:2): [True: 707, False: 0]
  ------------------
 5470|    707|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5470:2): [True: 0, False: 707]
  ------------------
 5471|    707|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5471:2): [True: 0, False: 707]
  ------------------
 5472|    707|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5472:2): [True: 0, False: 707]
  ------------------
 5473|    707|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5473:2): [True: 0, False: 707]
  ------------------
 5474|    707|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5474:2): [True: 0, False: 707]
  ------------------
 5475|    707|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5475:2): [True: 0, False: 707]
  ------------------
 5476|    707|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5476:2): [True: 0, False: 707]
  ------------------
 5477|    707|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5477:2): [True: 0, False: 707]
  ------------------
 5478|    707|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5478:2): [True: 0, False: 707]
  ------------------
 5479|    707|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5479:2): [True: 0, False: 707]
  ------------------
 5480|    707|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5480:2): [True: 0, False: 707]
  ------------------
 5481|    707|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (5481:2): [True: 0, False: 707]
  ------------------
 5482|    707|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (5482:2): [True: 0, False: 707]
  ------------------
 5483|    707|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5483:2): [True: 0, False: 707]
  ------------------
 5484|    707|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5484:2): [True: 0, False: 707]
  ------------------
 5485|    707|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5485:2): [True: 0, False: 707]
  ------------------
 5486|    707|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5486:2): [True: 0, False: 707]
  ------------------
 5487|    707|		type = card->type;
 5488|    707|		break;
 5489|      0|	default:
  ------------------
  |  Branch (5489:2): [True: 0, False: 707]
  ------------------
 5490|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5491|    707|	}
 5492|    707|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|    707|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5493|    707|	if (type == -1) {
  ------------------
  |  Branch (5493:6): [True: 707, False: 0]
  ------------------
 5494|       |		/*
 5495|       |		 * Try to identify card by ATR or historical data in ATR
 5496|       |		 * currently all PIV card will respond to piv_find_aid
 5497|       |		 * the same. But in future may need to know card type first,
 5498|       |		 * so do it here.
 5499|       |		 */
 5500|       |
 5501|    707|		if (card->reader->atr_info.hist_bytes != NULL) {
  ------------------
  |  Branch (5501:7): [True: 259, False: 448]
  ------------------
 5502|    259|			if (card->reader->atr_info.hist_bytes_len == 8 &&
  ------------------
  |  Branch (5502:8): [True: 6, False: 253]
  ------------------
 5503|      6|					!(memcmp(card->reader->atr_info.hist_bytes, "Yubikey4", 8))) {
  ------------------
  |  Branch (5503:6): [True: 3, False: 3]
  ------------------
 5504|      3|				type = SC_CARD_TYPE_PIV_II_YUBIKEY4;
 5505|    256|			} else if (card->reader->atr_info.hist_bytes_len >= 7 &&
  ------------------
  |  Branch (5505:15): [True: 97, False: 159]
  ------------------
 5506|     97|					!(memcmp(card->reader->atr_info.hist_bytes, "Yubikey", 7))) {
  ------------------
  |  Branch (5506:6): [True: 4, False: 93]
  ------------------
 5507|      4|				type = SC_CARD_TYPE_PIV_II_NEO;
 5508|    252|			} else if (card->reader->atr_info.hist_bytes_len >= 6 &&
  ------------------
  |  Branch (5508:15): [True: 101, False: 151]
  ------------------
 5509|    101|					!(memcmp(card->reader->atr_info.hist_bytes, "PIVKEY", 6))) {
  ------------------
  |  Branch (5509:6): [True: 2, False: 99]
  ------------------
 5510|      2|				type = SC_CARD_TYPE_PIV_II_PIVKEY;
 5511|    250|			} else if (card->reader->atr_info.hist_bytes_len >= 6 &&
  ------------------
  |  Branch (5511:15): [True: 99, False: 151]
  ------------------
 5512|     99|					!(memcmp(card->reader->atr_info.hist_bytes, (u8 *)"TK\x00PIV", 6))) {
  ------------------
  |  Branch (5512:6): [True: 0, False: 99]
  ------------------
 5513|      0|				type = SC_CARD_TYPE_PIV_II_TOKEN2;
 5514|      0|			}
 5515|       |			/* look for TLV historic data */
 5516|    250|			else if (card->reader->atr_info.hist_bytes_len > 0 &&
  ------------------
  |  Branch (5516:13): [True: 234, False: 16]
  ------------------
 5517|    234|					card->reader->atr_info.hist_bytes[0] == 0x80u) { /* compact TLV */
  ------------------
  |  Branch (5517:6): [True: 59, False: 175]
  ------------------
 5518|     59|				size_t datalen;
 5519|     59|				const u8 *data;
 5520|       |
 5521|       |				/* look for card issuer's data:  tag 5X where X is datalen */
 5522|     59|				if ((data = sc_compacttlv_find_tag(card->reader->atr_info.hist_bytes + 1,
  ------------------
  |  Branch (5522:9): [True: 0, False: 59]
  ------------------
 5523|     59|						     card->reader->atr_info.hist_bytes_len - 1, 0x50, &datalen))) {
 5524|      0|					if (datalen >= 8 && !(memcmp(data, "Nitrokey", 8))) { /* first 8 are Nitrokey */
  ------------------
  |  Branch (5524:10): [True: 0, False: 0]
  |  Branch (5524:26): [True: 0, False: 0]
  ------------------
 5525|      0|						type = SC_CARD_TYPE_PIV_II_NITROKEY;
 5526|      0|					} else if (datalen == 7 && !(memcmp(data, "YubiKey", 7))) {
  ------------------
  |  Branch (5526:17): [True: 0, False: 0]
  |  Branch (5526:33): [True: 0, False: 0]
  ------------------
 5527|      0|						type = SC_CARD_TYPE_PIV_II_YUBIKEY4; /* reader says 4  really 5 */
 5528|      0|					}
 5529|       |					/* Yubikey 5 NFC ATR using ACR122 contactless reader does not match
 5530|       |					 * https://developers.yubico.com/PIV/Introduction/Yubico_extensions.html
 5531|       |					 * On Windows 10, using Omnikey 5021, the ATR is correct
 5532|       |					 * will look at only 6 bytes that do match
 5533|       |					 */
 5534|      0|					else if (datalen == 7 && !(memcmp(data, "YubiKe", 6))) {
  ------------------
  |  Branch (5534:15): [True: 0, False: 0]
  |  Branch (5534:31): [True: 0, False: 0]
  ------------------
 5535|      0|						type = SC_CARD_TYPE_PIV_II_YUBIKEY4; /* reader says 4 really 5 */
 5536|      0|					}
 5537|     59|				} else if ((data = sc_compacttlv_find_tag(card->reader->atr_info.hist_bytes + 1,
  ------------------
  |  Branch (5537:16): [True: 57, False: 2]
  ------------------
 5538|     59|							    card->reader->atr_info.hist_bytes_len - 1, 0xF0, &datalen))) {
 5539|     57|					int k;
 5540|       |
 5541|    114|					for (k = 0; piv_aids[k].len_long != 0; k++) {
  ------------------
  |  Branch (5541:18): [True: 57, False: 57]
  ------------------
 5542|     57|						if (datalen == piv_aids[k].len_long &&
  ------------------
  |  Branch (5542:11): [True: 54, False: 3]
  ------------------
 5543|     54|								!memcmp(data, piv_aids[k].value, datalen)) {
  ------------------
  |  Branch (5543:9): [True: 0, False: 54]
  ------------------
 5544|      0|							type = SC_CARD_TYPE_PIV_II_HIST;
 5545|      0|							break;
 5546|      0|						}
 5547|     57|					}
 5548|     57|				}
 5549|     59|			}
 5550|    259|		}
 5551|       |
 5552|    707|		sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|    707|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5553|       |
 5554|    707|		if (type == -1) {
  ------------------
  |  Branch (5554:7): [True: 698, False: 9]
  ------------------
 5555|       |			/* use known ATRs  which changes the type */
 5556|    698|			i = _sc_match_atr(card, piv_atrs, &type);
 5557|    698|			if (i < 0)
  ------------------
  |  Branch (5557:8): [True: 698, False: 0]
  ------------------
 5558|    698|				type = SC_CARD_TYPE_PIV_II_BASE; /* May be some newer unknown card including CAC or PIV-like card */
 5559|    698|		}
 5560|    707|	}
 5561|       |
 5562|    707|	card->type = type;
 5563|       |
 5564|       |	/* we either found via ATR historic bytes or ATR directly */
 5565|    707|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d type:%d r:%d\n", card->type, type, r);
  ------------------
  |  |   70|    707|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5566|       |
 5567|       |	/* allocate and init basic fields */
 5568|    707|	priv = calloc(1, sizeof(piv_private_data_t));
 5569|       |
 5570|    707|	if (!priv)
  ------------------
  |  Branch (5570:6): [True: 0, False: 707]
  ------------------
 5571|    707|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5572|       |
 5573|    707|	card->drv_data = priv; /* will free if no match, or pass on to piv_init */
 5574|       |	/*
 5575|       |	 * Largest object defined in NIST sp800-73-3 and sp800-73-4 is 12710 bytes
 5576|       |	 * If for some reason future cards have larger objects, this value needs to
 5577|       |	 * be increased here.
 5578|       |	 */
 5579|    707|	priv->max_object_size = MAX_FILE_SIZE - 256; /* fix SM apdu resplen issue */
  ------------------
  |  |  229|    707|#define MAX_FILE_SIZE 65535
  ------------------
 5580|    707|	priv->selected_obj = -1;
 5581|    707|	priv->pin_preference = 0x80; /* 800-73-3 part 1, table 3 */
 5582|    707|	priv->logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  437|    707|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 5583|    707|	priv->pstate = PIV_STATE_MATCH;
 5584|       |
 5585|       |#ifdef ENABLE_PIV_SM
 5586|       |	memset(&card->sm_ctx, 0, sizeof card->sm_ctx);
 5587|       |	card->sm_ctx.ops.open = piv_sm_open;
 5588|       |	card->sm_ctx.ops.get_sm_apdu = piv_get_sm_apdu;
 5589|       |	card->sm_ctx.ops.free_sm_apdu = piv_free_sm_apdu;
 5590|       |	card->sm_ctx.ops.close = piv_sm_close;
 5591|       |#endif /* ENABLE_PIV_SM */
 5592|       |
 5593|       |	/* See if contactless  or run as virtual card */
 5594|       |	/* PivApplet in .github/test_piv.sh for example */
 5595|    707|	if (card->reader->atr.len >= 4 &&
  ------------------
  |  Branch (5595:6): [True: 319, False: 388]
  ------------------
 5596|    319|			card->reader->atr.value[0] == 0x3b &&
  ------------------
  |  Branch (5596:4): [True: 250, False: 69]
  ------------------
 5597|    250|			(card->reader->atr.value[1] & 0xF0) == 0x80 &&
  ------------------
  |  Branch (5597:4): [True: 7, False: 243]
  ------------------
 5598|      7|			card->reader->atr.value[2] == 0x80 &&
  ------------------
  |  Branch (5598:4): [True: 6, False: 1]
  ------------------
 5599|      6|			card->reader->atr.value[3] == 0x01) {
  ------------------
  |  Branch (5599:4): [True: 1, False: 5]
  ------------------
 5600|      1|		priv->init_flags |= PIV_INIT_CONTACTLESS;
  ------------------
  |  |  382|      1|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
 5601|      1|	}
 5602|       |
 5603|  43.1k|	for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++)
  ------------------
  |  Branch (5603:14): [True: 42.4k, False: 707]
  ------------------
 5604|  42.4k|		if (piv_objects[i].flags & PIV_OBJECT_NOT_PRESENT)
  ------------------
  |  |  634|  42.4k|#define PIV_OBJECT_NOT_PRESENT		0x04
  ------------------
  |  Branch (5604:7): [True: 14.1k, False: 28.2k]
  ------------------
 5605|  14.1k|			priv->obj_cache[i].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  150|  14.8k|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5606|       |	/*
 5607|       |	 * Detect if active AID is PIV. NIST 800-73 says only one PIV application per card
 5608|       |	 * and PIV must be the default application.
 5609|       |	 * Try to avoid doing a select_aid and losing the login state on some cards.
 5610|       |	 * We may get interference on some cards by other drivers trying SELECT_AID before
 5611|       |	 * we get to see if PIV application is still active. Putting PIV driver first might help.
 5612|       |	 *
 5613|       |	 * Discovery Object introduced in 800-73-3 so will return OK if found and PIV applet active.
 5614|       |	 * Will fail with SC_ERROR_FILE_NOT_FOUND if 800-73-3 and no Discovery object.
 5615|       |	 * But some other card could also return SC_ERROR_FILE_NOT_FOUND.
 5616|       |	 * Will fail for other reasons if wrong applet is selected or bad PIV implementation.
 5617|       |	 */
 5618|       |
 5619|       |	/*
 5620|       |	 * if ATR matched or user forced card type
 5621|       |	 * test if PIV is active applet without using AID If fails try AID
 5622|       |	 */
 5623|       |
 5624|    707|	if (card->type > SC_CARD_TYPE_PIV_II_BASE &&
  ------------------
  |  Branch (5624:6): [True: 9, False: 698]
  ------------------
 5625|      9|			!(priv->init_flags & PIV_INIT_CONTACTLESS)) {
  ------------------
  |  |  382|      9|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
  |  Branch (5625:4): [True: 9, False: 0]
  ------------------
 5626|      9|		r = piv_find_discovery(card);
 5627|      9|		if (r < 0) {
  ------------------
  |  Branch (5627:7): [True: 9, False: 0]
  ------------------
 5628|      9|			piv_obj_cache_free_entry(card, PIV_OBJ_DISCOVERY, 0); /* don't cache  on failure */
 5629|      9|			r = piv_find_aid(card);
 5630|      9|			LOG_TEST_GOTO_ERR(card->ctx, r, "Not a PIV card");
  ------------------
  |  |  184|      9|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      9|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      9|	int _ret = (r); \
  |  |  |  |  178|      9|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 9, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      9|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      9|		goto err; \
  |  |  |  |  182|      9|	} \
  |  |  |  |  183|      9|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5631|      9|		}
 5632|    698|	} else {
 5633|       |		/* piv_find_aid saves al_label from response */
 5634|    698|		r = piv_find_aid(card);
 5635|    698|		LOG_TEST_GOTO_ERR(card->ctx, r, "Not a PIV card");
  ------------------
  |  |  184|    698|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    698|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    698|	int _ret = (r); \
  |  |  |  |  178|    698|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 687, False: 11]
  |  |  |  |  ------------------
  |  |  |  |  179|    687|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    687|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    687|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    687|		goto err; \
  |  |  |  |  182|    687|	} \
  |  |  |  |  183|    698|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5636|    698|	}
 5637|       |
 5638|       |	/* Know to be PIV card but not the type */
 5639|       |
 5640|       |	/* If card type still unknown, see if Application Label is known and set card->type */
 5641|     11|	if (priv->al_label && priv->al_labellen) {
  ------------------
  |  Branch (5641:6): [True: 0, False: 11]
  |  Branch (5641:24): [True: 0, False: 0]
  ------------------
 5642|      0|		switch (card->type) {
  ------------------
  |  Branch (5642:11): [True: 0, False: 0]
  ------------------
 5643|      0|		case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5643:3): [True: 0, False: 0]
  ------------------
 5644|      0|		case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5644:3): [True: 0, False: 0]
  ------------------
 5645|      0|			for (i = 0; al_map[i].al_label; i++) {
  ------------------
  |  Branch (5645:16): [True: 0, False: 0]
  ------------------
 5646|      0|				if ((priv->al_labellen >= al_map[i].al_labellen) &&
  ------------------
  |  Branch (5646:9): [True: 0, False: 0]
  ------------------
 5647|      0|						(!memcmp(priv->al_label, al_map[i].al_label, al_map[i].al_labellen))) {
  ------------------
  |  Branch (5647:7): [True: 0, False: 0]
  ------------------
 5648|      0|					sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "AL match i:%d type:%d", i, al_map[i].al_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__
  |  |  ------------------
  ------------------
 5649|      0|					card->type = al_map[i].al_type;
 5650|      0|					break;
 5651|      0|				}
 5652|      0|			}
 5653|      0|			break;
 5654|      0|		}
 5655|      0|	}
 5656|       |
 5657|     11|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d  CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5658|     11|			card->type, priv->card_issues, r, priv->alg_ids);
 5659|       |
 5660|       |	/*
 5661|       |	 * Assumes all Yubikey/Nitrokey/Token2/PivApplet cards are all "Yubico like"
 5662|       |	 * via ATR, ATR Historic bytes or Application Label
 5663|       |	 * Will also check if BASE cards are Yubikey like card and return a version number
 5664|       |	 * SC_CARD_TYPE_PIV_II_GENERIC can be set by user to not test for Yubico version
 5665|       |	 */
 5666|     11|	switch (card->type) {
  ------------------
  |  Branch (5666:10): [True: 11, False: 0]
  ------------------
 5667|      0|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5667:2): [True: 0, False: 11]
  ------------------
 5668|      0|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5668:2): [True: 0, False: 11]
  ------------------
 5669|      0|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5669:2): [True: 0, False: 11]
  ------------------
 5670|      0|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5670:2): [True: 0, False: 11]
  ------------------
 5671|      0|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5671:2): [True: 0, False: 11]
  ------------------
 5672|      0|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5672:2): [True: 0, False: 11]
  ------------------
 5673|     11|	case SC_CARD_TYPE_PIV_II_BASE: /* unknown PIV card */
  ------------------
  |  Branch (5673:2): [True: 11, False: 0]
  ------------------
 5674|     11|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xFD, 0x00, 0x00);
  ------------------
  |  |  292|     11|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 5675|     11|		apdu.lc = 0;
 5676|     11|		apdu.data = NULL;
 5677|     11|		apdu.datalen = 0;
 5678|     11|		apdu.resp = yubico_version_buf;
 5679|     11|		apdu.resplen = sizeof(yubico_version_buf);
 5680|     11|		apdu.le = apdu.resplen;
 5681|     11|		r2 = sc_transmit_apdu(card, &apdu); /* if not supported yubico_version == 0 */
 5682|     11|		if (apdu.resplen == 3) {
  ------------------
  |  Branch (5682:7): [True: 3, False: 8]
  ------------------
 5683|      3|			priv->yubico_version = (yubico_version_buf[0] << 16) | (yubico_version_buf[1] << 8) | yubico_version_buf[2];
 5684|      3|			sc_log(card->ctx, "Yubikey version test card->type=%d, r=0x%08x version=0x%08x", card->type, r, priv->yubico_version);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5685|      3|		}
 5686|     11|		break;
 5687|     11|	}
 5688|       |
 5689|     11|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5690|     11|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5691|       |
 5692|       |	/* We now know PIV AID is active, test CCC object. 800-73-* say CCC is required */
 5693|       |	/* CCC not readable over contactless, unless using VCI. but dont need CCC for SC_CARD_TYPE_PIV_II_800_73_4 */
 5694|     11|	switch (card->type) {
  ------------------
  |  Branch (5694:10): [True: 11, False: 0]
  ------------------
 5695|       |	/*
 5696|       |	 * For cards that may also be CAC, try and read the CCC
 5697|       |	 * CCC is required and all Dual PIV/CAC will have a CCC
 5698|       |	 * Currently Dual PIV/CAC are based on NIST 800-73-1 which does not have Discovery or History
 5699|       |	 */
 5700|     11|	case SC_CARD_TYPE_PIV_II_BASE: /* i.e. really dont know what this is */
  ------------------
  |  Branch (5700:2): [True: 11, False: 0]
  ------------------
 5701|     11|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5701:2): [True: 0, False: 11]
  ------------------
 5702|     11|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5702:2): [True: 0, False: 11]
  ------------------
 5703|     11|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5703:2): [True: 0, False: 11]
  ------------------
 5704|     11|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5704:2): [True: 0, False: 11]
  ------------------
 5705|     11|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5705:2): [True: 0, False: 11]
  ------------------
 5706|     11|		r2 = piv_process_ccc(card);
 5707|     11|		sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5708|     11|				card->type, r2, priv->card_issues, r, priv->alg_ids);
 5709|       |		/* Ignore any error. */
 5710|       |		/* If CCC says it has CAC with PKI on card set to one of the SC_CARD_TYPE_PIV_II_*_DUAL_CAC */
 5711|     11|		if (priv->ccc_flags & PIV_CCC_F3_CAC_PKI) {
  ------------------
  |  |  171|     11|#define PIV_CCC_F3_CAC_PKI	0x00000010
  ------------------
  |  Branch (5711:7): [True: 0, False: 11]
  ------------------
 5712|      0|			switch (card->type) {
  ------------------
  |  Branch (5712:12): [True: 0, False: 0]
  ------------------
 5713|      0|			case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5713:4): [True: 0, False: 0]
  ------------------
 5714|      0|			case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5714:4): [True: 0, False: 0]
  ------------------
 5715|      0|			case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5715:4): [True: 0, False: 0]
  ------------------
 5716|      0|			case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5716:4): [True: 0, False: 0]
  ------------------
 5717|      0|				card->type = SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC;
 5718|      0|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  578|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5719|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  150|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5720|      0|				break;
 5721|      0|			case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5721:4): [True: 0, False: 0]
  ------------------
 5722|      0|				card->type = SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC;
 5723|      0|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  578|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5724|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  150|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5725|      0|				break;
 5726|      0|			case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5726:4): [True: 0, False: 0]
  ------------------
 5727|      0|				card->type = SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC;
 5728|      0|				priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  578|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5729|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  150|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5730|      0|				break;
 5731|      0|			}
 5732|      0|		}
 5733|     11|		break;
 5734|       |
 5735|     11|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5735:2): [True: 0, False: 11]
  ------------------
 5736|      0|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5736:2): [True: 0, False: 11]
  ------------------
 5737|      0|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5737:2): [True: 0, False: 11]
  ------------------
 5738|      0|		priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  578|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5739|      0|		priv->obj_cache[PIV_OBJ_DISCOVERY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  150|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5740|      0|		break;
 5741|     11|	}
 5742|     11|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5743|     11|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5744|       |
 5745|       |	/* If contactless or run as virtual card try to get alg refs from AC entries in response to SELECT AID */
 5746|     11|	if (!(priv->init_flags & PIV_INIT_AID_PARSED) && priv->init_flags & PIV_INIT_CONTACTLESS) {
  ------------------
  |  |  377|     11|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
              	if (!(priv->init_flags & PIV_INIT_AID_PARSED) && priv->init_flags & PIV_INIT_CONTACTLESS) {
  ------------------
  |  |  382|      0|#define PIV_INIT_CONTACTLESS			0x00000020u
  ------------------
  |  Branch (5746:6): [True: 0, False: 11]
  |  Branch (5746:51): [True: 0, False: 0]
  ------------------
 5747|      0|		r2 = piv_find_aid(card);
 5748|      0|	}
 5749|       |
 5750|       |	/* Read AID if needed for these cards types */
 5751|     11|	if (!(priv->init_flags & PIV_INIT_AID_PARSED)) {
  ------------------
  |  |  377|     11|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
  |  Branch (5751:6): [True: 0, False: 11]
  ------------------
 5752|      0|		switch (card->type) {
  ------------------
  |  Branch (5752:11): [True: 0, False: 0]
  ------------------
 5753|      0|		case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5753:3): [True: 0, False: 0]
  ------------------
 5754|      0|		case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5754:3): [True: 0, False: 0]
  ------------------
 5755|      0|		case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5755:3): [True: 0, False: 0]
  ------------------
 5756|      0|		case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5756:3): [True: 0, False: 0]
  ------------------
 5757|      0|		case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5757:3): [True: 0, False: 0]
  ------------------
 5758|      0|		case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5758:3): [True: 0, False: 0]
  ------------------
 5759|      0|			r2 = piv_find_aid(card);
 5760|      0|		}
 5761|      0|	}
 5762|       |
 5763|     11|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5764|     11|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5765|       |
 5766|       |	/* if card did not specify any of the NIST basic alg_ids add them */
 5767|     11|	if ((priv->alg_ids & AI_NIST) == 0) {
  ------------------
  |  |  597|     11|#define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  588|     11|#define AI_RSA_1024			    0x00000001U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  589|     11|#define AI_RSA_2048			    0x00000002U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  590|     11|#define AI_RSA_3072			    0x00000004U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  592|     11|#define AI_EC_256			    0x00000100U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  593|     11|#define AI_EC_384			    0x00000200U
  |  |  ------------------
  ------------------
  |  Branch (5767:6): [True: 11, False: 0]
  ------------------
 5768|     11|		priv->alg_ids |= AI_NIST;
  ------------------
  |  |  597|     11|#define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  588|     11|#define AI_RSA_1024			    0x00000001U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  589|     11|#define AI_RSA_2048			    0x00000002U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  590|     11|#define AI_RSA_3072			    0x00000004U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  592|     11|#define AI_EC_256			    0x00000100U
  |  |  ------------------
  |  |               #define AI_NIST (AI_RSA_1024 | AI_RSA_2048 | AI_RSA_3072 | AI_EC_256 | AI_EC_384)
  |  |  ------------------
  |  |  |  |  593|     11|#define AI_EC_384			    0x00000200U
  |  |  ------------------
  ------------------
 5769|     11|	}
 5770|       |
 5771|       |	/* If unknown card has 800-73-4 features, it must be based on 800-73-4 or above */
 5772|     11|	switch (card->type) {
  ------------------
  |  Branch (5772:10): [True: 11, False: 0]
  ------------------
 5773|     11|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5773:2): [True: 11, False: 0]
  ------------------
 5774|     11|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5774:2): [True: 0, False: 11]
  ------------------
 5775|     11|		if (priv->init_flags & PIV_INIT_AID_AC_SM) {
  ------------------
  |  |  378|     11|#define PIV_INIT_AID_AC_SM			0x00000002u
  ------------------
  |  Branch (5775:7): [True: 0, False: 11]
  ------------------
 5776|      0|			card->type = SC_CARD_TYPE_PIV_II_800_73_4;
 5777|      0|		}
 5778|       |
 5779|       |#ifdef ENABLE_PIV_SM
 5780|       |		/* Discovery object has pin policy. 800-74-4 bits, its at least SC_CARD_TYPE_PIV_II_800_73_4 */
 5781|       |		if ((priv->pin_policy & (PIV_PP_OCC | PIV_PP_VCI_IMPL | PIV_PP_VCI_WITHOUT_PC)) != 0) {
 5782|       |			card->type = SC_CARD_TYPE_PIV_II_800_73_4;
 5783|       |		}
 5784|       |#endif
 5785|     11|		break;
 5786|     11|	}
 5787|       |
 5788|     11|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5789|     11|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5790|       |
 5791|       |	/*
 5792|       |	 * Set card_issues flags based card->type and version numbers if available.
 5793|       |	 *
 5794|       |	 * YubiKey NEO, Yubikey 4 and other devices with PIV applets, have compliance
 5795|       |	 * issues with the NIST 800-73-3 specs. The OpenSC developers do not have
 5796|       |	 * access to all the different devices or versions of the devices.
 5797|       |	 * Vendor and user input is welcome on any compliance issues.
 5798|       |	 *
 5799|       |	 * For the Yubico devices The assumption is also made that if a bug is
 5800|       |	 * fixed in a Yubico version that means it is fixed on both NEO and Yubikey 4.
 5801|       |	 *
 5802|       |	 * The flags CI_CANT_USE_GETDATA_FOR_STATE and CI_DISCOVERY_USELESS
 5803|       |	 * may be set earlier or later then in the following code.
 5804|       |	 */
 5805|       |
 5806|     11|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|     11|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5807|     11|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5808|     11|	switch (card->type) {
 5809|      0|	case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (5809:2): [True: 0, False: 11]
  ------------------
 5810|      0|		priv->card_issues |= CI_NO_EC384 |
  ------------------
  |  |  584|      0|#define CI_NO_EC384			    0x00000400U /* does not have EC 384 */
  ------------------
 5811|      0|				     CI_VERIFY_630X |
  ------------------
  |  |  572|      0|#define CI_VERIFY_630X			    0x00000001U /* VERIFY tries left returns 630X rather then 63CX */
  ------------------
 5812|      0|				     CI_OTHER_AID_LOSE_STATE |
  ------------------
  |  |  581|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5813|      0|				     CI_LEAKS_FILE_NOT_FOUND |
  ------------------
  |  |  577|      0|#define CI_LEAKS_FILE_NOT_FOUND		    0x00000010U /* GET DATA of empty object returns 6A 82 even if PIN not verified */
  ------------------
 5814|      0|				     CI_NFC_EXPOSE_TOO_MUCH;
  ------------------
  |  |  582|      0|#define CI_NFC_EXPOSE_TOO_MUCH		    0x00000200U /* PIN, crypto and objects exposed over NFS in violation of 800-73-3 */
  ------------------
 5815|      0|		if (priv->yubico_version < 0x00040302)
  ------------------
  |  Branch (5815:7): [True: 0, False: 0]
  ------------------
 5816|      0|			priv->card_issues |= CI_VERIFY_LC0_FAIL;
  ------------------
  |  |  573|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5817|      0|		break;
 5818|       |
 5819|      0|	case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (5819:2): [True: 0, False: 11]
  ------------------
 5820|      0|	case SC_CARD_TYPE_PIV_II_PIVAPPLET:
  ------------------
  |  Branch (5820:2): [True: 0, False: 11]
  ------------------
 5821|      0|	case SC_CARD_TYPE_PIV_II_TOKEN2:
  ------------------
  |  Branch (5821:2): [True: 0, False: 11]
  ------------------
 5822|      0|		priv->card_issues |= CI_OTHER_AID_LOSE_STATE |
  ------------------
  |  |  581|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5823|      0|				     CI_LEAKS_FILE_NOT_FOUND;
  ------------------
  |  |  577|      0|#define CI_LEAKS_FILE_NOT_FOUND		    0x00000010U /* GET DATA of empty object returns 6A 82 even if PIN not verified */
  ------------------
 5824|      0|		if (priv->yubico_version < 0x00040302)
  ------------------
  |  Branch (5824:7): [True: 0, False: 0]
  ------------------
 5825|      0|			priv->card_issues |= CI_VERIFY_LC0_FAIL;
  ------------------
  |  |  573|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5826|      0|		if (priv->yubico_version >= 0x00050700) /* Also used by Token2 */
  ------------------
  |  Branch (5826:7): [True: 0, False: 0]
  ------------------
 5827|      0|			priv->alg_ids |= AI_RSA_4096 | AI_25519;
  ------------------
  |  |  591|      0|#define AI_RSA_4096			    0x00000008U
  ------------------
              			priv->alg_ids |= AI_RSA_4096 | AI_25519;
  ------------------
  |  |  594|      0|#define AI_25519			    0x00100000U
  ------------------
 5828|      0|		break;
 5829|       |
 5830|      0|	case SC_CARD_TYPE_PIV_II_NITROKEY:
  ------------------
  |  Branch (5830:2): [True: 0, False: 11]
  ------------------
 5831|      0|		priv->card_issues |= CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  581|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5832|      0|		if (priv->yubico_version >= 0x00010802) /* use for NitroKey too */
  ------------------
  |  Branch (5832:7): [True: 0, False: 0]
  ------------------
 5833|      0|			priv->alg_ids |= AI_RSA_4096;
  ------------------
  |  |  591|      0|#define AI_RSA_4096			    0x00000008U
  ------------------
 5834|      0|		break;
 5835|       |
 5836|      0|	case SC_CARD_TYPE_PIV_II_GI_DE:
  ------------------
  |  Branch (5836:2): [True: 0, False: 11]
  ------------------
 5837|      0|	case SC_CARD_TYPE_PIV_II_OBERTHUR:
  ------------------
  |  Branch (5837:2): [True: 0, False: 11]
  ------------------
 5838|      0|	case SC_CARD_TYPE_PIV_II_GEMALTO:
  ------------------
  |  Branch (5838:2): [True: 0, False: 11]
  ------------------
 5839|      0|	case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (5839:2): [True: 0, False: 11]
  ------------------
 5840|      0|		priv->card_issues |= 0; /* could add others here */
 5841|      0|		break;
 5842|       |
 5843|     11|	case SC_CARD_TYPE_PIV_II_BASE:
  ------------------
  |  Branch (5843:2): [True: 11, False: 0]
  ------------------
 5844|     11|	case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (5844:2): [True: 0, False: 11]
  ------------------
 5845|     11|	case SC_CARD_TYPE_PIV_II_800_73_4:
  ------------------
  |  Branch (5845:2): [True: 0, False: 11]
  ------------------
 5846|     11|		priv->card_issues |= 0; /* could add others here */
 5847|     11|		break;
 5848|       |
 5849|      0|	case SC_CARD_TYPE_PIV_II_GI_DE_DUAL_CAC:
  ------------------
  |  Branch (5849:2): [True: 0, False: 11]
  ------------------
 5850|      0|	case SC_CARD_TYPE_PIV_II_GEMALTO_DUAL_CAC:
  ------------------
  |  Branch (5850:2): [True: 0, False: 11]
  ------------------
 5851|      0|	case SC_CARD_TYPE_PIV_II_OBERTHUR_DUAL_CAC:
  ------------------
  |  Branch (5851:2): [True: 0, False: 11]
  ------------------
 5852|      0|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  573|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5853|      0|				     CI_PIV_AID_LOSE_STATE |
  ------------------
  |  |  579|      0|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
 5854|      0|				     CI_NO_RANDOM |
  ------------------
  |  |  575|      0|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
 5855|      0|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  581|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5856|      0|		break;
 5857|       |
 5858|      0|	case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (5858:2): [True: 0, False: 11]
  ------------------
 5859|      0|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  573|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5860|      0|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  581|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5861|      0|		break;
 5862|       |
 5863|      0|	case SC_CARD_TYPE_PIV_II_PIVKEY:
  ------------------
  |  Branch (5863:2): [True: 0, False: 11]
  ------------------
 5864|      0|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  573|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5865|      0|				     CI_PIV_AID_LOSE_STATE | /* be conservative */
  ------------------
  |  |  579|      0|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
 5866|      0|				     CI_NO_RANDOM;	     /* does not have 9B key */
  ------------------
  |  |  575|      0|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
 5867|       |							     /* Discovery object returns 6A 82 so is not on card by default */
 5868|      0|		break;
 5869|       |
 5870|      0|	default:
  ------------------
  |  Branch (5870:2): [True: 0, False: 11]
  ------------------
 5871|      0|		priv->card_issues |= CI_VERIFY_LC0_FAIL |
  ------------------
  |  |  573|      0|#define CI_VERIFY_LC0_FAIL		    0x00000002U /* VERIFY Lc=0 never returns 90 00 if PIN not needed */
  ------------------
 5872|      0|				     CI_OTHER_AID_LOSE_STATE;
  ------------------
  |  |  581|      0|#define CI_OTHER_AID_LOSE_STATE		    0x00000100U /* Other drivers match routines may reset our security state and lose AID!!! */
  ------------------
 5873|       |		/* opensc.conf may have it wrong, continue anyway */
 5874|      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__
  |  |  ------------------
  ------------------
 5875|      0|		card->type = SC_CARD_TYPE_PIV_II_GENERIC;
 5876|     11|	}
 5877|     11|	sc_log(card->ctx, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\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__
  |  |  ------------------
  ------------------
 5878|     11|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5879|       |
 5880|     11|	if (!(priv->card_issues & CI_DISCOVERY_USELESS) && !(priv->init_flags & PIV_INIT_DISCOVERY_PARSED)) {
  ------------------
  |  |  578|     11|#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)) {
  ------------------
  |  |  379|     11|#define PIV_INIT_DISCOVERY_PARSED		0x00000004u
  ------------------
  |  Branch (5880:6): [True: 11, False: 0]
  |  Branch (5880:53): [True: 11, False: 0]
  ------------------
 5881|       |		/*
 5882|       |		 * We now know PIV AID is active, test DISCOVERY object again
 5883|       |		 * Some PIV don't support DISCOVERY and return
 5884|       |		 * SC_ERROR_INCORRECT_PARAMETERS. Any error
 5885|       |		 * including SC_ERROR_FILE_NOT_FOUND means we cannot use discovery
 5886|       |		 * to test for active AID.
 5887|       |		 */
 5888|     11|		r2 = piv_find_discovery(card);
 5889|       |
 5890|     11|		if (r2 < 0) {
  ------------------
  |  Branch (5890:7): [True: 11, False: 0]
  ------------------
 5891|     11|			priv->card_issues |= CI_DISCOVERY_USELESS;
  ------------------
  |  |  578|     11|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
 5892|     11|			piv_obj_cache_free_entry(card, PIV_OBJ_DISCOVERY, PIV_OBJ_CACHE_NOT_PRESENT);
  ------------------
  |  |  150|     11|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5893|     11|		}
 5894|     11|	}
 5895|       |
 5896|     11|	sc_log(card->ctx, "PIV_MATCH card->type:%d r2:%d CI:%08x r:%d AI:%08x\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__
  |  |  ------------------
  ------------------
 5897|     11|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5898|       |	/* Matched, caller will use or free priv and sc_lock as needed */
 5899|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5900|       |
 5901|    696|err:
 5902|    696|	sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "PIV_MATCH failed card->type:%d r2:%d CI:%08x r:%d AI:%08x\n",
  ------------------
  |  |   70|    696|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5903|    696|			card->type, r2, priv->card_issues, r, priv->alg_ids);
 5904|       |	/* don't match. Does not have a PIV applet. */
 5905|    696|	piv_finish(card);
 5906|    696|	card->type = saved_type;
 5907|    696|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    696|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    696|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    696|	int _ret = r; \
  |  |  |  |  155|    696|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 696, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    696|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    696|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 696, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    696|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    696|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    696|	return _ret; \
  |  |  |  |  163|    696|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5908|    696|}
card-piv.c:piv_find_discovery:
 5057|     20|{
 5058|     20|	int r = 0;
 5059|     20|	size_t rbuflen;
 5060|     20|	u8 *rbuf = NULL;
 5061|     20|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|     20|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5062|       |
 5063|     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]
  |  |  ------------------
  ------------------
 5064|       |
 5065|       |	/*
 5066|       |	 * During piv_card_reader_lock_obtained,
 5067|       |	 * we use the discovery object to test if card present, and
 5068|       |	 * if PIV AID is active.
 5069|       |	 */
 5070|     20|	if (priv->obj_cache[PIV_OBJ_DISCOVERY].flags & PIV_OBJ_CACHE_NOT_PRESENT) {
  ------------------
  |  |  150|     20|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
  |  Branch (5070:6): [True: 0, False: 20]
  ------------------
 5071|      0|		r = SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
 5072|      0|		goto end;
 5073|      0|	}
 5074|       |
 5075|       |	/* If not valid: read, test,  cache */
 5076|     20|	if (!(priv->obj_cache[PIV_OBJ_DISCOVERY].flags & PIV_OBJ_CACHE_VALID)) {
  ------------------
  |  |  148|     20|#define PIV_OBJ_CACHE_VALID		1
  ------------------
  |  Branch (5076:6): [True: 20, False: 0]
  ------------------
 5077|     20|		r = piv_process_discovery(card);
 5078|     20|	} else {
 5079|       |		/* if already in cache,force read */
 5080|      0|		rbuflen = 1;
 5081|      0|		r = piv_get_data(card, PIV_OBJ_DISCOVERY, &rbuf, &rbuflen);
 5082|       |		/* if same response as last, no need to parse */
 5083|      0|		if (r == 0 && priv->obj_cache[PIV_OBJ_DISCOVERY].obj_len == 0)
  ------------------
  |  Branch (5083:7): [True: 0, False: 0]
  |  Branch (5083:17): [True: 0, False: 0]
  ------------------
 5084|      0|			goto end;
 5085|       |
 5086|      0|		if (r >= 0 && priv->obj_cache[PIV_OBJ_DISCOVERY].obj_len == rbuflen &&
  ------------------
  |  Branch (5086:7): [True: 0, False: 0]
  |  Branch (5086:17): [True: 0, False: 0]
  ------------------
 5087|      0|				priv->obj_cache[PIV_OBJ_DISCOVERY].obj_data &&
  ------------------
  |  Branch (5087:5): [True: 0, False: 0]
  ------------------
 5088|      0|				!memcmp(rbuf, priv->obj_cache[PIV_OBJ_DISCOVERY].obj_data, rbuflen)) {
  ------------------
  |  Branch (5088:5): [True: 0, False: 0]
  ------------------
 5089|      0|			goto end;
 5090|      0|		}
 5091|       |		/* This should not happen  bad card */
 5092|      0|		sc_log(card->ctx, "Discovery not the same as previously read object");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 5093|      0|		r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
 5094|      0|		goto end;
 5095|      0|	}
 5096|       |
 5097|     20|end:
 5098|     20|	free(rbuf);
 5099|     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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5100|     20|}
card-piv.c:piv_process_discovery:
 4950|     20|{
 4951|     20|	int r;
 4952|     20|	u8 *rbuf = NULL;
 4953|     20|	size_t rbuflen = 0;
 4954|       |
 4955|     20|	r = piv_get_cached_data(card, PIV_OBJ_DISCOVERY, &rbuf, &rbuflen);
 4956|       |	/* Note rbuf and rbuflen are now pointers into cache */
 4957|     20|	if (r < 0)
  ------------------
  |  Branch (4957:6): [True: 19, False: 1]
  ------------------
 4958|     19|		goto err;
 4959|       |
 4960|       |	/* the object is now cached, see what we have */
 4961|      1|	r = piv_parse_discovery(card, rbuf, rbuflen, 0);
 4962|       |
 4963|     20|err:
 4964|     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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4965|     20|}
card-piv.c:piv_get_cached_data:
 3189|     42|{
 3190|       |
 3191|     42|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|     42|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 3192|     42|	int r;
 3193|     42|	u8 *rbuf = NULL;
 3194|     42|	size_t rbuflen;
 3195|       |
 3196|     42|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     42|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     42|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     42|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 42]
  |  |  ------------------
  ------------------
 3197|       |
 3198|     42|	if (enumtag < 0 || enumtag >= PIV_OBJ_LAST_ENUM)
  ------------------
  |  Branch (3198:6): [True: 0, False: 42]
  |  Branch (3198:21): [True: 0, False: 42]
  ------------------
 3199|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3200|       |
 3201|     42|	sc_log(card->ctx, "#%d, %s", enumtag, piv_objects[enumtag].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__
  |  |  ------------------
  ------------------
 3202|       |
 3203|       |	/* see if we have it cached */
 3204|     42|	if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_VALID) {
  ------------------
  |  |  148|     42|#define PIV_OBJ_CACHE_VALID		1
  ------------------
  |  Branch (3204:6): [True: 0, False: 42]
  ------------------
 3205|       |
 3206|      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__
  |  |  ------------------
  ------------------
 3207|      0|				"found #%d %p:%" SC_FORMAT_LEN_SIZE_T "u %p:%" SC_FORMAT_LEN_SIZE_T "u",
 3208|      0|				enumtag,
 3209|      0|				priv->obj_cache[enumtag].obj_data,
 3210|      0|				priv->obj_cache[enumtag].obj_len,
 3211|      0|				priv->obj_cache[enumtag].internal_obj_data,
 3212|      0|				priv->obj_cache[enumtag].internal_obj_len);
 3213|       |
 3214|      0|		if (priv->obj_cache[enumtag].obj_len == 0) {
  ------------------
  |  Branch (3214:7): [True: 0, False: 0]
  ------------------
 3215|      0|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3216|      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__
  |  |  ------------------
  ------------------
 3217|      0|			goto err;
 3218|      0|		}
 3219|      0|		*buf = priv->obj_cache[enumtag].obj_data;
 3220|      0|		*buf_len = priv->obj_cache[enumtag].obj_len;
 3221|      0|		r = (int)*buf_len;
 3222|      0|		goto ok;
 3223|      0|	}
 3224|       |
 3225|       |	/*
 3226|       |	 * If we know it can not be on the card  i.e. History object
 3227|       |	 * has been read, and we know what other certs may or
 3228|       |	 * may not be on the card. We can avoid extra overhead
 3229|       |	 * Also used if object on card was not parsable
 3230|       |	 */
 3231|       |
 3232|     42|	if (priv->obj_cache[enumtag].flags & PIV_OBJ_CACHE_NOT_PRESENT) {
  ------------------
  |  |  150|     42|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
  |  Branch (3232:6): [True: 0, False: 42]
  ------------------
 3233|      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__
  |  |  ------------------
  ------------------
 3234|      0|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3235|      0|		goto err;
 3236|      0|	}
 3237|       |
 3238|       |	/* Not cached, try to get it, piv_get_data will allocate a buf */
 3239|     42|	sc_log(card->ctx, "get #%d", enumtag);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3240|     42|	rbuflen = 1;
 3241|     42|	r = piv_get_data(card, enumtag, &rbuf, &rbuflen);
 3242|     42|	if (r > 0) {
  ------------------
  |  Branch (3242:6): [True: 12, False: 30]
  ------------------
 3243|     12|		priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  148|     12|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 3244|     12|		priv->obj_cache[enumtag].obj_len = r;
 3245|     12|		priv->obj_cache[enumtag].obj_data = rbuf;
 3246|     12|		*buf = rbuf;
 3247|     12|		*buf_len = r;
 3248|       |
 3249|     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__
  |  |  ------------------
  ------------------
 3250|     12|				"added #%d  %p:%" SC_FORMAT_LEN_SIZE_T "u %p:%" SC_FORMAT_LEN_SIZE_T "u",
 3251|     12|				enumtag,
 3252|     12|				priv->obj_cache[enumtag].obj_data,
 3253|     12|				priv->obj_cache[enumtag].obj_len,
 3254|     12|				priv->obj_cache[enumtag].internal_obj_data,
 3255|     12|				priv->obj_cache[enumtag].internal_obj_len);
 3256|       |
 3257|     30|	} else {
 3258|     30|		free(rbuf);
 3259|     30|		if (r == 0 || r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|     30|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (3259:7): [True: 0, False: 30]
  |  Branch (3259:17): [True: 6, False: 24]
  ------------------
 3260|      6|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      6|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3261|      6|			priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  148|      6|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 3262|      6|			priv->obj_cache[enumtag].obj_len = 0;
 3263|     24|		} else {
 3264|     24|			goto err;
 3265|     24|		}
 3266|     30|	}
 3267|     18|ok:
 3268|       |
 3269|     42|err:
 3270|     42|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     42|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     42|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     42|	int _ret = r; \
  |  |  |  |  155|     42|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 30, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     12|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     12|	} \
  |  |  |  |  162|     42|	return _ret; \
  |  |  |  |  163|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3271|     42|}
card-piv.c:piv_parse_discovery:
 4893|      1|{
 4894|      1|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|      1|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4895|      1|	int r = 0;
 4896|      1|	const u8 *body;
 4897|      1|	size_t bodylen;
 4898|      1|	const u8 *aid;
 4899|      1|	size_t aidlen;
 4900|      1|	const u8 *pinp;
 4901|      1|	size_t pinplen;
 4902|      1|	unsigned int cla_out, tag_out;
 4903|       |
 4904|      1|	if (rbuflen != 0) {
  ------------------
  |  Branch (4904:6): [True: 1, False: 0]
  ------------------
 4905|      1|		body = rbuf;
 4906|      1|		if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
  |  Branch (4906:7): [True: 0, False: 1]
  ------------------
 4907|      1|				body == NULL ||
  ------------------
  |  Branch (4907:5): [True: 0, False: 1]
  ------------------
 4908|      1|				bodylen == 0 ||
  ------------------
  |  Branch (4908:5): [True: 0, False: 1]
  ------------------
 4909|      1|				((cla_out | tag_out) != 0x7E)) {
  ------------------
  |  Branch (4909:5): [True: 0, False: 1]
  ------------------
 4910|      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__
  |  |  ------------------
  ------------------
 4911|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 4912|      0|			goto err;
 4913|      0|		}
 4914|       |
 4915|      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__
  |  |  ------------------
  ------------------
 4916|      1|				"Discovery 0x%2.2x 0x%2.2x %p:%" SC_FORMAT_LEN_SIZE_T "u",
 4917|      1|				cla_out, tag_out, body, bodylen);
 4918|      1|		aidlen = 0;
 4919|      1|		aid = sc_asn1_find_tag(card->ctx, body, bodylen, 0x4F, &aidlen);
 4920|      1|		if (aid == NULL || aidlen < piv_aids[0].len_short ||
  ------------------
  |  Branch (4920:7): [True: 0, False: 1]
  |  Branch (4920:22): [True: 0, False: 1]
  ------------------
 4921|      1|				memcmp(aid, piv_aids[0].value, piv_aids[0].len_short) != 0) {
  ------------------
  |  Branch (4921:5): [True: 1, False: 0]
  ------------------
 4922|      1|			sc_log(card->ctx, "Discovery object not PIV");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4923|      1|			r = SC_ERROR_INVALID_CARD; /* This is an error */
  ------------------
  |  |   60|      1|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
 4924|      1|			goto err;
 4925|      1|		}
 4926|      0|		if (aid_only == 0) {
  ------------------
  |  Branch (4926:7): [True: 0, False: 0]
  ------------------
 4927|      0|			pinp = sc_asn1_find_tag(card->ctx, body, bodylen, 0x5F2F, &pinplen);
 4928|      0|			if (pinp && pinplen == 2) {
  ------------------
  |  Branch (4928:8): [True: 0, False: 0]
  |  Branch (4928:16): [True: 0, False: 0]
  ------------------
 4929|      0|				priv->init_flags |= PIV_INIT_DISCOVERY_PP;
  ------------------
  |  |  380|      0|#define PIV_INIT_DISCOVERY_PP			0x00000008u
  ------------------
 4930|      0|				priv->pin_policy = (*pinp << 8) + *(pinp + 1);
 4931|      0|				sc_log(card->ctx, "Discovery pinp flags=0x%2.2x 0x%2.2x", *pinp, *(pinp + 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__
  |  |  ------------------
  ------------------
 4932|      0|				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  368|      0|#define PIV_PP_PIN		0x00004000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  369|      0|#define PIV_PP_GLOBAL		0x00002000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  368|      0|#define PIV_PP_PIN		0x00004000u
  ------------------
              				if ((priv->pin_policy & (PIV_PP_PIN | PIV_PP_GLOBAL)) == (PIV_PP_PIN | PIV_PP_GLOBAL) &&
  ------------------
  |  |  369|      0|#define PIV_PP_GLOBAL		0x00002000u
  ------------------
  |  Branch (4932:9): [True: 0, False: 0]
  ------------------
 4933|      0|						priv->pin_policy & PIV_PP_GLOBAL_PRIMARY) {
  ------------------
  |  |  374|      0|#define PIV_PP_GLOBAL_PRIMARY	0x00000020u
  ------------------
  |  Branch (4933:7): [True: 0, False: 0]
  ------------------
 4934|      0|					sc_log(card->ctx, "Pin Preference - Global");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4935|      0|					priv->pin_preference = 0x00;
 4936|      0|				}
 4937|      0|			}
 4938|      0|		}
 4939|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 4940|      0|		priv->init_flags |= PIV_INIT_DISCOVERY_PARSED;
  ------------------
  |  |  379|      0|#define PIV_INIT_DISCOVERY_PARSED		0x00000004u
  ------------------
 4941|      0|	}
 4942|       |
 4943|      1|err:
 4944|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4945|      1|}
card-piv.c:piv_get_data:
 3077|     42|{
 3078|     42|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|     42|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 3079|     42|	u8 *p;
 3080|     42|	u8 *tbuf;
 3081|     42|	int r = 0;
 3082|     42|	u8 tagbuf[8];
 3083|     42|	size_t tag_len;
 3084|     42|	int alloc_buf = 0;
 3085|       |
 3086|     42|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     42|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     42|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     42|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 42]
  |  |  ------------------
  ------------------
 3087|       |
 3088|     42|	sc_log(card->ctx, "#%d, %s", enumtag, piv_objects[enumtag].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__
  |  |  ------------------
  ------------------
 3089|       |
 3090|     42|	r = sc_lock(card); /* do check len and get data in same transaction */
 3091|     42|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     42|#define SC_SUCCESS				0
  ------------------
  |  Branch (3091:6): [True: 0, False: 42]
  ------------------
 3092|      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__
  |  |  ------------------
  ------------------
 3093|      0|		return r;
 3094|      0|	}
 3095|       |
 3096|     42|	tag_len = piv_objects[enumtag].tag_len;
 3097|       |
 3098|     42|	p = tagbuf;
 3099|     42|	r = sc_asn1_put_tag(0x5c, piv_objects[enumtag].tag_value, tag_len, tagbuf, sizeof(tagbuf), &p);
 3100|     42|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     42|#define SC_SUCCESS				0
  ------------------
  |  Branch (3100:6): [True: 0, False: 42]
  ------------------
 3101|      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__
  |  |  ------------------
  ------------------
 3102|      0|		goto err;
 3103|      0|	}
 3104|       |
 3105|     42|	if (*buf_len == 1 && *buf == NULL) {
  ------------------
  |  Branch (3105:6): [True: 42, False: 0]
  |  Branch (3105:23): [True: 42, False: 0]
  ------------------
 3106|     42|		*buf_len = priv->max_object_size; /* will allocate below */
 3107|     42|		alloc_buf = 1;
 3108|     42|	}
 3109|       |
 3110|     42|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3111|     42|			"buffer for #%d *buf=0x%p len=%" SC_FORMAT_LEN_SIZE_T "u",
 3112|     42|			enumtag, *buf, *buf_len);
 3113|     42|	if (*buf == NULL && *buf_len > 0) {
  ------------------
  |  Branch (3113:6): [True: 42, False: 0]
  |  Branch (3113:22): [True: 42, False: 0]
  ------------------
 3114|     42|		if (*buf_len > MAX_FILE_SIZE) {
  ------------------
  |  |  229|     42|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (3114:7): [True: 0, False: 42]
  ------------------
 3115|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3116|      0|			goto err;
 3117|      0|		}
 3118|     42|		*buf = malloc(*buf_len);
 3119|     42|		if (*buf == NULL) {
  ------------------
  |  Branch (3119:7): [True: 0, False: 42]
  ------------------
 3120|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3121|      0|			goto err;
 3122|      0|		}
 3123|     42|	}
 3124|       |
 3125|       |#ifdef ENABLE_PIV_SM
 3126|       |	/*
 3127|       |	 * Over contact reader, OK to read non sensitive object in clear even when SM is active
 3128|       |	 * but only if using default policy and we are not in reader_lock_obtained
 3129|       |	 * Discovery object will use SM from reader_lock_obtained to catch if SM is still valid
 3130|       |	 * i.e. no interference from other applications
 3131|       |	 */
 3132|       |	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",
 3133|       |			enumtag, card->sm_ctx.sm_mode, piv_objects[enumtag].flags, priv->sm_flags, priv->init_flags);
 3134|       |	if (priv->sm_flags & PIV_SM_FLAGS_SM_IS_ACTIVE &&
 3135|       |			enumtag != PIV_OBJ_DISCOVERY &&
 3136|       |			card->sm_ctx.sm_mode == SM_MODE_TRANSMIT &&
 3137|       |			!(piv_objects[enumtag].flags & PIV_OBJECT_NEEDS_PIN) &&
 3138|       |			!(priv->sm_flags & (PIV_SM_FLAGS_NEVER | PIV_SM_FLAGS_ALWAYS)) &&
 3139|       |			!(priv->init_flags & (PIV_INIT_CONTACTLESS | PIV_INIT_IN_READER_LOCK_OBTAINED))) {
 3140|       |		sc_log(card->ctx, "Set PIV_SM_GET_DATA_IN_CLEAR");
 3141|       |		priv->sm_flags |= PIV_SM_GET_DATA_IN_CLEAR;
 3142|       |	}
 3143|       |
 3144|       |#endif /* ENABLE_PIV_SM */
 3145|     42|	r = piv_general_io(card, 0xCB, 0x3F, 0xFF, tagbuf, p - tagbuf, *buf, *buf_len);
 3146|     42|	if (r > 0) {
  ------------------
  |  Branch (3146:6): [True: 18, False: 24]
  ------------------
 3147|     18|		int r_tag;
 3148|     18|		unsigned int cla_out, tag_out;
 3149|     18|		size_t bodylen = 0;
 3150|     18|		const u8 *body = *buf;
 3151|     18|		r_tag = sc_asn1_read_tag(&body, r, &cla_out, &tag_out, &bodylen);
 3152|     18|		if (r_tag != SC_SUCCESS || body == NULL ||
  ------------------
  |  |   28|     36|#define SC_SUCCESS				0
  ------------------
  |  Branch (3152:7): [True: 0, False: 18]
  |  Branch (3152:30): [True: 1, False: 17]
  ------------------
 3153|     17|				((cla_out << 24 | tag_out) != piv_objects[enumtag].resp_tag)) {
  ------------------
  |  Branch (3153:5): [True: 5, False: 12]
  ------------------
 3154|      6|			sc_log(card->ctx, "invalid tag or length r_tag:%d body:%p", r_tag, body);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3155|      6|			r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      6|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3156|      6|			goto err;
 3157|      6|		}
 3158|     12|		*buf_len = (body - *buf) + bodylen;
 3159|     24|	} else if (r == 0) {
  ------------------
  |  Branch (3159:13): [True: 0, False: 24]
  ------------------
 3160|      0|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 3161|      0|		goto err;
 3162|     24|	} else {
 3163|     24|		goto err;
 3164|     24|	}
 3165|       |
 3166|     12|	if (alloc_buf && *buf) {
  ------------------
  |  Branch (3166:6): [True: 12, False: 0]
  |  Branch (3166:19): [True: 12, False: 0]
  ------------------
 3167|     12|		tbuf = malloc(r);
 3168|     12|		if (tbuf == NULL) {
  ------------------
  |  Branch (3168:7): [True: 0, False: 12]
  ------------------
 3169|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 3170|      0|			goto err;
 3171|      0|		}
 3172|     12|		memcpy(tbuf, *buf, r);
 3173|     12|		free(*buf);
 3174|     12|		alloc_buf = 0;
 3175|     12|		*buf = tbuf;
 3176|     12|	}
 3177|       |
 3178|     42|err:
 3179|     42|	if (alloc_buf) {
  ------------------
  |  Branch (3179:6): [True: 30, False: 12]
  ------------------
 3180|     30|		free(*buf);
 3181|     30|		*buf = NULL;
 3182|     30|	}
 3183|     42|	sc_unlock(card);
 3184|     42|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     42|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     42|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     42|	int _ret = r; \
  |  |  |  |  155|     42|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 30, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     12|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     12|	} \
  |  |  |  |  162|     42|	return _ret; \
  |  |  |  |  163|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3185|     42|}
card-piv.c:piv_general_io:
 1782|     42|{
 1783|     42|	int r;
 1784|     42|	sc_apdu_t apdu;
 1785|       |
 1786|     42|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     42|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     42|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     42|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 42]
  |  |  ------------------
  ------------------
 1787|       |
 1788|     42|	r = sc_lock(card);
 1789|     42|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     42|#define SC_SUCCESS				0
  ------------------
  |  Branch (1789:6): [True: 0, False: 42]
  ------------------
 1790|     42|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1791|       |
 1792|     42|	sc_format_apdu(card, &apdu,
 1793|     42|			recvbuf ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT,
  ------------------
  |  |  294|     42|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
              			recvbuf ? SC_APDU_CASE_4_SHORT : SC_APDU_CASE_3_SHORT,
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (1793:4): [True: 42, False: 0]
  ------------------
 1794|     42|			ins, p1, p2);
 1795|     42|	apdu.flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     42|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
 1796|       |#ifdef ENABLE_PIV_SM
 1797|       |	if (card->sm_ctx.sm_mode != SM_MODE_NONE && sendbuflen > 255) {
 1798|       |		/* tell apdu.c to not do the chaining, let the SM get_apdu do it */
 1799|       |		apdu.flags |= SC_APDU_FLAGS_SM_CHAINING;
 1800|       |	}
 1801|       |#endif
 1802|     42|	apdu.lc = sendbuflen;
 1803|     42|	apdu.datalen = sendbuflen;
 1804|     42|	apdu.data = sendbuf;
 1805|       |
 1806|     42|	if (recvbuf && recvbuflen) {
  ------------------
  |  Branch (1806:6): [True: 42, False: 0]
  |  Branch (1806:17): [True: 42, False: 0]
  ------------------
 1807|     42|		apdu.le = (recvbuflen > 256) ? 256 : recvbuflen;
  ------------------
  |  Branch (1807:13): [True: 42, False: 0]
  ------------------
 1808|     42|		apdu.resplen = recvbuflen;
 1809|     42|	} else {
 1810|      0|		apdu.le = 0;
 1811|      0|		apdu.resplen = 0;
 1812|      0|	}
 1813|     42|	apdu.resp = recvbuf;
 1814|       |
 1815|       |	/* with new adpu.c and chaining, this actually reads the whole object */
 1816|     42|	r = sc_transmit_apdu(card, &apdu);
 1817|       |
 1818|       |	/* adpu will not have sw1,sw2 set because sc_sm_single_transmit called sc_sm_stop, */
 1819|     42|	if (r < 0) {
  ------------------
  |  Branch (1819:6): [True: 3, False: 39]
  ------------------
 1820|      3|		sc_log(card->ctx, "Transmit failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1821|      3|		goto err;
 1822|      3|	}
 1823|       |
 1824|     39|	if (apdu.sw1 == 0x69 && apdu.sw2 == 0x88)
  ------------------
  |  Branch (1824:6): [True: 0, False: 39]
  |  Branch (1824:26): [True: 0, False: 0]
  ------------------
 1825|      0|		r = SC_ERROR_SM_INVALID_SESSION_KEY;
  ------------------
  |  |  119|      0|#define SC_ERROR_SM_INVALID_SESSION_KEY		-1604
  ------------------
 1826|     39|	else
 1827|     39|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1828|       |
 1829|     39|	if (r < 0) {
  ------------------
  |  Branch (1829:6): [True: 21, False: 18]
  ------------------
 1830|     21|		sc_log(card->ctx, "Card returned error ");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1831|     21|		goto err;
 1832|     21|	}
 1833|       |
 1834|     18|	r = (int)apdu.resplen;
 1835|       |
 1836|     42|err:
 1837|     42|	sc_unlock(card);
 1838|     42|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     42|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     42|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     42|	int _ret = r; \
  |  |  |  |  155|     42|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 24, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     18|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     18|	} \
  |  |  |  |  162|     42|	return _ret; \
  |  |  |  |  163|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1839|     42|}
card-piv.c:piv_obj_cache_free_entry:
 5355|  42.4k|{
 5356|  42.4k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|  42.4k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5357|       |
 5358|  42.4k|	if (priv->obj_cache[enumtag].obj_data)
  ------------------
  |  Branch (5358:6): [True: 12, False: 42.4k]
  ------------------
 5359|     12|		free(priv->obj_cache[enumtag].obj_data);
 5360|  42.4k|	priv->obj_cache[enumtag].obj_data = NULL;
 5361|  42.4k|	priv->obj_cache[enumtag].obj_len = 0;
 5362|       |
 5363|  42.4k|	if (priv->obj_cache[enumtag].internal_obj_data)
  ------------------
  |  Branch (5363:6): [True: 0, False: 42.4k]
  ------------------
 5364|      0|		free(priv->obj_cache[enumtag].internal_obj_data);
 5365|  42.4k|	priv->obj_cache[enumtag].internal_obj_data = NULL;
 5366|  42.4k|	priv->obj_cache[enumtag].internal_obj_len = 0;
 5367|  42.4k|	priv->obj_cache[enumtag].flags = flags;
 5368|       |
 5369|  42.4k|	return SC_SUCCESS;
  ------------------
  |  |   28|  42.4k|#define SC_SUCCESS				0
  ------------------
 5370|  42.4k|}
card-piv.c:piv_find_aid:
 2890|    707|{
 2891|    707|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|    707|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 2892|    707|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
 2893|    707|	int r, i, j;
 2894|    707|	const u8 *tag;
 2895|    707|	size_t taglen;
 2896|    707|	const u8 *nextac;
 2897|    707|	const u8 *next80;
 2898|    707|	const u8 *pix;
 2899|    707|	size_t pixlen;
 2900|    707|	const u8 *al_label;
 2901|    707|	size_t al_labellen;
 2902|    707|	const u8 *actag; /* Cipher Suite */
 2903|    707|	size_t actaglen;
 2904|    707|	const u8 *csai; /* Cipher Suite Algorithm Identifier */
 2905|    707|	size_t csailen;
 2906|    707|	size_t resplen = sizeof(rbuf);
 2907|       |#ifdef ENABLE_PIV_SM
 2908|       |	int found_csai = 0;
 2909|       |#endif
 2910|       |
 2911|    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]
  |  |  ------------------
  ------------------
 2912|       |
 2913|       |	/* first  see if the default application will return a template
 2914|       |	 * that we know about.
 2915|       |	 */
 2916|       |
 2917|    707|	r = iso7816_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, rbuf, &resplen);
 2918|    707|	if (r > 0 && priv->aid_der.value && resplen == priv->aid_der.len && !memcmp(priv->aid_der.value, rbuf, resplen)) {
  ------------------
  |  Branch (2918:6): [True: 0, False: 707]
  |  Branch (2918:15): [True: 0, False: 0]
  |  Branch (2918:38): [True: 0, False: 0]
  |  Branch (2918:70): [True: 0, False: 0]
  ------------------
 2919|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2920|       |		/* no need to parse again, same as last time */
 2921|      0|	}
 2922|    707|	if (r >= 0 && resplen > 2) {
  ------------------
  |  Branch (2922:6): [True: 51, False: 656]
  |  Branch (2922:16): [True: 45, False: 6]
  ------------------
 2923|     45|		tag = sc_asn1_find_tag(card->ctx, rbuf, resplen, 0x61, &taglen);
 2924|     45|		if (tag != NULL) {
  ------------------
  |  Branch (2924:7): [True: 12, False: 33]
  ------------------
 2925|     12|			priv->init_flags |= PIV_INIT_AID_PARSED;
  ------------------
  |  |  377|     12|#define PIV_INIT_AID_PARSED			0x00000001u
  ------------------
 2926|       |			/* look for 800-73-4 0xAC for Cipher Suite Algorithm Identifier Table 14 */
 2927|       |			/* 800-73-4 only expects 1 0xAC tag len 6 with a 80 01 xx 06 01 00
 2928|       |			 * where xx is the SM csID either 27 or 2E.
 2929|       |			 * Some vendors may include entries for supported Algorithms even when
 2930|       |			 * not required. We will use these if possible
 2931|       |			 * Will look for multiple 0x80 with in 0xAC value too.
 2932|       |			 */
 2933|     12|			nextac = tag;
 2934|     12|			while ((actag = sc_asn1_find_tag(card->ctx, nextac, taglen - (nextac - tag),
  ------------------
  |  Branch (2934:11): [True: 0, False: 12]
  ------------------
 2935|     12|						0xAC, &actaglen)) != NULL) {
 2936|      0|				nextac = actag + actaglen;
 2937|       |
 2938|      0|				next80 = actag;
 2939|      0|				while ((csai = sc_asn1_find_tag(card->ctx, next80, actaglen - (next80 - actag),
  ------------------
  |  Branch (2939:12): [True: 0, False: 0]
  ------------------
 2940|      0|							0x80, &csailen)) != NULL) {
 2941|      0|					next80 = csai + csailen;
 2942|      0|					if (csailen == 1) {
  ------------------
  |  Branch (2942:10): [True: 0, False: 0]
  ------------------
 2943|      0|						sc_log(card->ctx, "0xAC 0x80 entry:0x%2.2x found", *csai);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2944|      0|						j = piv_ai_map_find_by_id(card, *csai);
 2945|      0|						if (j >= 0) {
  ------------------
  |  Branch (2945:11): [True: 0, False: 0]
  ------------------
 2946|      0|							priv->alg_ids |= ai_map[j].ai_flag;
 2947|      0|							continue;
 2948|      0|						}
 2949|       |#ifdef ENABLE_PIV_SM
 2950|       |						/* check if id is NIST SM */
 2951|       |						for (i = 0; i < PIV_CSS_SIZE; i++) {
 2952|       |							if (*csai != css[i].id)
 2953|       |								continue;
 2954|       |							if (found_csai) {
 2955|       |								sc_log(card->ctx, "found multiple csIDs, using first");
 2956|       |							} else {
 2957|       |								priv->cs = &css[i];
 2958|       |								priv->csID = *csai;
 2959|       |								found_csai++;
 2960|       |								priv->init_flags |= PIV_INIT_AID_AC_SM;
 2961|       |							}
 2962|       |						}
 2963|       |#endif /* ENABLE_PIV_SM */
 2964|      0|					}
 2965|      0|				}
 2966|      0|			}
 2967|       |
 2968|       |			/* Last chance to distinguish card type based on Application Label '50' */
 2969|     12|			al_label = sc_asn1_find_tag(card->ctx, tag, taglen, 0x50, &al_labellen);
 2970|     12|			if (al_label != NULL) {
  ------------------
  |  Branch (2970:8): [True: 0, False: 12]
  ------------------
 2971|      0|				sc_log_hex(card->ctx, "Application Label", al_label, al_labellen);
  ------------------
  |  |  129|      0|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|      0|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2972|      0|				if ((priv->al_label = malloc(al_labellen)) == NULL) {
  ------------------
  |  Branch (2972:9): [True: 0, False: 0]
  ------------------
 2973|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2974|      0|				}
 2975|      0|				memcpy(priv->al_label, al_label, al_labellen);
 2976|      0|				priv->al_labellen = (int)al_labellen;
 2977|      0|			}
 2978|       |
 2979|     12|			pix = sc_asn1_find_tag(card->ctx, tag, taglen, 0x4F, &pixlen);
 2980|     12|			if (pix != NULL) {
  ------------------
  |  Branch (2980:8): [True: 11, False: 1]
  ------------------
 2981|     11|				sc_log(card->ctx, "found PIX");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2982|       |
 2983|       |				/* early cards returned full AID, rather then just the pix */
 2984|     11|				for (i = 0; piv_aids[i].len_long != 0; i++) {
  ------------------
  |  Branch (2984:17): [True: 11, False: 0]
  ------------------
 2985|     11|					if ((pixlen >= 6 && memcmp(pix, piv_aids[i].value + 5, piv_aids[i].len_long - 5) == 0) ||
  ------------------
  |  Branch (2985:11): [True: 11, False: 0]
  |  Branch (2985:26): [True: 11, False: 0]
  ------------------
 2986|      0|							((pixlen >= piv_aids[i].len_short && memcmp(pix, piv_aids[i].value,
  ------------------
  |  Branch (2986:10): [True: 0, False: 0]
  |  Branch (2986:45): [True: 0, False: 0]
  ------------------
 2987|     11|													     piv_aids[i].len_short) == 0))) {
 2988|     11|						free(priv->aid_der.value); /* free previous value if any */
 2989|     11|						if ((priv->aid_der.value = malloc(resplen)) == NULL) {
  ------------------
  |  Branch (2989:11): [True: 0, False: 11]
  ------------------
 2990|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2991|      0|						}
 2992|     11|						memcpy(priv->aid_der.value, rbuf, resplen);
 2993|     11|						priv->aid_der.len = resplen;
 2994|     11|						LOG_FUNC_RETURN(card->ctx, i);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2995|     11|					}
 2996|     11|				}
 2997|     11|			}
 2998|     12|		}
 2999|     45|	}
 3000|       |
 3001|    696|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NO_CARD_SUPPORT);
  ------------------
  |  |  164|    696|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    696|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    696|	int _ret = r; \
  |  |  |  |  155|    696|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 696, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    696|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    696|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 696, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    696|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    696|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    696|	return _ret; \
  |  |  |  |  163|    696|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3002|    696|}
card-piv.c:piv_process_ccc:
 5038|     11|{
 5039|     11|	int r = 0;
 5040|     11|	u8 *rbuf = NULL;
 5041|     11|	size_t rbuflen = 0;
 5042|       |
 5043|     11|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     11|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     11|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     11|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 11]
  |  |  ------------------
  ------------------
 5044|     11|	r = piv_get_cached_data(card, PIV_OBJ_CCC, &rbuf, &rbuflen);
 5045|       |
 5046|     11|	if (r < 0)
  ------------------
  |  Branch (5046:6): [True: 7, False: 4]
  ------------------
 5047|      7|		goto err;
 5048|       |
 5049|       |	/* the object is now cached, see what we have */
 5050|      4|	r = piv_parse_ccc(card, rbuf, rbuflen);
 5051|     11|err:
 5052|     11|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5053|     11|}
card-piv.c:piv_parse_ccc:
 4974|      4|{
 4975|      4|	int r = 0;
 4976|      4|	const u8 *body;
 4977|      4|	size_t bodylen;
 4978|      4|	unsigned int cla_out, tag_out;
 4979|       |
 4980|      4|	u8 tag;
 4981|      4|	const u8 *end;
 4982|      4|	size_t len;
 4983|       |
 4984|      4|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|      4|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4985|       |
 4986|      4|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 4987|       |
 4988|      4|	if (rbuf == NULL || rbuflen == 0) {
  ------------------
  |  Branch (4988:6): [True: 0, False: 4]
  |  Branch (4988:22): [True: 0, False: 4]
  ------------------
 4989|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 4990|      0|		goto err;
 4991|      0|	}
 4992|       |
 4993|       |	/* Outer layer is a DER tlv */
 4994|      4|	body = rbuf;
 4995|      4|	if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|      8|#define SC_SUCCESS				0
  ------------------
  |  Branch (4995:6): [True: 0, False: 4]
  ------------------
 4996|      4|			body == NULL ||
  ------------------
  |  Branch (4996:4): [True: 0, False: 4]
  ------------------
 4997|      4|			bodylen == 0 ||
  ------------------
  |  Branch (4997:4): [True: 0, False: 4]
  ------------------
 4998|      4|			((cla_out << 24 | tag_out) != piv_objects[PIV_OBJ_CCC].resp_tag)) {
  ------------------
  |  Branch (4998:4): [True: 0, False: 4]
  ------------------
 4999|      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__
  |  |  ------------------
  ------------------
 5000|      0|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5001|      0|		goto err;
 5002|      0|	}
 5003|       |
 5004|      4|	priv->ccc_flags |= PIV_CCC_FOUND;
  ------------------
  |  |  167|      4|#define PIV_CCC_FOUND		0x00000001
  ------------------
 5005|       |
 5006|       |	/* CCC  entries are simple tlv */
 5007|      4|	end = body + bodylen;
 5008|     13|	for (; (body < end); body += len) {
  ------------------
  |  Branch (5008:9): [True: 13, False: 0]
  ------------------
 5009|     13|		r = sc_simpletlv_read_tag(&body, end - body, &tag, &len);
 5010|     13|		if (r < 0)
  ------------------
  |  Branch (5010:7): [True: 4, False: 9]
  ------------------
 5011|      4|			goto err;
 5012|      9|		switch (tag) {
  ------------------
  |  Branch (5012:11): [True: 3, False: 6]
  ------------------
 5013|      3|		case PIV_CCC_TAG_F0:
  ------------------
  |  |  173|      3|#define PIV_CCC_TAG_F0		0xF0
  ------------------
  |  Branch (5013:3): [True: 3, False: 6]
  ------------------
 5014|      3|			if (len == 0x15) {
  ------------------
  |  Branch (5014:8): [True: 1, False: 2]
  ------------------
 5015|      1|				if (memcmp(body, "\xA0\x00\x00\x03\08", 5) == 0)
  ------------------
  |  Branch (5015:9): [True: 0, False: 1]
  ------------------
 5016|      0|					priv->ccc_flags |= PIV_CCC_F0_PIV;
  ------------------
  |  |  168|      0|#define PIV_CCC_F0_PIV		0x00000002
  ------------------
 5017|      1|				else if (memcmp(body, "\xA0\x00\x00\x00\x79", 5) == 0)
  ------------------
  |  Branch (5017:14): [True: 0, False: 1]
  ------------------
 5018|      0|					priv->ccc_flags |= PIV_CCC_F0_CAC;
  ------------------
  |  |  169|      0|#define PIV_CCC_F0_CAC		0x00000004
  ------------------
 5019|      1|				if (*(body + 6) == 0x02)
  ------------------
  |  Branch (5019:9): [True: 1, False: 0]
  ------------------
 5020|      1|					priv->ccc_flags |= PIV_CCC_F0_JAVA;
  ------------------
  |  |  170|      1|#define PIV_CCC_F0_JAVA		0x00000008
  ------------------
 5021|      1|			}
 5022|      3|			break;
 5023|      0|		case PIV_CCC_TAG_F3:
  ------------------
  |  |  174|      0|#define PIV_CCC_TAG_F3		0xF3
  ------------------
  |  Branch (5023:3): [True: 0, False: 9]
  ------------------
 5024|      0|			if (len == 0x10) {
  ------------------
  |  Branch (5024:8): [True: 0, False: 0]
  ------------------
 5025|      0|				if (memcmp(body, "\xA0\x00\x00\x00\x79\x04", 6) == 0)
  ------------------
  |  Branch (5025:9): [True: 0, False: 0]
  ------------------
 5026|      0|					priv->ccc_flags |= PIV_CCC_F3_CAC_PKI;
  ------------------
  |  |  171|      0|#define PIV_CCC_F3_CAC_PKI	0x00000010
  ------------------
 5027|      0|			}
 5028|      0|			break;
 5029|      9|		}
 5030|      9|	}
 5031|       |
 5032|      4|err:
 5033|      4|	LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5034|      4|}
card-piv.c:piv_init:
 5912|     11|{
 5913|     11|	int r = 0;
 5914|     11|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|     11|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5915|     11|	unsigned long flags;
 5916|     11|	unsigned long flags_eddsa;
 5917|     11|	unsigned long flags_xeddsa;
 5918|     11|	unsigned long ext_flags;
 5919|       |
 5920|     11|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     11|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     11|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     11|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 11]
  |  |  ------------------
  ------------------
 5921|       |
 5922|     11|	r = sc_lock(card); /* hold until match or init is complete */
 5923|     11|	LOG_TEST_RET(card->ctx, r, "sc_lock 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5924|       |
 5925|       |	/* piv_match_card_continued called from card match should have left card->drv_data */
 5926|     11|	if (priv == NULL) {
  ------------------
  |  Branch (5926:6): [True: 0, False: 11]
  ------------------
 5927|      0|		r = piv_match_card_continued(card);
 5928|      0|		priv = PIV_DATA(card);
  ------------------
  |  |  432|      0|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5929|      0|		if (r < 0 || !priv) {
  ------------------
  |  Branch (5929:7): [True: 0, False: 0]
  |  Branch (5929:16): [True: 0, False: 0]
  ------------------
 5930|      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__
  |  |  ------------------
  ------------------
 5931|      0|			sc_unlock(card);
 5932|      0|			piv_finish(card);
 5933|       |			/* tell sc_connect_card to try other driver */
 5934|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5935|      0|		}
 5936|      0|	}
 5937|       |
 5938|       |	/* read "card_driver PIV-II" opensc.conf options, and env parameters */
 5939|     11|	piv_load_options(card);
 5940|       |
 5941|     11|	priv->pstate = PIV_STATE_INIT;
 5942|       |
 5943|     11|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 5944|     11|			"Max send = %" SC_FORMAT_LEN_SIZE_T "u recv = %" SC_FORMAT_LEN_SIZE_T "u card->type:%d, CI:%08x AI:%08x",
 5945|     11|			card->max_send_size, card->max_recv_size, card->type, priv->card_issues, priv->alg_ids);
 5946|     11|	card->cla = 0x00;
 5947|     11|	if (card->name == NULL)
  ------------------
  |  Branch (5947:6): [True: 11, False: 0]
  ------------------
 5948|     11|		card->name = card->driver->name;
 5949|       |
 5950|     11|	priv->enumtag = piv_aids[0].enumtag;
 5951|       |
 5952|       |	/* PKCS#11 may try to generate session keys, and get confused
 5953|       |	 * if SC_ALGORITHM_ONBOARD_KEY_GEN is present
 5954|       |	 * piv-tool can still do this, just don't tell PKCS#11
 5955|       |	 */
 5956|       |
 5957|     11|	flags = SC_ALGORITHM_RSA_RAW;
  ------------------
  |  |  111|     11|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
 5958|       |
 5959|     11|	if (card->type == SC_CARD_TYPE_PIV_II_SWISSBIT) {
  ------------------
  |  Branch (5959:6): [True: 0, False: 11]
  ------------------
 5960|      0|		flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|      0|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 5961|      0|	}
 5962|       |
 5963|     11|	if (priv->alg_ids & AI_RSA_1024)
  ------------------
  |  |  588|     11|#define AI_RSA_1024			    0x00000001U
  ------------------
  |  Branch (5963:6): [True: 11, False: 0]
  ------------------
 5964|     11|		_sc_card_add_rsa_alg(card, 1024, flags, 0); /* mandatory */
 5965|       |
 5966|     11|	if (priv->alg_ids & AI_RSA_2048)
  ------------------
  |  |  589|     11|#define AI_RSA_2048			    0x00000002U
  ------------------
  |  Branch (5966:6): [True: 11, False: 0]
  ------------------
 5967|     11|		_sc_card_add_rsa_alg(card, 2048, flags, 0); /* optional */
 5968|       |
 5969|     11|	if (priv->alg_ids & AI_RSA_3072)
  ------------------
  |  |  590|     11|#define AI_RSA_3072			    0x00000004U
  ------------------
  |  Branch (5969:6): [True: 11, False: 0]
  ------------------
 5970|     11|		_sc_card_add_rsa_alg(card, 3072, flags, 0); /* optional */
 5971|       |
 5972|     11|	if (priv->alg_ids & AI_RSA_4096)
  ------------------
  |  |  591|     11|#define AI_RSA_4096			    0x00000008U
  ------------------
  |  Branch (5972:6): [True: 0, False: 11]
  ------------------
 5973|      0|		_sc_card_add_rsa_alg(card, 4096, flags, 0); /* non standard */
 5974|       |
 5975|     11|	if (!(priv->card_issues & CI_NO_EC)) {
  ------------------
  |  |  585|     11|#define CI_NO_EC			    0x00000800U /* No EC at all */
  ------------------
  |  Branch (5975:6): [True: 11, False: 0]
  ------------------
 5976|     11|		int i;
 5977|     11|		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  183|     11|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  182|     11|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
              		flags = SC_ALGORITHM_ECDSA_RAW | SC_ALGORITHM_ECDH_CDH_RAW | SC_ALGORITHM_ECDSA_HASH_NONE;
  ------------------
  |  |  184|     11|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|     11|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
 5978|     11|		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  210|     11|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
              		ext_flags = SC_ALGORITHM_EXT_EC_NAMEDCURVE | SC_ALGORITHM_EXT_EC_UNCOMPRESES;
  ------------------
  |  |  211|     11|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
 5979|     11|		flags_eddsa = SC_ALGORITHM_EDDSA_RAW;
  ------------------
  |  |  197|     11|#define SC_ALGORITHM_EDDSA_RAW		0x00400000
  ------------------
 5980|     11|		flags_xeddsa = SC_ALGORITHM_XEDDSA_RAW;
  ------------------
  |  |  198|     11|#define SC_ALGORITHM_XEDDSA_RAW		0x00800000
  ------------------
 5981|       |
 5982|     55|		for (i = 0; ec_curves[i].oid.value[0] >= 0; i++) {
  ------------------
  |  Branch (5982:15): [True: 44, False: 11]
  ------------------
 5983|     44|			if (ec_curves[i].key_type == SC_ALGORITHM_EC) {
  ------------------
  |  |   79|     44|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (5983:8): [True: 22, False: 22]
  ------------------
 5984|     22|				if (!(priv->card_issues & CI_NO_EC384 && ec_curves[i].size == 384))
  ------------------
  |  |  584|     44|#define CI_NO_EC384			    0x00000400U /* does not have EC 384 */
  ------------------
  |  Branch (5984:11): [True: 0, False: 22]
  |  Branch (5984:46): [True: 0, False: 0]
  ------------------
 5985|     22|					_sc_card_add_ec_alg(card, ec_curves[i].size, flags, ext_flags, &ec_curves[i].oid);
 5986|     22|			}
 5987|       |
 5988|     22|			else if (priv->alg_ids & AI_25519 && ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |  594|     44|#define AI_25519			    0x00100000U
  ------------------
              			else if (priv->alg_ids & AI_25519 && ec_curves[i].key_type == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (5988:13): [True: 0, False: 22]
  |  Branch (5988:41): [True: 0, False: 0]
  ------------------
 5989|      0|				_sc_card_add_eddsa_alg(card, ec_curves[i].size, flags_eddsa, ext_flags, &ec_curves[i].oid);
 5990|       |
 5991|     22|			else if (priv->alg_ids & AI_X25519 && ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |  595|     44|#define AI_X25519			    0x00200000U
  ------------------
              			else if (priv->alg_ids & AI_X25519 && ec_curves[i].key_type == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (5991:13): [True: 0, False: 22]
  |  Branch (5991:42): [True: 0, False: 0]
  ------------------
 5992|      0|				_sc_card_add_xeddsa_alg(card, ec_curves[i].size, flags_xeddsa, ext_flags, &ec_curves[i].oid);
 5993|     44|		}
 5994|     11|	}
 5995|       |
 5996|     11|	if (!(priv->card_issues & CI_NO_RANDOM))
  ------------------
  |  |  575|     11|#define CI_NO_RANDOM			    0x00000004U /* can not use Challenge to get random data or no 9B key */
  ------------------
  |  Branch (5996:6): [True: 11, False: 0]
  ------------------
 5997|     11|		card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|     11|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
 5998|       |
 5999|       |	/* May turn off SC_CARD_CAP_ISO7816_PIN_INFO later */
 6000|     11|	card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|     11|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 6001|       |
 6002|       |	/*
 6003|       |	 * 800-73-3 cards may have discovery. "piv-like cards may or may not.
 6004|       |	 * 800-73-4 with VCI must have it as it has the pin policy needed for VCI .
 6005|       |	 */
 6006|       |
 6007|       |#ifdef ENABLE_PIV_SM
 6008|       |	/*
 6009|       |	 * 800-73-4
 6010|       |	 * Response of AID says if SM is supported. Look for Cipher Suite
 6011|       |	 */
 6012|       |	if (priv->csID && priv->cs != NULL) {
 6013|       |		/*
 6014|       |		 * Main point in SM and VCI is to allow contactless access
 6015|       |		 */
 6016|       |		/* Only piv_init and piv_reader_lock_obtained should call piv_sm_open */
 6017|       |
 6018|       |		/* If user said PIV_SM_FLAGS_NEVER, dont start SM; implies limited contatless access */
 6019|       |		if (priv->sm_flags & PIV_SM_FLAGS_NEVER) {
 6020|       |			sc_log(card->ctx, "User has requested PIV_SM_FLAGS_NEVER");
 6021|       |			r = SC_SUCCESS; /* Users choice */
 6022|       |
 6023|       |		} else if ((priv->init_flags & PIV_INIT_CONTACTLESS) &&
 6024|       |				!(priv->pin_policy & PIV_PP_VCI_IMPL)) {
 6025|       |			sc_log(card->ctx, "Contactless and no card support for VCI");
 6026|       |			r = SC_SUCCESS; /* User should know VCI is not possible with their card; use like 800-73-3 contactless  */
 6027|       |
 6028|       |		} else if ((priv->init_flags & PIV_INIT_CONTACTLESS) &&
 6029|       |				!(priv->pin_policy & PIV_PP_VCI_WITHOUT_PC) &&
 6030|       |				(priv->pairing_code[0] == 0x00)) {
 6031|       |			sc_log(card->ctx, "Contactless, pairing_code required and no pairing code");
 6032|       |			r = SC_ERROR_PIN_CODE_INCORRECT; /* User should know they need to set pairing code */
 6033|       |
 6034|       |		} else {
 6035|       |			priv->sm_flags |= PIV_SM_FLAGS_DEFER_OPEN; /* tell priv_sm_open, OK to open */
 6036|       |			r = piv_sm_open(card);
 6037|       |			sc_log(card->ctx, "piv_sm_open returned:%d", r);
 6038|       |		}
 6039|       |
 6040|       |		/* If failed, and user said PIV_SM_FLAGS_ALWAYS quit */
 6041|       |		if (priv->sm_flags & PIV_SM_FLAGS_ALWAYS && r < 0) {
 6042|       |			sc_log(card->ctx, "User has requested PIV_SM_FLAGS_ALWAYS, SM has failed to start, don't use the card");
 6043|       |			LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_ALLOWED);
 6044|       |		}
 6045|       |
 6046|       |		/* user has wrong or no required pairing code */
 6047|       |		if (r == SC_ERROR_PIN_CODE_INCORRECT)
 6048|       |			LOG_FUNC_RETURN(card->ctx, r);
 6049|       |
 6050|       |		/* If SM did not start, or is not expected to start, continue on without it */
 6051|       |	}
 6052|       |#endif /* ENABLE_PIV_SM */
 6053|       |
 6054|       |	/*
 6055|       |	 * 800-73-3 cards may have a history object
 6056|       |	 * We want to process it now as this has information on what
 6057|       |	 * keys and certs. "piv like" cards may or may not have history
 6058|       |	 */
 6059|     11|	piv_process_history(card);
 6060|       |
 6061|     11|	priv->pstate = PIV_STATE_NORMAL;
 6062|     11|	sc_unlock(card);
 6063|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6064|     11|}
card-piv.c:piv_load_options:
 1674|     11|{
 1675|     11|	int r;
 1676|     11|	size_t i, j;
 1677|     11|	scconf_block **found_blocks, *block;
 1678|       |
 1679|       |#ifdef ENABLE_PIV_SM
 1680|       |	piv_private_data_t *priv = PIV_DATA(card);
 1681|       |	const char *option = NULL;
 1682|       |	int piv_pairing_code_found = 0;
 1683|       |	int piv_use_sm_found = 0;
 1684|       |
 1685|       |	/* pairing code is 8 decimal digits and is card specific */
 1686|       |	if ((option = getenv("PIV_PAIRING_CODE")) != NULL) {
 1687|       |		sc_log(card->ctx, "getenv(\"PIV_PAIRING_CODE\") found");
 1688|       |		if (piv_parse_pairing_code(card, option) == SC_SUCCESS) {
 1689|       |			memcpy(priv->pairing_code, option, PIV_PAIRING_CODE_LEN);
 1690|       |			piv_pairing_code_found = 1;
 1691|       |		}
 1692|       |	}
 1693|       |
 1694|       |	if ((option = getenv("PIV_USE_SM")) != NULL) {
 1695|       |		sc_log(card->ctx, "getenv(\"PIV_USE_SM\")=\"%s\"", option);
 1696|       |		if (!strcmp(option, "never")) {
 1697|       |			priv->sm_flags |= PIV_SM_FLAGS_NEVER;
 1698|       |			piv_use_sm_found = 1;
 1699|       |		} else if (!strcmp(option, "always")) {
 1700|       |			priv->sm_flags |= PIV_SM_FLAGS_ALWAYS;
 1701|       |			piv_use_sm_found = 1;
 1702|       |		} else {
 1703|       |			sc_log(card->ctx, "Invalid piv_use_sm: \"%s\"", option);
 1704|       |		}
 1705|       |	}
 1706|       |#endif
 1707|       |
 1708|     22|	for (i = 0; card->ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (1708:14): [True: 11, False: 11]
  ------------------
 1709|     11|		found_blocks = scconf_find_blocks(card->ctx->conf, card->ctx->conf_blocks[i],
 1710|     11|				"card_driver", "PIV-II");
 1711|     11|		if (!found_blocks)
  ------------------
  |  Branch (1711:7): [True: 0, False: 11]
  ------------------
 1712|      0|			continue;
 1713|       |
 1714|     11|		for (j = 0, block = found_blocks[j]; block; j++, block = found_blocks[j]) {
  ------------------
  |  Branch (1714:40): [True: 0, False: 11]
  ------------------
 1715|       |
 1716|       |#ifdef ENABLE_PIV_SM
 1717|       |			/*
 1718|       |			 * "piv_use_sm" if card supports NIST sp800-73-4 sm, when should it be used
 1719|       |			 * never - use card like 800-73-3, i.e. contactless is very limited on
 1720|       |			 * true PIV cards. Some  PIV-like" card may allow this.
 1721|       |			 * this security risk
 1722|       |			 * always - Use even for contact interface.
 1723|       |			 * PINS, crypto and reading of object will not show up in logs
 1724|       |			 * or over network.
 1725|       |			 */
 1726|       |
 1727|       |			if (piv_use_sm_found == 0) {
 1728|       |				option = scconf_get_str(block, "piv_use_sm", "default");
 1729|       |				sc_log(card->ctx, "conf: \"piv_use_sm\"=\"%s\"", option);
 1730|       |				if (!strcmp(option, "default")) {
 1731|       |					/* no new flags */
 1732|       |				} else if (!strcmp(option, "never")) {
 1733|       |					priv->sm_flags |= PIV_SM_FLAGS_NEVER;
 1734|       |				} else if (!strcmp(option, "always")) {
 1735|       |					priv->sm_flags |= PIV_SM_FLAGS_ALWAYS;
 1736|       |				} else {
 1737|       |					sc_log(card->ctx, "Invalid piv_use_sm: \"%s\"", option);
 1738|       |				}
 1739|       |			}
 1740|       |
 1741|       |			/* This is really a card specific value and should not be in the conf file */
 1742|       |			if (piv_pairing_code_found == 0) {
 1743|       |				option = scconf_get_str(block, "piv_pairing_code", NULL);
 1744|       |				if (option && piv_parse_pairing_code(card, option) == SC_SUCCESS) {
 1745|       |					memcpy(priv->pairing_code, option, PIV_PAIRING_CODE_LEN);
 1746|       |				}
 1747|       |			}
 1748|       |#endif
 1749|      0|		}
 1750|     11|		free(found_blocks);
 1751|     11|	}
 1752|     11|	r = SC_SUCCESS;
  ------------------
  |  |   28|     11|#define SC_SUCCESS				0
  ------------------
 1753|     11|	return r;
 1754|     11|}
card-piv.c:piv_process_history:
 5110|     11|{
 5111|     11|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|     11|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5112|     11|	int r;
 5113|     11|	int i, tmplen, tmplen2, tmplen3;
 5114|     11|	int enumtag;
 5115|     11|	u8 *rbuf = NULL;
 5116|     11|	size_t rbuflen = 0;
 5117|     11|	const u8 *body;
 5118|     11|	size_t bodylen;
 5119|     11|	const u8 *num;
 5120|     11|	size_t numlen;
 5121|     11|	const u8 *url = NULL;
 5122|     11|	size_t urllen;
 5123|     11|	u8 *ocfhfbuf = NULL;
 5124|     11|	unsigned int cla_out, tag_out;
 5125|     11|	size_t ocfhflen;
 5126|     11|	const u8 *seq;
 5127|     11|	const u8 *seqtag;
 5128|     11|	size_t seqlen;
 5129|     11|	const u8 *keyref;
 5130|     11|	size_t keyreflen;
 5131|     11|	const u8 *cert;
 5132|     11|	size_t certlen;
 5133|     11|	size_t certobjlen, i2;
 5134|     11|	u8 *certobj;
 5135|     11|	u8 *cp;
 5136|       |
 5137|     11|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     11|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     11|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     11|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 11]
  |  |  ------------------
  ------------------
 5138|       |
 5139|     11|	r = piv_get_cached_data(card, PIV_OBJ_HISTORY, &rbuf, &rbuflen);
 5140|     11|	if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|     11|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (5140:6): [True: 0, False: 11]
  ------------------
 5141|      0|		r = 0; /* OK if not found */
 5142|     11|	if (r <= 0) {
  ------------------
  |  Branch (5142:6): [True: 4, False: 7]
  ------------------
 5143|      4|		priv->obj_cache[PIV_OBJ_HISTORY].flags |= PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  150|      4|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5144|      4|		goto err; /* no file, must be pre 800-73-3 card and not on card */
 5145|      4|	}
 5146|       |
 5147|       |	/* the object is now cached, see what we have */
 5148|      7|	if (rbuflen != 0) {
  ------------------
  |  Branch (5148:6): [True: 7, False: 0]
  ------------------
 5149|      7|		body = rbuf;
 5150|      7|		if ((r = sc_asn1_read_tag(&body, rbuflen, &cla_out, &tag_out, &bodylen)) != SC_SUCCESS ||
  ------------------
  |  |   28|     14|#define SC_SUCCESS				0
  ------------------
  |  Branch (5150:7): [True: 0, False: 7]
  ------------------
 5151|      7|				((cla_out << 24 | tag_out) != piv_objects[PIV_OBJ_HISTORY].resp_tag)) {
  ------------------
  |  Branch (5151:5): [True: 0, False: 7]
  ------------------
 5152|      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__
  |  |  ------------------
  ------------------
 5153|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5154|      0|			goto err;
 5155|      0|		}
 5156|       |
 5157|      7|		if (body != NULL && bodylen != 0) {
  ------------------
  |  Branch (5157:7): [True: 7, False: 0]
  |  Branch (5157:23): [True: 7, False: 0]
  ------------------
 5158|      7|			numlen = 0;
 5159|      7|			num = sc_asn1_find_tag(card->ctx, body, bodylen, 0xC1, &numlen);
 5160|      7|			if (num) {
  ------------------
  |  Branch (5160:8): [True: 0, False: 7]
  ------------------
 5161|      0|				if (numlen != 1 || *num > PIV_OBJ_RETIRED_X509_20 - PIV_OBJ_RETIRED_X509_1 + 1) {
  ------------------
  |  Branch (5161:9): [True: 0, False: 0]
  |  Branch (5161:24): [True: 0, False: 0]
  ------------------
 5162|      0|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5163|      0|					goto err;
 5164|      0|				}
 5165|       |
 5166|      0|				priv->keysWithOnCardCerts = *num;
 5167|      0|			}
 5168|       |
 5169|      7|			numlen = 0;
 5170|      7|			num = sc_asn1_find_tag(card->ctx, body, bodylen, 0xC2, &numlen);
 5171|      7|			if (num) {
  ------------------
  |  Branch (5171:8): [True: 0, False: 7]
  ------------------
 5172|      0|				if (numlen != 1 || *num > PIV_OBJ_RETIRED_X509_20 - PIV_OBJ_RETIRED_X509_1 + 1) {
  ------------------
  |  Branch (5172:9): [True: 0, False: 0]
  |  Branch (5172:24): [True: 0, False: 0]
  ------------------
 5173|      0|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5174|      0|					goto err;
 5175|      0|				}
 5176|       |
 5177|      0|				priv->keysWithOffCardCerts = *num;
 5178|      0|			}
 5179|       |
 5180|      7|			url = sc_asn1_find_tag(card->ctx, body, bodylen, 0xF3, &urllen);
 5181|      7|			if (url) {
  ------------------
  |  Branch (5181:8): [True: 6, False: 1]
  ------------------
 5182|      6|				if (urllen > 118) {
  ------------------
  |  Branch (5182:9): [True: 0, False: 6]
  ------------------
 5183|      0|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5184|      0|					goto err;
 5185|      0|				}
 5186|      6|				priv->offCardCertURL = calloc(1, urllen + 1);
 5187|      6|				if (priv->offCardCertURL == NULL)
  ------------------
  |  Branch (5187:9): [True: 0, False: 6]
  ------------------
 5188|      6|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5189|      6|				memcpy(priv->offCardCertURL, url, urllen);
 5190|      6|			}
 5191|      7|		} else {
 5192|      0|			sc_log(card->ctx, "Problem with History object\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__
  |  |  ------------------
  ------------------
 5193|      0|			r = SC_SUCCESS; /* OK if not found */
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 5194|      0|			goto err;
 5195|      0|		}
 5196|      7|	}
 5197|      7|	sc_log(card->ctx, "History on=%d off=%d URL=%s",
  ------------------
  |  |   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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 6, False: 1]
  |  |  ------------------
  ------------------
 5198|      7|			priv->keysWithOnCardCerts, priv->keysWithOffCardCerts,
 5199|      7|			priv->offCardCertURL ? priv->offCardCertURL : "NONE");
 5200|       |
 5201|       |	/* now mark what objects are on the card */
 5202|      7|	for (i = 0; i < priv->keysWithOnCardCerts; i++)
  ------------------
  |  Branch (5202:14): [True: 0, False: 7]
  ------------------
 5203|      0|		priv->obj_cache[PIV_OBJ_RETIRED_X509_1 + i].flags &= ~PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  150|      7|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5204|       |
 5205|       |	/*
 5206|       |	 * If user has gotten copy of the file from the offCardCertsURL,
 5207|       |	 * we will read in and add the certs to the cache as listed on
 5208|       |	 * the card. some of the certs may be on the card as well.
 5209|       |	 *
 5210|       |	 * Get file name from url. verify that the filename is valid
 5211|       |	 * The URL ends in a SHA-256 string. We will use this as the filename
 5212|       |	 * in the directory used for the  PKCS15 cache
 5213|       |	 * "http://" <DNS name> "/" <ASCII-HEX encoded SHA-256 hash of OffCardKeyHistoryFile>
 5214|       |	 */
 5215|       |
 5216|      7|	r = 0;
 5217|      7|	if (priv->offCardCertURL) {
  ------------------
  |  Branch (5217:6): [True: 6, False: 1]
  ------------------
 5218|      6|		char *fp;
 5219|      6|		char filename[PATH_MAX];
 5220|       |
 5221|      6|		if (strncmp("http://", priv->offCardCertURL, 7)) {
  ------------------
  |  Branch (5221:7): [True: 6, False: 0]
  ------------------
 5222|      6|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      6|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5223|      6|			goto err;
 5224|      6|		}
 5225|       |		/* find the last /  so we have the filename part */
 5226|      0|		fp = strrchr(priv->offCardCertURL + 7, '/');
 5227|      0|		if (fp == NULL) {
  ------------------
  |  Branch (5227:7): [True: 0, False: 0]
  ------------------
 5228|      0|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5229|      0|			goto err;
 5230|      0|		}
 5231|      0|		fp++;
 5232|      0|		if (strlen(fp) != 64) { /* ASCII-HEX encoded SHA-256 */
  ------------------
  |  Branch (5232:7): [True: 0, False: 0]
  ------------------
 5233|      0|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5234|      0|			goto err;
 5235|      0|		}
 5236|      0|		for (i = 0; i < 64; i++) {
  ------------------
  |  Branch (5236:15): [True: 0, False: 0]
  ------------------
 5237|      0|			if (isxdigit((unsigned char)fp[i]) == 0) {
  ------------------
  |  Branch (5237:8): [True: 0, False: 0]
  ------------------
 5238|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
 5239|      0|				goto err;
 5240|      0|			}
 5241|      0|		}
 5242|       |
 5243|       |		/* Use the same directory as used for other OpenSC cached items */
 5244|      0|		r = sc_get_cache_dir(card->ctx, filename, sizeof(filename) - strlen(fp) - 2);
 5245|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5245:7): [True: 0, False: 0]
  ------------------
 5246|      0|			goto err;
 5247|       |#ifdef _WIN32
 5248|       |		strlcat(filename, "\\", PATH_MAX);
 5249|       |#else
 5250|      0|		strlcat(filename, "/", PATH_MAX);
 5251|      0|#endif
 5252|      0|		strlcat(filename, fp, PATH_MAX);
 5253|       |
 5254|      0|		r = piv_read_obj_from_file(card, filename,
 5255|      0|				&ocfhfbuf, &ocfhflen);
 5256|      0|		if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (5256:7): [True: 0, False: 0]
  ------------------
 5257|      0|			r = 0;
 5258|      0|			goto err;
 5259|      0|		}
 5260|       |
 5261|       |		/*
 5262|       |		 * Its a seq of seq of a key ref and cert
 5263|       |		 */
 5264|       |
 5265|      0|		body = ocfhfbuf;
 5266|      0|		if (sc_asn1_read_tag(&body, ocfhflen, &cla_out, &tag_out, &bodylen) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5266:7): [True: 0, False: 0]
  ------------------
 5267|      0|				body == NULL ||
  ------------------
  |  Branch (5267:5): [True: 0, False: 0]
  ------------------
 5268|      0|				bodylen == 0 ||
  ------------------
  |  Branch (5268:5): [True: 0, False: 0]
  ------------------
 5269|      0|				(cla_out | tag_out) != 0x30) {
  ------------------
  |  Branch (5269:5): [True: 0, False: 0]
  ------------------
 5270|      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__
  |  |  ------------------
  ------------------
 5271|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5272|      0|			goto err;
 5273|      0|		}
 5274|      0|		seq = body;
 5275|      0|		while (bodylen > 0) {
  ------------------
  |  Branch (5275:10): [True: 0, False: 0]
  ------------------
 5276|      0|			seqtag = seq;
 5277|      0|			if (sc_asn1_read_tag(&seq, bodylen, &cla_out, &tag_out, &seqlen) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5277:8): [True: 0, False: 0]
  ------------------
 5278|      0|					seq == 0 ||
  ------------------
  |  Branch (5278:6): [True: 0, False: 0]
  ------------------
 5279|      0|					seqlen == 0 ||
  ------------------
  |  Branch (5279:6): [True: 0, False: 0]
  ------------------
 5280|      0|					(cla_out | tag_out) != 0x30) {
  ------------------
  |  Branch (5280:6): [True: 0, False: 0]
  ------------------
 5281|      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__
  |  |  ------------------
  ------------------
 5282|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5283|      0|				goto err;
 5284|      0|			}
 5285|      0|			keyref = sc_asn1_find_tag(card->ctx, seq, seqlen, 0x04, &keyreflen);
 5286|      0|			if (!keyref || keyreflen != 1 ||
  ------------------
  |  Branch (5286:8): [True: 0, False: 0]
  |  Branch (5286:19): [True: 0, False: 0]
  ------------------
 5287|      0|					(*keyref < 0x82 || *keyref > 0x95)) {
  ------------------
  |  Branch (5287:7): [True: 0, False: 0]
  |  Branch (5287:25): [True: 0, False: 0]
  ------------------
 5288|      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__
  |  |  ------------------
  ------------------
 5289|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5290|      0|				goto err;
 5291|      0|			}
 5292|      0|			cert = keyref + keyreflen;
 5293|      0|			certlen = seqlen - (cert - seq);
 5294|       |
 5295|      0|			enumtag = PIV_OBJ_RETIRED_X509_1 + *keyref - 0x82;
 5296|       |			/* now add the cert like another object */
 5297|       |
 5298|      0|			if ((tmplen = sc_asn1_put_tag(0x70, NULL, certlen, NULL, 0, NULL)) <= 0 ||
  ------------------
  |  Branch (5298:8): [True: 0, False: 0]
  ------------------
 5299|      0|					(tmplen2 = sc_asn1_put_tag(0x71, NULL, 1, NULL, 0, NULL)) <= 0 ||
  ------------------
  |  Branch (5299:6): [True: 0, False: 0]
  ------------------
 5300|      0|					(tmplen3 = sc_asn1_put_tag(0xFE, NULL, 0, NULL, 0, NULL)) <= 0) {
  ------------------
  |  Branch (5300:6): [True: 0, False: 0]
  ------------------
 5301|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5302|      0|				goto err;
 5303|      0|			}
 5304|      0|			i2 = tmplen + tmplen2 + tmplen3;
 5305|      0|			tmplen = sc_asn1_put_tag(0x53, NULL, i2, NULL, 0, NULL);
 5306|      0|			if (tmplen <= 0) {
  ------------------
  |  Branch (5306:8): [True: 0, False: 0]
  ------------------
 5307|      0|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 5308|      0|				goto err;
 5309|      0|			}
 5310|       |
 5311|      0|			certobjlen = tmplen;
 5312|      0|			certobj = malloc(certobjlen);
 5313|      0|			if (certobj == NULL) {
  ------------------
  |  Branch (5313:8): [True: 0, False: 0]
  ------------------
 5314|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 5315|      0|				goto err;
 5316|      0|			}
 5317|      0|			cp = certobj;
 5318|      0|			if ((r = sc_asn1_put_tag(0x53, NULL, i2, cp, certobjlen, &cp)) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5318:8): [True: 0, False: 0]
  ------------------
 5319|      0|					(r = sc_asn1_put_tag(0x70, cert, certlen, cp, certobjlen - (cp - certobj), &cp)) != SC_SUCCESS ||
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5319:6): [True: 0, False: 0]
  ------------------
 5320|      0|					(r = sc_asn1_put_tag(0x71, NULL, 1, cp, certobjlen - (cp - certobj), &cp)) != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5320:6): [True: 0, False: 0]
  ------------------
 5321|      0|				goto err;
 5322|      0|			}
 5323|      0|			*cp++ = 0x00;
 5324|      0|			r = sc_asn1_put_tag(0xFE, NULL, 0, cp, certobjlen - (cp - certobj), &cp);
 5325|      0|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (5325:8): [True: 0, False: 0]
  ------------------
 5326|      0|				goto err;
 5327|      0|			}
 5328|       |
 5329|      0|			priv->obj_cache[enumtag].obj_data = certobj;
 5330|      0|			priv->obj_cache[enumtag].obj_len = certobjlen;
 5331|      0|			priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
  ------------------
  |  |  148|      0|#define PIV_OBJ_CACHE_VALID		1
  ------------------
 5332|      0|			priv->obj_cache[enumtag].flags &= ~PIV_OBJ_CACHE_NOT_PRESENT;
  ------------------
  |  |  150|      0|#define PIV_OBJ_CACHE_NOT_PRESENT	8
  ------------------
 5333|       |
 5334|      0|			r = piv_cache_internal_data(card, enumtag);
 5335|      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__
  |  |  ------------------
  ------------------
 5336|       |
 5337|      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__
  |  |  ------------------
  ------------------
 5338|      0|					"Added from off card file #%d %p:%" SC_FORMAT_LEN_SIZE_T "u 0x%02X",
 5339|      0|					enumtag,
 5340|      0|					priv->obj_cache[enumtag].obj_data,
 5341|      0|					priv->obj_cache[enumtag].obj_len, *keyref);
 5342|       |
 5343|      0|			bodylen -= (seqlen + seq - seqtag);
 5344|      0|			seq += seqlen;
 5345|      0|		}
 5346|      0|	}
 5347|     11|err:
 5348|     11|	if (ocfhfbuf)
  ------------------
  |  Branch (5348:6): [True: 0, False: 11]
  ------------------
 5349|      0|		free(ocfhfbuf);
 5350|     11|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|     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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 5351|     11|}
card-piv.c:piv_finish:
 5374|  1.40k|{
 5375|  1.40k|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|  1.40k|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 5376|  1.40k|	int i;
 5377|       |
 5378|  1.40k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.40k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.40k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.40k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.40k]
  |  |  ------------------
  ------------------
 5379|  1.40k|	if (priv) {
  ------------------
  |  Branch (5379:6): [True: 707, False: 696]
  ------------------
 5380|    707|		if (priv->context_specific) {
  ------------------
  |  Branch (5380:7): [True: 0, False: 707]
  ------------------
 5381|      0|			sc_log(card->ctx, "Clearing CONTEXT_SPECIFIC 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__
  |  |  ------------------
  ------------------
 5382|      0|			priv->context_specific = 0;
 5383|      0|			sc_unlock(card);
 5384|      0|		}
 5385|    707|		free(priv->aid_der.value);
 5386|    707|		free(priv->al_label);
 5387|    707|		if (priv->w_buf)
  ------------------
  |  Branch (5387:7): [True: 0, False: 707]
  ------------------
 5388|      0|			free(priv->w_buf);
 5389|    707|		if (priv->offCardCertURL)
  ------------------
  |  Branch (5389:7): [True: 6, False: 701]
  ------------------
 5390|      6|			free(priv->offCardCertURL);
 5391|  43.1k|		for (i = 0; i < PIV_OBJ_LAST_ENUM - 1; i++) {
  ------------------
  |  Branch (5391:15): [True: 42.4k, False: 707]
  ------------------
 5392|  42.4k|			piv_obj_cache_free_entry(card, i, 0);
 5393|  42.4k|		}
 5394|       |#ifdef ENABLE_PIV_SM
 5395|       |		piv_clear_cvc_content(&priv->sm_cvc);
 5396|       |		piv_clear_cvc_content(&priv->sm_in_cvc);
 5397|       |		piv_clear_sm_session(&priv->sm_session);
 5398|       |#endif /* ENABLE_PIV_SM */
 5399|       |
 5400|    707|		free(priv);
 5401|       |		card->drv_data = NULL; /* priv */
 5402|    707|	}
 5403|  1.40k|	return 0;
 5404|  1.40k|}
card-piv.c:piv_check_sw:
 6068|    749|{
 6069|    749|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 6070|       |
 6071|    749|	int r;
 6072|       |#ifdef ENABLE_PIV_SM
 6073|       |	int i;
 6074|       |#endif
 6075|    749|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|    749|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6076|       |
 6077|    749|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    749|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    749|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    749|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 749]
  |  |  ------------------
  ------------------
 6078|       |
 6079|       |	/* may be called before piv_init has allocated priv */
 6080|    749|	if (priv) {
  ------------------
  |  Branch (6080:6): [True: 749, False: 0]
  ------------------
 6081|       |		/* need to save sw1 and sw2 if trying to determine card_state from pin_cmd */
 6082|       |
 6083|    749|		if (priv->pin_cmd_verify) {
  ------------------
  |  Branch (6083:7): [True: 0, False: 749]
  ------------------
 6084|      0|			priv->pin_cmd_verify_sw1 = sw1;
 6085|      0|			priv->pin_cmd_verify_sw2 = sw2;
 6086|    749|		} else {
 6087|       |			/* a command has completed and it is not verify
 6088|       |			 * If we are in a context_specific sequence, unlock
 6089|       |			 * This just decrements the extra lock count
 6090|       |			 */
 6091|    749|			if (priv->context_specific) {
  ------------------
  |  Branch (6091:8): [True: 0, False: 749]
  ------------------
 6092|      0|				sc_log(card->ctx, "Clearing CONTEXT_SPECIFIC 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__
  |  |  ------------------
  ------------------
 6093|      0|				priv->context_specific = 0;
 6094|      0|				sc_unlock(card);
 6095|      0|			}
 6096|    749|		}
 6097|       |
 6098|    749|		if (priv->card_issues & CI_VERIFY_630X) {
  ------------------
  |  |  572|    749|#define CI_VERIFY_630X			    0x00000001U /* VERIFY tries left returns 630X rather then 63CX */
  ------------------
  |  Branch (6098:7): [True: 0, False: 749]
  ------------------
 6099|       |
 6100|       |			/* Handle the Yubikey NEO or any other PIV card which returns in response to a verify
 6101|       |			 * 63 0X rather than 63 CX indicate the number of remaining PIN retries.
 6102|       |			 * Perhaps they misread the spec and thought 0xCX meant "clear" or "don't care", not a literal 0xC!
 6103|       |			 */
 6104|      0|			if (priv->pin_cmd_verify && sw1 == 0x63U) {
  ------------------
  |  Branch (6104:8): [True: 0, False: 0]
  |  Branch (6104:32): [True: 0, False: 0]
  ------------------
 6105|      0|				priv->pin_cmd_verify_sw2 |= 0xC0U; /* make it easier to test in other code */
 6106|      0|				if ((sw2 & ~0x0fU) == 0x00U) {
  ------------------
  |  Branch (6106:9): [True: 0, False: 0]
  ------------------
 6107|      0|					sc_log(card->ctx, "Verification failed (remaining tries: %d)", (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__
  |  |  ------------------
  ------------------
 6108|      0|					return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      0|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
 6109|       |					/* this is what the iso_check_sw returns for 63 C0 */
 6110|      0|				}
 6111|      0|			}
 6112|      0|		}
 6113|    749|	}
 6114|       |#ifdef ENABLE_PIV_SM
 6115|       |	/* Note 6982 is map to SC_ERROR_SM_NO_SESSION_KEYS but iso maps it to SC_ERROR_SECURITY_STATUS_NOT_SATISFIED */
 6116|       |	/* we do this because 6982 could also mean a verify is not allowed over contactless without VCI */
 6117|       |	/* we stashed the sw1 and sw2 above for verify */
 6118|       |	/* Check specific NIST sp800-73-4 SM  errors */
 6119|       |	for (i = 0; piv_sm_errors[i].SWs != 0; i++) {
 6120|       |		if (piv_sm_errors[i].SWs == ((sw1 << 8) | sw2)) {
 6121|       |			sc_log(card->ctx, "%s", piv_sm_errors[i].errorstr);
 6122|       |			return piv_sm_errors[i].errorno;
 6123|       |		}
 6124|       |	}
 6125|       |#endif
 6126|    749|	r = iso_drv->ops->check_sw(card, sw1, sw2);
 6127|    749|	return r;
 6128|    749|}
card-piv.c:piv_card_ctl:
 4482|     11|{
 4483|     11|	piv_private_data_t *priv = PIV_DATA(card);
  ------------------
  |  |  432|     11|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 4484|     11|	u8 *opts; /*  A or M, key_ref, alg_id */
 4485|       |
 4486|     11|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     11|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     11|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     11|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     11|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4487|       |
 4488|     11|	if (priv == NULL) {
  ------------------
  |  Branch (4488:6): [True: 0, False: 11]
  ------------------
 4489|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4490|      0|	}
 4491|     11|	switch (cmd) {
  ------------------
  |  Branch (4491:10): [True: 0, False: 11]
  ------------------
 4492|      0|	case SC_CARDCTL_PIV_AUTHENTICATE:
  ------------------
  |  Branch (4492:2): [True: 0, False: 11]
  ------------------
 4493|      0|		opts = (u8 *)ptr;
 4494|      0|		switch (*opts) {
  ------------------
  |  Branch (4494:11): [True: 0, False: 0]
  ------------------
 4495|      0|		case 'A':
  ------------------
  |  Branch (4495:3): [True: 0, False: 0]
  ------------------
 4496|      0|			return piv_general_external_authenticate(card,
 4497|      0|					*(opts + 1), *(opts + 2));
 4498|      0|			break;
 4499|      0|		case 'M':
  ------------------
  |  Branch (4499:3): [True: 0, False: 0]
  ------------------
 4500|      0|			return piv_general_mutual_authenticate(card,
 4501|      0|					*(opts + 1), *(opts + 2));
 4502|      0|			break;
 4503|      0|		}
 4504|      0|		break;
 4505|      0|	case SC_CARDCTL_PIV_GENERATE_KEY:
  ------------------
  |  Branch (4505:2): [True: 0, False: 11]
  ------------------
 4506|      0|		return piv_generate_key(card,
 4507|      0|				(sc_cardctl_piv_genkey_info_t *)ptr);
 4508|      0|		break;
 4509|      0|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (4509:2): [True: 0, False: 11]
  ------------------
 4510|      0|		return piv_get_serial_nr_from_CHUI(card, (sc_serial_number_t *)ptr);
 4511|      0|		break;
 4512|      0|	case SC_CARDCTL_PIV_PIN_PREFERENCE:
  ------------------
  |  Branch (4512:2): [True: 0, False: 11]
  ------------------
 4513|      0|		return piv_get_pin_preference(card, ptr);
 4514|      0|		break;
 4515|      0|	case SC_CARDCTL_PIV_OBJECT_PRESENT:
  ------------------
  |  Branch (4515:2): [True: 0, False: 11]
  ------------------
 4516|      0|		return piv_is_object_present(card, ptr);
 4517|      0|		break;
 4518|     11|	}
 4519|       |
 4520|     11|	LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4521|     11|}
card-piv.c:piv_card_reader_lock_obtained:
 6375|    718|{
 6376|    718|	int r = 0;
 6377|    718|	u8 temp[SC_MAX_APDU_BUFFER_SIZE];
 6378|    718|	size_t templen = sizeof(temp);
 6379|    718|	piv_private_data_t *priv = PIV_DATA(card); /* may be null */
  ------------------
  |  |  432|    718|#define PIV_DATA(card) ((piv_private_data_t*)card->drv_data)
  ------------------
 6380|       |
 6381|    718|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    718|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    718|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    718|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 718]
  |  |  ------------------
  ------------------
 6382|       |
 6383|       |	/* We have a PCSC transaction and sc_lock */
 6384|    718|	if (priv == NULL || priv->pstate == PIV_STATE_MATCH) {
  ------------------
  |  Branch (6384:6): [True: 707, False: 11]
  |  Branch (6384:22): [True: 11, False: 0]
  ------------------
 6385|    718|		sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE,
  ------------------
  |  |   70|  1.43k|#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: 11, False: 707]
  |  |  ------------------
  ------------------
 6386|    718|				priv ? "PIV_STATE_MATCH" : "priv==NULL");
 6387|    718|		r = 0; /* do nothing, piv_match will take care of it */
 6388|    718|		goto err;
 6389|    718|	}
 6390|       |
 6391|      0|	priv->init_flags |= PIV_INIT_IN_READER_LOCK_OBTAINED;
  ------------------
  |  |  381|      0|#define PIV_INIT_IN_READER_LOCK_OBTAINED	0x00000010u
  ------------------
 6392|       |
 6393|       |	/* make sure our application is active */
 6394|       |
 6395|       |	/* first see if AID is active AID by reading discovery object '7E' */
 6396|       |	/* If not try selecting AID */
 6397|       |
 6398|       |	/* but if card does not support DISCOVERY object we can not use it */
 6399|      0|	if (priv->card_issues & CI_DISCOVERY_USELESS) {
  ------------------
  |  |  578|      0|#define CI_DISCOVERY_USELESS		    0x00000020U /* Discovery can not be used to query active AID invalid or no data returned */
  ------------------
  |  Branch (6399:6): [True: 0, False: 0]
  ------------------
 6400|      0|		r = SC_ERROR_NO_CARD_SUPPORT;
  ------------------
  |  |   58|      0|#define SC_ERROR_NO_CARD_SUPPORT		-1208
  ------------------
 6401|      0|	} else {
 6402|      0|		r = piv_find_discovery(card);
 6403|       |#ifdef ENABLE_PIV_SM
 6404|       |		/*
 6405|       |		 * All 800-73-4 cards that support SM, also have a discovery object with
 6406|       |		 * the pin_policy, so can not have CI_DISCOVERY_USELESS
 6407|       |		 * Discovery object can be read with contact or contactless
 6408|       |		 * If read with SM and fails with 69 88  SC_ERROR_SM_INVALID_SESSION_KEY
 6409|       |		 * sm.c will close the SM connectrion, and set defer
 6410|       |		 */
 6411|       |		if (was_reset == 0 && (r == SC_ERROR_SM_INVALID_SESSION_KEY || priv->sm_flags & PIV_SM_FLAGS_DEFER_OPEN)) {
 6412|       |			sc_log(card->ctx, "SC_ERROR_SM_INVALID_SESSION_KEY || PIV_SM_FLAGS_DEFER_OPEN");
 6413|       |			piv_sm_open(card);
 6414|       |			r = piv_find_discovery(card);
 6415|       |		}
 6416|       |#endif /* ENABLE_PIV_SM */
 6417|      0|	}
 6418|       |
 6419|      0|	if (r < 0) {
  ------------------
  |  Branch (6419:6): [True: 0, False: 0]
  ------------------
 6420|      0|		if (was_reset > 0 || !(priv->card_issues & CI_PIV_AID_LOSE_STATE)) {
  ------------------
  |  |  579|      0|#define CI_PIV_AID_LOSE_STATE		    0x00000040U /* PIV AID can lose the login state run with out it*/
  ------------------
  |  Branch (6420:7): [True: 0, False: 0]
  |  Branch (6420:24): [True: 0, False: 0]
  ------------------
 6421|      0|			r = iso7816_select_aid(card, piv_aids[0].value, piv_aids[0].len_short, temp, &templen);
 6422|      0|			sc_debug(card->ctx, SC_LOG_DEBUG_MATCH, "iso7816_select_aid card->type:%d r:%d\n", card->type, 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__
  |  |  ------------------
  ------------------
 6423|      0|		} else {
 6424|      0|			r = 0; /* can't do anything with this card, hope there was no interference */
 6425|      0|		}
 6426|      0|	}
 6427|       |
 6428|      0|	if (r < 0) /* bad error return will show up in sc_lock as error*/
  ------------------
  |  Branch (6428:6): [True: 0, False: 0]
  ------------------
 6429|      0|		goto err;
 6430|       |
 6431|      0|	if (was_reset > 0)
  ------------------
  |  Branch (6431:6): [True: 0, False: 0]
  ------------------
 6432|      0|		priv->logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  437|      0|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
 6433|       |
 6434|      0|	r = 0;
 6435|       |
 6436|    718|err:
 6437|    718|	if (priv)
  ------------------
  |  Branch (6437:6): [True: 11, False: 707]
  ------------------
 6438|     11|		priv->init_flags &= ~PIV_INIT_IN_READER_LOCK_OBTAINED;
  ------------------
  |  |  381|     11|#define PIV_INIT_IN_READER_LOCK_OBTAINED	0x00000010u
  ------------------
 6439|    718|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    718|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    718|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    718|	int _ret = r; \
  |  |  |  |  155|    718|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 718, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    718|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 718]
  |  |  |  |  ------------------
  |  |  |  |  157|    718|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    718|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    718|	return _ret; \
  |  |  |  |  163|    718|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 6440|    718|}

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

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

sc_get_sc_hsm_driver:
 1976|  3.69k|{
 1977|  3.69k|	return sc_get_driver();
 1978|  3.69k|}
card-sc-hsm.c:sc_get_driver:
 1940|  3.69k|{
 1941|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1942|       |
 1943|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1943:6): [True: 1, False: 3.69k]
  ------------------
 1944|      1|		iso_ops = iso_drv->ops;
 1945|       |
 1946|  3.69k|	sc_hsm_ops                   = *iso_drv->ops;
 1947|  3.69k|	sc_hsm_ops.match_card        = sc_hsm_match_card;
 1948|  3.69k|	sc_hsm_ops.select_file       = sc_hsm_select_file;
 1949|  3.69k|	sc_hsm_ops.get_challenge     = sc_hsm_get_challenge;
 1950|  3.69k|	sc_hsm_ops.read_binary       = sc_hsm_read_binary;
 1951|  3.69k|	sc_hsm_ops.update_binary     = sc_hsm_update_binary;
 1952|  3.69k|	sc_hsm_ops.list_files        = sc_hsm_list_files;
 1953|  3.69k|	sc_hsm_ops.create_file       = sc_hsm_create_file;
 1954|  3.69k|	sc_hsm_ops.delete_file       = sc_hsm_delete_file;
 1955|  3.69k|	sc_hsm_ops.set_security_env  = sc_hsm_set_security_env;
 1956|  3.69k|	sc_hsm_ops.compute_signature = sc_hsm_compute_signature;
 1957|  3.69k|	sc_hsm_ops.decipher          = sc_hsm_decipher;
 1958|  3.69k|	sc_hsm_ops.init              = sc_hsm_init;
 1959|  3.69k|	sc_hsm_ops.finish            = sc_hsm_finish;
 1960|  3.69k|	sc_hsm_ops.card_ctl          = sc_hsm_card_ctl;
 1961|  3.69k|	sc_hsm_ops.pin_cmd           = sc_hsm_pin_cmd;
 1962|  3.69k|	sc_hsm_ops.logout            = sc_hsm_logout;
 1963|       |
 1964|       |	/* no record oriented file services */
 1965|  3.69k|	sc_hsm_ops.read_record       = NULL;
 1966|  3.69k|	sc_hsm_ops.write_record      = NULL;
 1967|  3.69k|	sc_hsm_ops.append_record     = NULL;
 1968|  3.69k|	sc_hsm_ops.update_record     = NULL;
 1969|       |
 1970|  3.69k|	return &sc_hsm_drv;
 1971|  3.69k|}
card-sc-hsm.c:sc_hsm_match_card:
  266|  1.05k|{
  267|  1.05k|	sc_path_t path;
  268|  1.05k|	int i, r, type = 0;
  269|  1.05k|	sc_file_t *file = NULL;
  270|       |
  271|  1.05k|	i = _sc_match_atr(card, sc_hsm_atrs, &type);
  272|  1.05k|	if (i >= 0 && type != SC_CARD_TYPE_SC_HSM_SOC) {
  ------------------
  |  Branch (272:6): [True: 195, False: 863]
  |  Branch (272:16): [True: 195, False: 0]
  ------------------
  273|    195|		card->type = type;
  274|    195|		return 1;
  275|    195|	}
  276|       |
  277|    863|	sc_path_set(&path, SC_PATH_TYPE_DF_NAME, sc_hsm_aid.value, sc_hsm_aid.len, 0, 0);
  ------------------
  |  |  118|    863|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  278|    863|	r = sc_hsm_select_file(card, &path, &file);
  279|    863|	LOG_TEST_RET(card->ctx, r, "Could not select SmartCard-HSM application");
  ------------------
  |  |  174|    863|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    863|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    863|	int _ret = (r); \
  |  |  |  |  168|    863|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 846, False: 17]
  |  |  |  |  ------------------
  |  |  |  |  169|    846|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    846|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    846|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    846|		return _ret; \
  |  |  |  |  172|    846|	} \
  |  |  |  |  173|    863|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 17]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  280|       |
  281|       |	// Validate that card returns a FCP with a proprietary tag 85 with value longer than 2 byte (Fixes #1377)
  282|     17|	if (file != NULL) {
  ------------------
  |  Branch (282:6): [True: 17, False: 0]
  ------------------
  283|     17|		size_t sz = file->prop_attr_len;
  284|     17|		sc_file_free(file);
  285|     17|		if (sz < 2) {
  ------------------
  |  Branch (285:7): [True: 16, False: 1]
  ------------------
  286|     16|			return 0;
  287|     16|		}
  288|     17|	}
  289|       |
  290|      1|	if (type == SC_CARD_TYPE_SC_HSM_SOC) {
  ------------------
  |  Branch (290:6): [True: 0, False: 1]
  ------------------
  291|      0|		card->type = SC_CARD_TYPE_SC_HSM_SOC;
  292|      1|	} else {
  293|      1|		card->type = SC_CARD_TYPE_SC_HSM;
  294|      1|	}
  295|       |
  296|      1|	return 1;
  297|     17|}
card-sc-hsm.c:sc_hsm_select_file:
  246|  45.3k|{
  247|  45.3k|	return sc_hsm_select_file_ex(card, in_path, 0, file_out);
  248|  45.3k|}
card-sc-hsm.c:sc_hsm_select_file_ex:
  148|  46.3k|{
  149|  46.3k|	int rv;
  150|  46.3k|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
  151|  46.3k|	sc_file_t *file = NULL;
  152|  46.3k|	sc_path_t cpath;
  153|  46.3k|	size_t card_max_recv_size = card->max_recv_size;
  154|  46.3k|	size_t reader_max_recv_size = card->reader->max_recv_size;
  155|       |
  156|  46.3k|	if (file_out == NULL) {				// Versions before 0.16 of the SmartCard-HSM do not support P2='0C'
  ------------------
  |  Branch (156:6): [True: 808, False: 45.5k]
  ------------------
  157|    808|		rv = sc_hsm_select_file_ex(card, in_path, forceselect, &file);
  158|    808|		sc_file_free(file);
  159|    808|		return rv;
  160|    808|	}
  161|       |
  162|  45.5k|	if ((in_path->type == SC_PATH_TYPE_FILE_ID) && in_path->aid.len) {
  ------------------
  |  |  117|  45.5k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (162:6): [True: 1.46k, False: 44.0k]
  |  Branch (162:49): [True: 0, False: 1.46k]
  ------------------
  163|       |		// Split applet selection and file selection into two separate calls
  164|      0|		cpath = *in_path;
  165|      0|		cpath.len = 0;
  166|      0|		cpath.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  167|      0|		rv = sc_hsm_select_file_ex(card, &cpath, forceselect, NULL);
  168|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  169|       |
  170|      0|		if (in_path->len) {
  ------------------
  |  Branch (170:7): [True: 0, False: 0]
  ------------------
  171|      0|			cpath = *in_path;
  172|      0|			cpath.aid.len = 0;
  173|      0|			rv = sc_hsm_select_file_ex(card, &cpath, forceselect, file_out);
  174|      0|		}
  175|      0|		return rv;
  176|      0|	}
  177|       |
  178|       |	// Prevent selection of applet unless this is the first time, selection is forced or the device is not authenticated
  179|  45.5k|	if (in_path->type == SC_PATH_TYPE_DF_NAME
  ------------------
  |  |  118|  91.0k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (179:6): [True: 1.48k, False: 44.0k]
  ------------------
  180|  44.0k|			|| (in_path->type == SC_PATH_TYPE_PATH
  ------------------
  |  |  119|  88.0k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (180:8): [True: 42.5k, False: 1.46k]
  ------------------
  181|  42.5k|				&& in_path->len == sc_hsm_aid.len
  ------------------
  |  Branch (181:8): [True: 0, False: 42.5k]
  ------------------
  182|      0|				&& !memcmp(in_path->value, sc_hsm_aid.value, sc_hsm_aid.len))
  ------------------
  |  Branch (182:8): [True: 0, False: 0]
  ------------------
  183|  44.0k|			|| (in_path->type == SC_PATH_TYPE_PATH
  ------------------
  |  |  119|  88.0k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (183:8): [True: 42.5k, False: 1.46k]
  ------------------
  184|  42.5k|				&& in_path->len == 0
  ------------------
  |  Branch (184:8): [True: 11.8k, False: 30.7k]
  ------------------
  185|  11.8k|				&& in_path->aid.len == sc_hsm_aid.len
  ------------------
  |  Branch (185:8): [True: 0, False: 11.8k]
  ------------------
  186|  1.48k|				&& !memcmp(in_path->aid.value, sc_hsm_aid.value, sc_hsm_aid.len))) {
  ------------------
  |  Branch (186:8): [True: 0, False: 0]
  ------------------
  187|  1.48k|		if (!priv || (priv->dffcp == NULL) || forceselect) {
  ------------------
  |  Branch (187:7): [True: 863, False: 621]
  |  Branch (187:16): [True: 479, False: 142]
  |  Branch (187:41): [True: 0, False: 142]
  ------------------
  188|       |			/* Force use of Le = 0x00 in iso7816_select_file as required by SC-HSM */
  189|  1.34k|			card->max_recv_size = card->reader->max_recv_size = SC_READER_SHORT_APDU_MAX_RECV_SIZE;
  ------------------
  |  |  391|  1.34k|#define SC_READER_SHORT_APDU_MAX_RECV_SIZE 256
  ------------------
  190|  1.34k|			rv = (*iso_ops->select_file)(card, in_path, file_out);
  191|  1.34k|			card->max_recv_size = card_max_recv_size;
  192|  1.34k|			card->reader->max_recv_size = reader_max_recv_size;
  193|  1.34k|			LOG_TEST_RET(card->ctx, rv, "Could not select SmartCard-HSM application");
  ------------------
  |  |  174|  1.34k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.34k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.34k|	int _ret = (r); \
  |  |  |  |  168|  1.34k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.25k, False: 91]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.25k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.25k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.25k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.25k|		return _ret; \
  |  |  |  |  172|  1.25k|	} \
  |  |  |  |  173|  1.34k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 91]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  194|       |
  195|     91|			if (priv) {
  ------------------
  |  Branch (195:8): [True: 74, False: 17]
  ------------------
  196|     74|				sc_file_free(priv->dffcp);
  197|       |				// Cache the FCP returned when selecting the applet
  198|     74|				sc_file_dup(&priv->dffcp, *file_out);
  199|     74|			}
  200|    142|		} else {
  201|    142|			sc_file_dup(file_out, priv->dffcp);
  202|    142|			rv = SC_SUCCESS;
  ------------------
  |  |   28|    142|#define SC_SUCCESS				0
  ------------------
  203|    142|		}
  204|    233|		return rv;
  205|  1.48k|	}
  206|       |
  207|  44.0k|	if ((in_path->len >= 2) && (in_path->value[0] == 0x3F) && (in_path->value[1] == 0x00)) {
  ------------------
  |  Branch (207:6): [True: 32.1k, False: 11.8k]
  |  Branch (207:29): [True: 31.8k, False: 337]
  |  Branch (207:60): [True: 31.8k, False: 3]
  ------------------
  208|       |		// The SmartCard-HSM is an applet that is not default selected. Simulate selection of the MF
  209|  31.8k|		if (in_path->len == 2) {
  ------------------
  |  Branch (209:7): [True: 1.21k, False: 30.6k]
  ------------------
  210|  1.21k|			file = sc_file_new();
  211|  1.21k|			if (file == NULL)
  ------------------
  |  Branch (211:8): [True: 0, False: 1.21k]
  ------------------
  212|  1.21k|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  213|  1.21k|			file->path = *in_path;
  214|  1.21k|			file->id = 0x3F00;
  215|  1.21k|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|  1.21k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  216|  1.21k|			file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|  1.21k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  217|       |
  218|  1.21k|			*file_out = file;
  219|  1.21k|			return SC_SUCCESS;
  ------------------
  |  |   28|  1.21k|#define SC_SUCCESS				0
  ------------------
  220|  30.6k|		} else {
  221|       |			/* Force use of Le = 0x00 in iso7816_select_file as required by SC-HSM */
  222|  30.6k|			card->max_recv_size = card->reader->max_recv_size = SC_READER_SHORT_APDU_MAX_RECV_SIZE;
  ------------------
  |  |  391|  30.6k|#define SC_READER_SHORT_APDU_MAX_RECV_SIZE 256
  ------------------
  223|  30.6k|			sc_path_t truncated;
  224|  30.6k|			memcpy(&truncated, in_path, sizeof truncated);
  225|  30.6k|			truncated.len = in_path->len - 2;
  226|  30.6k|			memcpy(truncated.value, in_path->value+2, truncated.len);
  227|  30.6k|			rv = (*iso_ops->select_file)(card, &truncated, file_out);
  228|  30.6k|			card->max_recv_size = card_max_recv_size;
  229|  30.6k|			card->reader->max_recv_size = reader_max_recv_size;
  230|  30.6k|			return rv;
  231|  30.6k|		}
  232|  31.8k|	}
  233|       |	/* Force use of Le = 0x00 in iso7816_select_file as required by SC-HSM */
  234|  12.1k|	card->max_recv_size = card->reader->max_recv_size = SC_READER_SHORT_APDU_MAX_RECV_SIZE;
  ------------------
  |  |  391|  12.1k|#define SC_READER_SHORT_APDU_MAX_RECV_SIZE 256
  ------------------
  235|  12.1k|	rv = (*iso_ops->select_file)(card, in_path, file_out);
  236|  12.1k|	card->max_recv_size = card_max_recv_size;
  237|  12.1k|	card->reader->max_recv_size = reader_max_recv_size;
  238|  12.1k|	return rv;
  239|  44.0k|}
card-sc-hsm.c:sc_hsm_read_binary:
  795|  2.19k|{
  796|  2.19k|	sc_context_t *ctx = card->ctx;
  797|  2.19k|	sc_apdu_t apdu;
  798|  2.19k|	u8 cmdbuff[4];
  799|  2.19k|	int r;
  800|       |
  801|  2.19k|	if (idx > 0xffff) {
  ------------------
  |  Branch (801:6): [True: 0, False: 2.19k]
  ------------------
  802|      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__
  |  |  ------------------
  ------------------
  803|      0|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      0|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  804|      0|	}
  805|       |
  806|  2.19k|	cmdbuff[0] = 0x54;
  807|  2.19k|	cmdbuff[1] = 0x02;
  808|  2.19k|	cmdbuff[2] = (idx >> 8) & 0xFF;
  809|  2.19k|	cmdbuff[3] = idx & 0xFF;
  810|       |
  811|  2.19k|	if (count > sc_get_max_recv_size(card))
  ------------------
  |  Branch (811:6): [True: 0, False: 2.19k]
  ------------------
  812|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  813|  2.19k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0xB1, 0x00, 0x00);
  ------------------
  |  |  303|  2.19k|#define SC_APDU_CASE_4			0x24
  ------------------
  814|  2.19k|	apdu.data = cmdbuff;
  815|  2.19k|	apdu.datalen = 4;
  816|  2.19k|	apdu.lc = 4;
  817|  2.19k|	apdu.le = count;
  818|  2.19k|	apdu.resplen = count;
  819|  2.19k|	apdu.resp = buf;
  820|       |
  821|  2.19k|	r = sc_transmit_apdu(card, &apdu);
  822|  2.19k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.19k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.19k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.19k|	int _ret = (r); \
  |  |  |  |  168|  2.19k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 83, False: 2.10k]
  |  |  |  |  ------------------
  |  |  |  |  169|     83|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     83|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     83|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     83|		return _ret; \
  |  |  |  |  172|     83|	} \
  |  |  |  |  173|  2.19k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.10k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  823|       |
  824|  2.10k|	r =  sc_check_sw(card, apdu.sw1, apdu.sw2);
  825|  2.10k|	if (r != SC_ERROR_FILE_END_REACHED) {
  ------------------
  |  |   69|  2.10k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (825:6): [True: 2.04k, False: 64]
  ------------------
  826|  2.04k|		LOG_TEST_RET(ctx, r, "Check SW error");
  ------------------
  |  |  174|  2.04k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.04k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.04k|	int _ret = (r); \
  |  |  |  |  168|  2.04k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.34k, False: 700]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.34k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.34k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.34k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.34k|		return _ret; \
  |  |  |  |  172|  1.34k|	} \
  |  |  |  |  173|  2.04k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 700]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  827|  2.04k|	}
  828|       |
  829|    764|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|    764|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    764|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    764|	int _ret = r; \
  |  |  |  |  155|    764|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 85, False: 679]
  |  |  |  |  ------------------
  |  |  |  |  156|     85|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 85]
  |  |  |  |  ------------------
  |  |  |  |  157|     85|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    679|	} else { \
  |  |  |  |  159|    679|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    679|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    679|	} \
  |  |  |  |  162|    764|	return _ret; \
  |  |  |  |  163|    764|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  830|    764|}
card-sc-hsm.c:sc_hsm_update_binary:
  913|    756|{
  914|    756|	return sc_hsm_write_ef(card, 0, idx, buf, count);
  915|    756|}
card-sc-hsm.c:sc_hsm_write_ef:
  837|    760|{
  838|    760|	sc_context_t *ctx = card->ctx;
  839|    760|	sc_apdu_t apdu;
  840|    760|	u8 *cmdbuff, *p;
  841|    760|	size_t len;
  842|    760|	int r;
  843|       |
  844|    760|	if (idx > 0xffff) {
  ------------------
  |  Branch (844:6): [True: 0, False: 760]
  ------------------
  845|      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__
  |  |  ------------------
  ------------------
  846|      0|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      0|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  847|      0|	}
  848|       |
  849|    760|	cmdbuff = malloc(8 + count);
  850|    760|	if (!cmdbuff) {
  ------------------
  |  Branch (850:6): [True: 0, False: 760]
  ------------------
  851|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  852|      0|	}
  853|       |
  854|    760|	size_t bytes_left = count;
  855|       |	// 8 bytes are required for T54(4) and T53(4)
  856|    760|	size_t blk_size = card->max_send_size - 8;
  857|    760|	size_t to_send = 0;
  858|    760|	size_t file_offset = (size_t) idx;
  859|    760|	size_t offset = 0;
  860|    885|	do {
  861|    885|		to_send = bytes_left >= blk_size ? blk_size : bytes_left;
  ------------------
  |  Branch (861:13): [True: 558, False: 327]
  ------------------
  862|    885|		p = cmdbuff;
  863|       |		// ASN1 0x54 offset
  864|    885|		*p++ = 0x54;
  865|    885|		*p++ = 0x02;
  866|    885|		*p++ = (file_offset >> 8) & 0xFF;
  867|    885|		*p++ = file_offset & 0xFF;
  868|       |		// ASN1 0x53 to_send
  869|    885|		*p++ = 0x53;
  870|    885|		if (to_send < 128) {
  ------------------
  |  Branch (870:7): [True: 181, False: 704]
  ------------------
  871|    181|			*p++ = (u8)to_send;
  872|    181|			len = 6;
  873|    704|		} else if (to_send < 256) {
  ------------------
  |  Branch (873:14): [True: 0, False: 704]
  ------------------
  874|      0|			*p++ = 0x81;
  875|      0|			*p++ = (u8)to_send;
  876|      0|			len = 7;
  877|    704|		} else {
  878|    704|			*p++ = 0x82;
  879|    704|			*p++ = (to_send >> 8) & 0xFF;
  880|    704|			*p++ = to_send & 0xFF;
  881|    704|			len = 8;
  882|    704|		}
  883|       |
  884|    885|		if (buf != NULL)
  ------------------
  |  Branch (884:7): [True: 881, False: 4]
  ------------------
  885|    881|			memcpy(p, buf+offset, to_send);
  886|    885|		len += to_send;
  887|       |
  888|    885|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3, 0xD7, fid >> 8, fid & 0xFF);
  ------------------
  |  |  302|    885|#define SC_APDU_CASE_3			0x23
  ------------------
  889|    885|		apdu.data = cmdbuff;
  890|    885|		apdu.datalen = len;
  891|    885|		apdu.lc = len;
  892|       |
  893|    885|		r = sc_transmit_apdu(card, &apdu);
  894|    885|		LOG_TEST_GOTO_ERR(ctx, r, "APDU transmit failed");
  ------------------
  |  |  184|    885|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    885|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    885|	int _ret = (r); \
  |  |  |  |  178|    885|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 93, False: 792]
  |  |  |  |  ------------------
  |  |  |  |  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|    885|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 792]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  895|    792|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  896|    792|		LOG_TEST_GOTO_ERR(ctx, r, "Check SW error");
  ------------------
  |  |  184|    792|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    792|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    792|	int _ret = (r); \
  |  |  |  |  178|    792|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 541, False: 251]
  |  |  |  |  ------------------
  |  |  |  |  179|    541|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    541|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    541|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    541|		goto err; \
  |  |  |  |  182|    541|	} \
  |  |  |  |  183|    792|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 251]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  897|       |
  898|    251|		bytes_left -= to_send;
  899|    251|		offset += to_send;
  900|    251|		file_offset += to_send;
  901|    251|	} while (0 < bytes_left);
  ------------------
  |  Branch (901:11): [True: 125, False: 126]
  ------------------
  902|       |
  903|    760|err:
  904|    760|	free(cmdbuff);
  905|       |
  906|    760|	LOG_FUNC_RETURN(ctx, (int)count);
  ------------------
  |  |  164|    760|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    760|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    760|	int _ret = r; \
  |  |  |  |  155|    760|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4, False: 756]
  |  |  |  |  ------------------
  |  |  |  |  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|    756|	} else { \
  |  |  |  |  159|    756|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    756|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    756|	} \
  |  |  |  |  162|    760|	return _ret; \
  |  |  |  |  163|    760|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  907|    760|}
card-sc-hsm.c:sc_hsm_list_files:
  920|    409|{
  921|    409|	sc_apdu_t apdu;
  922|    409|	u8 recvbuf[MAX_EXT_APDU_LENGTH];
  923|    409|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
  924|    409|	int r;
  925|       |
  926|    409|	if (priv->noExtLength) {
  ------------------
  |  Branch (926:6): [True: 0, False: 409]
  ------------------
  927|      0|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x58, 0, 0);
  ------------------
  |  |  301|      0|#define SC_APDU_CASE_2			0x22
  ------------------
  928|    409|	} else {
  929|    409|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_EXT, 0x58, 0, 0);
  ------------------
  |  |  297|    409|#define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  292|    409|#define SC_APDU_CASE_2_SHORT		0x02
  |  |  ------------------
  |  |               #define SC_APDU_CASE_2_EXT		SC_APDU_CASE_2_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|    409|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
  930|    409|	}
  931|    409|	apdu.cla = 0x80;
  932|    409|	apdu.resp = recvbuf;
  933|    409|	apdu.resplen = sizeof(recvbuf);
  934|    409|	apdu.le = 0;
  935|    409|	r = sc_transmit_apdu(card, &apdu);
  936|       |
  937|    409|	if ((r == SC_ERROR_TRANSMIT_FAILED) && (!priv->noExtLength)) {
  ------------------
  |  |   38|    409|#define SC_ERROR_TRANSMIT_FAILED		-1107
  ------------------
  |  Branch (937:6): [True: 0, False: 409]
  |  Branch (937:41): [True: 0, False: 0]
  ------------------
  938|      0|		sc_log(card->ctx, "No extended length support ? Trying fall-back to short APDUs, probably breaking support for RSA 2048 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__
  |  |  ------------------
  ------------------
  939|      0|		priv->noExtLength = 1;
  940|      0|		card->max_send_size = 248;		// 255 - 7 because of TLV in odd ins UPDATE BINARY
  941|      0|		return sc_hsm_list_files(card, buf, buflen);
  942|      0|	}
  943|    409|	LOG_TEST_RET(card->ctx, r, "ENUMERATE OBJECTS APDU transmit failed");
  ------------------
  |  |  174|    409|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    409|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    409|	int _ret = (r); \
  |  |  |  |  168|    409|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 409]
  |  |  |  |  ------------------
  |  |  |  |  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|    409|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 409]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  944|       |
  945|    409|	if (buflen < apdu.resplen)
  ------------------
  |  Branch (945:6): [True: 0, False: 409]
  ------------------
  946|      0|		memcpy(buf, recvbuf, buflen);
  947|    409|	else
  948|    409|		memcpy(buf, recvbuf, apdu.resplen);
  949|       |
  950|    409|	LOG_FUNC_RETURN(card->ctx, (int)apdu.resplen);
  ------------------
  |  |  164|    409|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    409|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    409|	int _ret = r; \
  |  |  |  |  155|    409|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 339, False: 70]
  |  |  |  |  ------------------
  |  |  |  |  156|    339|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 339]
  |  |  |  |  ------------------
  |  |  |  |  157|    339|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    339|	} 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|    409|	return _ret; \
  |  |  |  |  163|    409|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  951|    409|}
card-sc-hsm.c:sc_hsm_create_file:
  956|      4|{
  957|      4|	int r;
  958|       |
  959|      4|	r = sc_hsm_write_ef(card, file->id, 0, NULL, 0);
  960|      4|	LOG_TEST_RET(card->ctx, r, "Create file 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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  961|       |
  962|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  963|      4|}
card-sc-hsm.c:sc_hsm_delete_file:
  968|      2|{
  969|      2|	sc_context_t *ctx = card->ctx;
  970|      2|	sc_apdu_t apdu;
  971|      2|	u8 sbuf[2];
  972|      2|	int r;
  973|       |
  974|      2|	if ((path->type != SC_PATH_TYPE_FILE_ID) || (path->len != 2)) {
  ------------------
  |  |  117|      2|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (974:6): [True: 0, False: 2]
  |  Branch (974:46): [True: 0, False: 2]
  ------------------
  975|      0|		sc_log(card->ctx,  "File type has to be SC_PATH_TYPE_FILE_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__
  |  |  ------------------
  ------------------
  976|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  977|      0|	}
  978|       |
  979|      2|	sbuf[0] = path->value[0];
  980|      2|	sbuf[1] = path->value[1];
  981|       |
  982|      2|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x02, 0x00);
  ------------------
  |  |  293|      2|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  983|      2|	apdu.data = sbuf;
  984|      2|	apdu.datalen = sizeof(sbuf);
  985|      2|	apdu.lc = sizeof(sbuf);
  986|       |
  987|      2|	r = sc_transmit_apdu(card, &apdu);
  988|      2|	LOG_TEST_RET(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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  989|       |
  990|      2|	r =  sc_check_sw(card, apdu.sw1, apdu.sw2);
  991|      2|	LOG_TEST_RET(ctx, r, "Check SW 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  992|       |
  993|      2|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  994|      2|}
card-sc-hsm.c:sc_hsm_init:
 1775|    196|{
 1776|       |#if defined(ENABLE_SM) && defined(ENABLE_OPENPACE) && defined(_WIN32)
 1777|       |	char expanded_val[PATH_MAX];
 1778|       |	size_t expanded_len = PATH_MAX;
 1779|       |#endif
 1780|    196|	int flags,ext_flags;
 1781|    196|	sc_file_t *file = NULL;
 1782|    196|	sc_path_t path;
 1783|    196|	sc_hsm_private_data_t *priv = NULL;
 1784|       |
 1785|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1786|       |
 1787|    196|	flags = SC_ALGORITHM_RSA_RAW|SC_ALGORITHM_RSA_PAD_PSS|SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  111|    196|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              	flags = SC_ALGORITHM_RSA_RAW|SC_ALGORITHM_RSA_PAD_PSS|SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  116|    196|#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
  ------------------
  |  |  102|    196|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 1788|    196|			|SC_ALGORITHM_RSA_HASH_SHA1|SC_ALGORITHM_RSA_HASH_SHA256|SC_ALGORITHM_RSA_HASH_SHA384|SC_ALGORITHM_RSA_HASH_SHA512
  ------------------
  |  |  143|    196|#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
  ------------------
  |  |  147|    196|#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
  ------------------
  |  |  148|    196|#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
  ------------------
  |  |  149|    196|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
 1789|    196|			|SC_ALGORITHM_MGF1_SHA256|SC_ALGORITHM_MGF1_SHA384|SC_ALGORITHM_MGF1_SHA512;
  ------------------
  |  |  155|    196|#define SC_ALGORITHM_MGF1_SHA256	0x00200000
  ------------------
              			|SC_ALGORITHM_MGF1_SHA256|SC_ALGORITHM_MGF1_SHA384|SC_ALGORITHM_MGF1_SHA512;
  ------------------
  |  |  156|    196|#define SC_ALGORITHM_MGF1_SHA384	0x00400000
  ------------------
              			|SC_ALGORITHM_MGF1_SHA256|SC_ALGORITHM_MGF1_SHA384|SC_ALGORITHM_MGF1_SHA512;
  ------------------
  |  |  157|    196|#define SC_ALGORITHM_MGF1_SHA512	0x00800000
  ------------------
 1790|       |
 1791|    196|	_sc_card_add_rsa_alg(card, 1024, flags, 0);
 1792|    196|	_sc_card_add_rsa_alg(card, 1536, flags, 0);
 1793|    196|	_sc_card_add_rsa_alg(card, 2048, flags, 0);
 1794|    196|	_sc_card_add_rsa_alg(card, 3072, flags, 0);
 1795|    196|	_sc_card_add_rsa_alg(card, 4096, flags, 0);
 1796|       |
 1797|    196|	flags = SC_ALGORITHM_ECDSA_RAW|
  ------------------
  |  |  183|    196|#define SC_ALGORITHM_ECDSA_RAW		0x00100000
  ------------------
 1798|    196|		SC_ALGORITHM_ECDH_CDH_RAW|
  ------------------
  |  |  182|    196|#define SC_ALGORITHM_ECDH_CDH_RAW	0x00200000
  ------------------
 1799|    196|		SC_ALGORITHM_ECDSA_HASH_NONE|
  ------------------
  |  |  184|    196|#define SC_ALGORITHM_ECDSA_HASH_NONE		SC_ALGORITHM_RSA_HASH_NONE
  |  |  ------------------
  |  |  |  |  142|    196|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  |  |  ------------------
  ------------------
 1800|    196|		SC_ALGORITHM_ECDSA_HASH_SHA1|
  ------------------
  |  |  185|    196|#define SC_ALGORITHM_ECDSA_HASH_SHA1		SC_ALGORITHM_RSA_HASH_SHA1
  |  |  ------------------
  |  |  |  |  143|    196|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  |  |  ------------------
  ------------------
 1801|    196|		SC_ALGORITHM_ECDSA_HASH_SHA224|
  ------------------
  |  |  186|    196|#define SC_ALGORITHM_ECDSA_HASH_SHA224		SC_ALGORITHM_RSA_HASH_SHA224
  |  |  ------------------
  |  |  |  |  150|    196|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  |  |  ------------------
  ------------------
 1802|    196|		SC_ALGORITHM_ECDSA_HASH_SHA256|
  ------------------
  |  |  187|    196|#define SC_ALGORITHM_ECDSA_HASH_SHA256		SC_ALGORITHM_RSA_HASH_SHA256
  |  |  ------------------
  |  |  |  |  147|    196|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  |  |  ------------------
  ------------------
 1803|    196|		SC_ALGORITHM_ECDSA_HASH_SHA384|
  ------------------
  |  |  188|    196|#define SC_ALGORITHM_ECDSA_HASH_SHA384		SC_ALGORITHM_RSA_HASH_SHA384
  |  |  ------------------
  |  |  |  |  148|    196|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  |  |  ------------------
  ------------------
 1804|    196|		SC_ALGORITHM_ECDSA_HASH_SHA512|
  ------------------
  |  |  189|    196|#define SC_ALGORITHM_ECDSA_HASH_SHA512		SC_ALGORITHM_RSA_HASH_SHA512
  |  |  ------------------
  |  |  |  |  149|    196|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  |  |  ------------------
  ------------------
 1805|    196|		SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    196|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 1806|       |
 1807|    196|	ext_flags = SC_ALGORITHM_EXT_EC_F_P|
  ------------------
  |  |  207|    196|#define SC_ALGORITHM_EXT_EC_F_P          0x00000001
  ------------------
 1808|    196|			SC_ALGORITHM_EXT_EC_ECPARAMETERS|
  ------------------
  |  |  209|    196|#define SC_ALGORITHM_EXT_EC_ECPARAMETERS 0x00000004
  ------------------
 1809|    196|			SC_ALGORITHM_EXT_EC_NAMEDCURVE|
  ------------------
  |  |  210|    196|#define SC_ALGORITHM_EXT_EC_NAMEDCURVE   0x00000008
  ------------------
 1810|    196|			SC_ALGORITHM_EXT_EC_UNCOMPRESES|
  ------------------
  |  |  211|    196|#define SC_ALGORITHM_EXT_EC_UNCOMPRESES  0x00000010
  ------------------
 1811|    196|			SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    196|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
 1812|    196|	_sc_card_add_ec_alg(card, 192, flags, ext_flags, NULL);
 1813|    196|	_sc_card_add_ec_alg(card, 224, flags, ext_flags, NULL);
 1814|    196|	_sc_card_add_ec_alg(card, 256, flags, ext_flags, NULL);
 1815|    196|	_sc_card_add_ec_alg(card, 320, flags, ext_flags, NULL);
 1816|    196|	_sc_card_add_ec_alg(card, 384, flags, ext_flags, NULL);
 1817|    196|	_sc_card_add_ec_alg(card, 512, flags, ext_flags, NULL);
 1818|    196|	_sc_card_add_ec_alg(card, 521, flags, ext_flags, NULL);
 1819|       |
 1820|    196|	card->caps |= SC_CARD_CAP_RNG|SC_CARD_CAP_APDU_EXT|SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  557|    196|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
              	card->caps |= SC_CARD_CAP_RNG|SC_CARD_CAP_APDU_EXT|SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  554|    196|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
              	card->caps |= SC_CARD_CAP_RNG|SC_CARD_CAP_APDU_EXT|SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|    196|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
 1821|       |
 1822|       |	// APDU Size limits
 1823|       |	//   JCOP 2.4.1r3           1462
 1824|       |	//   JCOP 2.4.2r3           1454
 1825|       |	//   JCOP 3                 1232
 1826|       |	//   JCOP 4                 1454
 1827|       |	//   MicroSD with JCOP 3    478 / 506 - handled in reader-pcsc.c
 1828|       |	//   Reiner SCT             1014 - handled in reader-pcsc.c
 1829|       |	//
 1830|       |	// Note, that these are limits for the whole APDU, but the semantics of max_send_size
 1831|       |	// is the size of the APDU send buffer so to get the right value from them, we need
 1832|       |	// to subtract APDU headers (CLA, INS, P1, P2, Lc (3B)), 7 bytes altogether for
 1833|       |	// class 3 APDU
 1834|       |	// (or 9 bytes for case 4 when we pass in >255 B data and expect return of more than 255 B)
 1835|       |
 1836|       |	// Use JCOP 3 (smallest unhandled by reader limitation) card limits for sending
 1837|       |	// And make it 9 smaller to make sure we fit the rest of the APDU.
 1838|    196|	card->max_send_size = 1232 - 9;
 1839|       |	// Assume that card supports sending with extended length APDU and without limit
 1840|    196|	card->max_recv_size = 0;
 1841|       |
 1842|    196|	if (card->type == SC_CARD_TYPE_SC_HSM_SOC
  ------------------
  |  Branch (1842:6): [True: 0, False: 196]
  ------------------
 1843|    196|			|| card->type == SC_CARD_TYPE_SC_HSM_GOID) {
  ------------------
  |  Branch (1843:7): [True: 195, False: 1]
  ------------------
 1844|    195|		card->max_recv_size = 0x0630;	// SoC Proxy forces this limit
 1845|    195|	} else {
 1846|       |		// Adjust to the limits set by the reader
 1847|      1|		if (card->reader->max_send_size < card->max_send_size) {
  ------------------
  |  Branch (1847:7): [True: 1, False: 0]
  ------------------
 1848|      1|			if (18 >= card->reader->max_send_size)
  ------------------
  |  Branch (1848:8): [True: 1, False: 0]
  ------------------
 1849|      1|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INCONSISTENT_CONFIGURATION);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1850|       |
 1851|       |			// 17 byte header and TLV because of odd ins in UPDATE BINARY
 1852|      0|			card->max_send_size = card->reader->max_send_size - 17;
 1853|      0|		}
 1854|       |
 1855|      0|		if (0 < card->reader->max_recv_size) {
  ------------------
  |  Branch (1855:7): [True: 0, False: 0]
  ------------------
 1856|      0|			if (3 >= card->reader->max_recv_size)
  ------------------
  |  Branch (1856:8): [True: 0, False: 0]
  ------------------
 1857|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1858|      0|			card->max_recv_size = card->reader->max_recv_size - 2;
 1859|      0|		}
 1860|      0|	}
 1861|       |
 1862|    195|	priv = card->drv_data;
 1863|    195|	if (!priv) {
  ------------------
  |  Branch (1863:6): [True: 195, False: 0]
  ------------------
 1864|    195|		priv = calloc(1, sizeof(sc_hsm_private_data_t));
 1865|    195|		if (!priv)
  ------------------
  |  Branch (1865:7): [True: 0, False: 195]
  ------------------
 1866|    195|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1867|    195|		card->drv_data = priv;
 1868|    195|	}
 1869|       |
 1870|    195|	sc_path_set(&path, SC_PATH_TYPE_DF_NAME, sc_hsm_aid.value, sc_hsm_aid.len, 0, 0);
  ------------------
  |  |  118|    195|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 1871|    195|	if (sc_hsm_select_file_ex(card, &path, 0, &file) == SC_SUCCESS
  ------------------
  |  |   28|    390|#define SC_SUCCESS				0
  ------------------
  |  Branch (1871:6): [True: 48, False: 147]
  ------------------
 1872|     48|			&& file && file->prop_attr && file->prop_attr_len >= 2) {
  ------------------
  |  Branch (1872:7): [True: 48, False: 0]
  |  Branch (1872:15): [True: 0, False: 48]
  |  Branch (1872:34): [True: 0, False: 0]
  ------------------
 1873|      0|		static char card_name[SC_MAX_APDU_BUFFER_SIZE];
 1874|      0|		u8 type = 0xFF;
 1875|      0|		u8 major = file->prop_attr[file->prop_attr_len - 2];
 1876|      0|		u8 minor = file->prop_attr[file->prop_attr_len - 1];
 1877|      0|		char p00[] = "SmartCard-HSM Applet for JCOP";
 1878|      0|		char p01[] = "SmartCard-HSM Demo Applet for JCOP";
 1879|      0|		char *p = "SmartCard-HSM";
 1880|      0|		if (file->prop_attr_len >= 3) {
  ------------------
  |  Branch (1880:7): [True: 0, False: 0]
  ------------------
 1881|      0|			type = file->prop_attr[file->prop_attr_len - 3];
 1882|      0|		}
 1883|      0|		switch (type) {
 1884|      0|			case 0x00:
  ------------------
  |  Branch (1884:4): [True: 0, False: 0]
  ------------------
 1885|      0|				p = p00;
 1886|      0|				break;
 1887|      0|			case 0x01:
  ------------------
  |  Branch (1887:4): [True: 0, False: 0]
  ------------------
 1888|      0|				p = p01;
 1889|      0|				break;
 1890|      0|			default:
  ------------------
  |  Branch (1890:4): [True: 0, False: 0]
  ------------------
 1891|      0|				break;
 1892|      0|		}
 1893|      0|		snprintf(card_name, sizeof card_name, "%s version %u.%u", p, major, minor);
 1894|      0|		card->name = card_name;
 1895|       |
 1896|      0|		if (file->prop_attr[1] & 0x04) {
  ------------------
  |  Branch (1896:7): [True: 0, False: 0]
  ------------------
 1897|      0|			card->caps |= SC_CARD_CAP_SESSION_PIN;
  ------------------
  |  |  570|      0|#define SC_CARD_CAP_SESSION_PIN	0x00000200
  ------------------
 1898|      0|		}
 1899|      0|	}
 1900|    195|	sc_file_free(file);
 1901|       |
 1902|    195|	priv->EF_C_DevAut = NULL;
 1903|    195|	priv->EF_C_DevAut_len = 0;
 1904|       |
 1905|    195|#if defined(ENABLE_SM) && defined(ENABLE_OPENPACE)
 1906|    195|	EAC_init();
 1907|       |#ifdef _WIN32
 1908|       |	expanded_len = ExpandEnvironmentStringsA(CVCDIR, expanded_val, sizeof expanded_val);
 1909|       |	if (0 < expanded_len && expanded_len < sizeof expanded_val)
 1910|       |		EAC_set_cvc_default_dir(expanded_val);
 1911|       |#else
 1912|    195|	EAC_set_cvc_default_dir(CVCDIR);
  ------------------
  |  |    8|    195|#define CVCDIR "/usr/etc/eac/cvc"
  ------------------
 1913|    195|#endif
 1914|    195|#endif
 1915|       |
 1916|    195|	return 0;
 1917|    195|}
card-sc-hsm.c:sc_hsm_finish:
 1922|    195|{
 1923|    195|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
 1924|    195|#ifdef ENABLE_SM
 1925|    195|	sc_sm_stop(card);
 1926|    195|#endif
 1927|    195|	if (priv) {
  ------------------
  |  Branch (1927:6): [True: 195, False: 0]
  ------------------
 1928|    195|		free(priv->serialno);
 1929|    195|		sc_file_free(priv->dffcp);
 1930|    195|		free(priv->EF_C_DevAut);
 1931|    195|	}
 1932|    195|	free(priv);
 1933|       |
 1934|    195|	return SC_SUCCESS;
  ------------------
  |  |   28|    195|#define SC_SUCCESS				0
  ------------------
 1935|    195|}
card-sc-hsm.c:sc_hsm_card_ctl:
 1746|    461|{
 1747|    461|	switch (cmd) {
  ------------------
  |  Branch (1747:10): [True: 265, False: 196]
  ------------------
 1748|      7|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (1748:2): [True: 7, False: 454]
  ------------------
 1749|      7|		return sc_hsm_get_serialnr(card, (sc_serial_number_t *)ptr);
 1750|      0|	case SC_CARDCTL_PKCS11_INIT_TOKEN:
  ------------------
  |  Branch (1750:2): [True: 0, False: 461]
  ------------------
 1751|      0|		return sc_hsm_init_token(card, (sc_cardctl_pkcs11_init_token_t *)ptr);
 1752|      0|	case SC_CARDCTL_PKCS11_INIT_PIN:
  ------------------
  |  Branch (1752:2): [True: 0, False: 461]
  ------------------
 1753|      0|		return sc_hsm_init_pin(card, (sc_cardctl_pkcs11_init_pin_t *)ptr);
 1754|    258|	case SC_CARDCTL_SC_HSM_GENERATE_KEY:
  ------------------
  |  Branch (1754:2): [True: 258, False: 203]
  ------------------
 1755|    258|		return sc_hsm_generate_keypair(card, (sc_cardctl_sc_hsm_keygen_info_t *)ptr);
 1756|      0|	case SC_CARDCTL_SC_HSM_INITIALIZE:
  ------------------
  |  Branch (1756:2): [True: 0, False: 461]
  ------------------
 1757|      0|		return sc_hsm_initialize(card, (sc_cardctl_sc_hsm_init_param_t *)ptr);
 1758|      0|	case SC_CARDCTL_SC_HSM_IMPORT_DKEK_SHARE:
  ------------------
  |  Branch (1758:2): [True: 0, False: 461]
  ------------------
 1759|      0|		return sc_hsm_import_dkek_share(card, (sc_cardctl_sc_hsm_dkek_t *)ptr);
 1760|      0|	case SC_CARDCTL_SC_HSM_WRAP_KEY:
  ------------------
  |  Branch (1760:2): [True: 0, False: 461]
  ------------------
 1761|      0|		return sc_hsm_wrap_key(card, (sc_cardctl_sc_hsm_wrapped_key_t *)ptr);
 1762|      0|	case SC_CARDCTL_SC_HSM_UNWRAP_KEY:
  ------------------
  |  Branch (1762:2): [True: 0, False: 461]
  ------------------
 1763|      0|		return sc_hsm_unwrap_key(card, (sc_cardctl_sc_hsm_wrapped_key_t *)ptr);
 1764|      0|	case SC_CARDCTL_SC_HSM_REGISTER_PUBLIC_KEY:
  ------------------
  |  Branch (1764:2): [True: 0, False: 461]
  ------------------
 1765|      0|		return sc_hsm_register_public_key(card, ptr);
 1766|      0|	case SC_CARDCTL_SC_HSM_PUBLIC_KEY_AUTH_STATUS:
  ------------------
  |  Branch (1766:2): [True: 0, False: 461]
  ------------------
 1767|      0|		return sc_hsm_public_key_auth_status(card, ptr);
 1768|    461|	}
 1769|    196|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    196|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1770|    461|}
card-sc-hsm.c:sc_hsm_get_serialnr:
 1193|      7|{
 1194|      7|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
 1195|       |
 1196|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1197|       |
 1198|      7|	if (!priv->serialno && 0 == strcmp(card->ctx->app_name, "opensc-tool")) {
  ------------------
  |  Branch (1198:6): [True: 7, False: 0]
  |  Branch (1198:25): [True: 0, False: 7]
  ------------------
 1199|       |		/* sc-hsm initializes the serial number via its PKCS#15 layer.
 1200|       |		 * Create and destroy a dummy card to get this initialized.  Only do
 1201|       |		 * this for `opensc-tool --serial` to avoid unnecessary card commands
 1202|       |		 * in all other cases. */
 1203|      0|		sc_pkcs15_card_t *p15card = NULL;
 1204|      0|		(void)sc_pkcs15_bind(card, NULL, &p15card);
 1205|      0|		sc_pkcs15_unbind(p15card);
 1206|      0|	}
 1207|       |
 1208|      7|	if (!priv->serialno) {
  ------------------
  |  Branch (1208:6): [True: 7, False: 0]
  ------------------
 1209|      7|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      7|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1210|      7|	}
 1211|       |
 1212|      0|	serial->len = strlen(priv->serialno);
 1213|      0|	if (serial->len > sizeof(serial->value))
  ------------------
  |  Branch (1213:6): [True: 0, False: 0]
  ------------------
 1214|      0|		serial->len = sizeof(serial->value);
 1215|       |
 1216|      0|	memcpy(serial->value, priv->serialno, serial->len);
 1217|       |
 1218|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1219|      0|}
card-sc-hsm.c:sc_hsm_generate_keypair:
 1708|    258|{
 1709|    258|	u8 rbuf[1200];
 1710|    258|	int r;
 1711|    258|	sc_apdu_t apdu;
 1712|       |
 1713|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1714|       |
 1715|    258|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_EXT, 0x46, keyinfo->key_id, keyinfo->auth_key_id);
  ------------------
  |  |  299|    258|#define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  294|    258|#define SC_APDU_CASE_4_SHORT		0x04
  |  |  ------------------
  |  |               #define SC_APDU_CASE_4_EXT		SC_APDU_CASE_4_SHORT | SC_APDU_EXT
  |  |  ------------------
  |  |  |  |  296|    258|#define SC_APDU_EXT			0x10
  |  |  ------------------
  ------------------
 1716|    258|	apdu.cla = 0x00;
 1717|    258|	apdu.resp = rbuf;
 1718|    258|	apdu.resplen = sizeof(rbuf);
 1719|    258|	apdu.le = 0;
 1720|       |
 1721|    258|	apdu.data = keyinfo->gakprequest;
 1722|    258|	apdu.lc = keyinfo->gakprequest_len;
 1723|    258|	apdu.datalen = keyinfo->gakprequest_len;
 1724|       |
 1725|    258|	r = sc_transmit_apdu(card, &apdu);
 1726|    258|	LOG_TEST_RET(card->ctx, r, "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: 0, False: 258]
  |  |  |  |  ------------------
  |  |  |  |  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|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1727|       |
 1728|    258|	r =  sc_check_sw(card, apdu.sw1, apdu.sw2);
 1729|    258|	LOG_TEST_RET(card->ctx, r, "Check SW error");
  ------------------
  |  |  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: 245, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  169|    245|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    245|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    245|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    245|		return _ret; \
  |  |  |  |  172|    245|	} \
  |  |  |  |  173|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1730|       |
 1731|     13|	keyinfo->gakpresponse_len = apdu.resplen;
 1732|     13|	keyinfo->gakpresponse = malloc(apdu.resplen);
 1733|       |
 1734|     13|	if (keyinfo->gakpresponse == NULL) {
  ------------------
  |  Branch (1734:6): [True: 0, False: 13]
  ------------------
 1735|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1736|      0|	}
 1737|       |
 1738|     13|	memcpy(keyinfo->gakpresponse, apdu.resp, apdu.resplen);
 1739|       |
 1740|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1741|     13|}
card-sc-hsm.c:sc_hsm_pin_cmd:
  616|      3|{
  617|      3|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
  618|      3|	sc_apdu_t apdu;
  619|      3|	u8 cmdbuff[16];
  620|      3|#ifdef ENABLE_SM
  621|      3|	u8 rbuf[SC_MAX_APDU_BUFFER_SIZE];
  622|      3|#endif
  623|      3|	int r;
  624|      3|	int cmd = data->cmd;
  625|      3|	size_t pin2_len = data->pin2.len;
  626|       |
  627|      3|	if (cmd == SC_PIN_CMD_GET_SESSION_PIN) {
  ------------------
  |  |  426|      3|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (627:6): [True: 0, False: 3]
  ------------------
  628|       |		/* First, perform a standard VERIFY */
  629|      0|		data->cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  422|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  630|       |		/* we assign pin2.len to 0 early on so that in case of an error we are
  631|       |		 * not exiting with an undefined session PIN */
  632|      0|		data->pin2.len = 0;
  633|      0|	}
  634|       |
  635|      3|	if ((card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)
  ------------------
  |  |  567|      3|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (635:6): [True: 0, False: 3]
  ------------------
  636|      0|		   	&& (data->cmd == SC_PIN_CMD_CHANGE)
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (636:10): [True: 0, False: 0]
  ------------------
  637|      0|		   	&& (data->pin_reference == 0x81)
  ------------------
  |  Branch (637:10): [True: 0, False: 0]
  ------------------
  638|      0|			&& (!data->pin1.data || data->pin1.len <= 0)) {
  ------------------
  |  Branch (638:8): [True: 0, False: 0]
  |  Branch (638:28): [True: 0, False: 0]
  ------------------
  639|      0|		return sc_hsm_soc_change(card, data);
  640|      3|	} else if ((card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)
  ------------------
  |  |  567|      3|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (640:13): [True: 0, False: 3]
  ------------------
  641|      0|		   	&& (data->cmd == SC_PIN_CMD_UNBLOCK)
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (641:10): [True: 0, False: 0]
  ------------------
  642|      0|		   	&& (data->pin_reference == 0x81)
  ------------------
  |  Branch (642:10): [True: 0, False: 0]
  ------------------
  643|      0|			&& (!data->pin1.data || data->pin1.len <= 0)) {
  ------------------
  |  Branch (643:8): [True: 0, False: 0]
  |  Branch (643:28): [True: 0, False: 0]
  ------------------
  644|      0|		return sc_hsm_soc_unblock(card, data);
  645|      0|	}
  646|       |
  647|      3|#ifdef ENABLE_SM
  648|       |	/* For contactless cards always establish a secure channel before PIN
  649|       |	 * verification. Also, Session PIN generation requires SM. */
  650|      3|	if ((card->type == SC_CARD_TYPE_SC_HSM_SOC
  ------------------
  |  Branch (650:7): [True: 0, False: 3]
  ------------------
  651|      3|				|| card->type == SC_CARD_TYPE_SC_HSM_GOID
  ------------------
  |  Branch (651:8): [True: 3, False: 0]
  ------------------
  652|      0|				|| card->reader->uid.len || cmd == SC_PIN_CMD_GET_SESSION_PIN)
  ------------------
  |  |  426|      0|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (652:8): [True: 0, False: 0]
  |  Branch (652:33): [True: 0, False: 0]
  ------------------
  653|      3|			&& (data->cmd != SC_PIN_CMD_GET_INFO)) {
  ------------------
  |  |  425|      3|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (653:7): [True: 0, False: 3]
  ------------------
  654|      0|		struct sc_pin_cmd_data check_sm_pin_data;
  655|      0|		memset(&check_sm_pin_data, 0, sizeof(check_sm_pin_data));
  656|      0|		check_sm_pin_data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  425|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  657|      0|		check_sm_pin_data.pin_type = data->pin_type;
  658|      0|		check_sm_pin_data.pin_reference = data->pin_reference;
  659|       |
  660|      0|		r = SC_ERROR_NOT_ALLOWED;
  ------------------
  |  |   59|      0|#define SC_ERROR_NOT_ALLOWED			-1209
  ------------------
  661|      0|		if (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT) {
  ------------------
  |  |   47|      0|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (661:7): [True: 0, False: 0]
  ------------------
  662|       |			/* check if the existing SM channel is still valid */
  663|      0|			r = sc_pin_cmd(card, &check_sm_pin_data);
  664|      0|		}
  665|      0|		if (r == SC_ERROR_ASN1_OBJECT_NOT_FOUND || r == SC_ERROR_NOT_ALLOWED) {
  ------------------
  |  |   83|      0|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
              		if (r == SC_ERROR_ASN1_OBJECT_NOT_FOUND || r == SC_ERROR_NOT_ALLOWED) {
  ------------------
  |  |   59|      0|#define SC_ERROR_NOT_ALLOWED			-1209
  ------------------
  |  Branch (665:7): [True: 0, False: 0]
  |  Branch (665:46): [True: 0, False: 0]
  ------------------
  666|       |			/* need to establish a new SM channel */
  667|      0|			LOG_TEST_RET(card->ctx,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  668|      0|					sc_hsm_perform_chip_authentication(card),
  669|      0|					"Could not perform chip authentication");
  670|      0|		}
  671|      0|	}
  672|      3|#endif
  673|       |
  674|      3|	if ((card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)
  ------------------
  |  |  567|      3|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (674:6): [True: 0, False: 3]
  ------------------
  675|      0|			&& (data->cmd == SC_PIN_CMD_VERIFY)
  ------------------
  |  |  422|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (675:7): [True: 0, False: 0]
  ------------------
  676|      0|			&& (data->pin_reference == 0x81)
  ------------------
  |  Branch (676:7): [True: 0, False: 0]
  ------------------
  677|      0|			&& (!data->pin1.data || data->pin1.len <= 0)) {
  ------------------
  |  Branch (677:8): [True: 0, False: 0]
  |  Branch (677:28): [True: 0, False: 0]
  ------------------
  678|      0|		r = sc_hsm_soc_biomatch(card, data);
  679|      3|	} else {
  680|      3|		if ((data->cmd == SC_PIN_CMD_VERIFY) && (data->pin_reference == 0x88)) {
  ------------------
  |  |  422|      3|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (680:7): [True: 0, False: 3]
  |  Branch (680:43): [True: 0, False: 0]
  ------------------
  681|      0|			if (data->pin1.len != 16)
  ------------------
  |  Branch (681:8): [True: 0, False: 0]
  ------------------
  682|      0|				return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      0|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
  683|       |
  684|       |			// Save SO PIN for later use in sc_hsm_init_pin()
  685|      0|			r = sc_hsm_encode_sopin(data->pin1.data, priv->sopin);
  686|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  687|       |
  688|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  689|      0|		}
  690|       |
  691|      3|		if ((data->cmd == SC_PIN_CMD_CHANGE) && (data->pin_reference == 0x88)) {
  ------------------
  |  |  423|      3|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (691:7): [True: 0, False: 3]
  |  Branch (691:43): [True: 0, False: 0]
  ------------------
  692|      0|			if ((data->pin1.len != 16) || (data->pin2.len != 16))
  ------------------
  |  Branch (692:8): [True: 0, False: 0]
  |  Branch (692:34): [True: 0, False: 0]
  ------------------
  693|      0|				return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      0|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
  694|       |
  695|      0|			r = sc_hsm_encode_sopin(data->pin1.data, cmdbuff);
  696|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  697|       |
  698|      0|			r = sc_hsm_encode_sopin(data->pin2.data, cmdbuff + 8);
  699|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  700|       |
  701|      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
  ------------------
  702|      0|			apdu.data = cmdbuff;
  703|      0|			apdu.datalen = sizeof(cmdbuff);
  704|      0|			apdu.lc = 16;
  705|      0|			apdu.resplen = 0;
  706|      0|			data->apdu = &apdu;
  707|      0|		}
  708|       |
  709|      3|#ifdef ENABLE_SM
  710|      3|		if ((data->cmd == SC_PIN_CMD_GET_INFO)
  ------------------
  |  |  425|      3|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (710:7): [True: 3, False: 0]
  ------------------
  711|      3|				&& (card->sm_ctx.sm_mode == SM_MODE_TRANSMIT)) {
  ------------------
  |  |   47|      3|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (711:8): [True: 0, False: 3]
  ------------------
  712|       |			/* JCOP's SM accelerator is incapable of using case 1 APDU in SM */
  713|      0|			sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x20, 0x00, data->pin_reference);
  ------------------
  |  |  301|      0|#define SC_APDU_CASE_2			0x22
  ------------------
  714|      0|			apdu.resp = rbuf;
  715|      0|			apdu.resplen = sizeof rbuf;
  716|      0|			data->apdu = &apdu;
  717|      0|		}
  718|      3|#endif
  719|       |
  720|      3|		data->pin1.offset = 5;
  721|      3|		data->pin2.offset = 5;
  722|       |
  723|      3|		r = (*iso_ops->pin_cmd)(card, data);
  724|      3|		data->apdu = NULL;
  725|      3|	}
  726|      3|	LOG_TEST_RET(card->ctx, r, "Verification 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: 2, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|      3|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  727|       |
  728|      1|	if (cmd == SC_PIN_CMD_GET_SESSION_PIN) {
  ------------------
  |  |  426|      1|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (728:6): [True: 0, False: 1]
  ------------------
  729|       |		/* reset data->cmd to its original value */
  730|      0|		data->cmd = SC_PIN_CMD_GET_SESSION_PIN;
  ------------------
  |  |  426|      0|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  731|      0|		if (data->pin_reference == 0x81) {
  ------------------
  |  Branch (731:7): [True: 0, False: 0]
  ------------------
  732|      0|			u8 recvbuf[SC_MAX_APDU_BUFFER_SIZE];
  733|      0|#ifdef ENABLE_SM
  734|      0|			if (card->sm_ctx.sm_mode != SM_MODE_TRANSMIT) {
  ------------------
  |  |   47|      0|#define SM_MODE_TRANSMIT	0x200
  ------------------
  |  Branch (734:8): [True: 0, False: 0]
  ------------------
  735|      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__
  |  |  ------------------
  ------------------
  736|      0|						"Session PIN generation only supported in SM");
  737|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  738|      0|			}
  739|       |#else
  740|       |			sc_log(card->ctx,
  741|       |					"Session PIN generation only supported in SM");
  742|       |			LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  743|       |#endif
  744|      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
  ------------------
  745|      0|			apdu.cla = 0x80;
  746|      0|			apdu.resp = recvbuf;
  747|      0|			apdu.resplen = sizeof recvbuf;
  748|      0|			apdu.le = 0;
  749|      0|			if (sc_transmit_apdu(card, &apdu) != SC_SUCCESS
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (749:8): [True: 0, False: 0]
  ------------------
  750|      0|					|| sc_check_sw(card, apdu.sw1, apdu.sw2) != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (750:9): [True: 0, False: 0]
  ------------------
  751|      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__
  |  |  ------------------
  ------------------
  752|      0|						"Generating session PIN failed");
  753|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|      0|			}
  755|      0|			if (data->pin2.data && pin2_len > 0) {
  ------------------
  |  Branch (755:8): [True: 0, False: 0]
  |  Branch (755:27): [True: 0, False: 0]
  ------------------
  756|      0|				if (pin2_len >= apdu.resplen) {
  ------------------
  |  Branch (756:9): [True: 0, False: 0]
  ------------------
  757|      0|					memcpy((unsigned char *) data->pin2.data, apdu.resp,
  758|      0|							apdu.resplen);
  759|      0|					data->pin2.len = apdu.resplen;
  760|      0|				} else {
  761|      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__
  |  |  ------------------
  ------------------
  762|      0|							"Buffer too small for session PIN");
  763|      0|				}
  764|      0|			}
  765|      0|		} else {
  766|      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__
  |  |  ------------------
  ------------------
  767|      0|					"Session PIN not supported for this PIN (0x%02X)",
  768|      0|					data->pin_reference);
  769|      0|		}
  770|      0|	}
  771|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  772|      1|}

sc_get_setcos_driver:
 1130|  3.69k|{
 1131|  3.69k|	return sc_get_driver();
 1132|  3.69k|}
card-setcos.c:sc_get_driver:
 1110|  3.69k|{
 1111|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 1112|       |
 1113|  3.69k|	setcos_ops = *iso_drv->ops;
 1114|  3.69k|	setcos_ops.match_card = setcos_match_card;
 1115|  3.69k|	setcos_ops.init = setcos_init;
 1116|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (1116:6): [True: 1, False: 3.69k]
  ------------------
 1117|      1|		iso_ops = iso_drv->ops;
 1118|  3.69k|	setcos_ops.create_file = setcos_create_file;
 1119|  3.69k|	setcos_ops.set_security_env = setcos_set_security_env;
 1120|  3.69k|	setcos_ops.select_file = setcos_select_file;
 1121|  3.69k|	setcos_ops.list_files = setcos_list_files;
 1122|  3.69k|	setcos_ops.process_fci = setcos_process_fci;
 1123|  3.69k|	setcos_ops.construct_fci = setcos_construct_fci;
 1124|  3.69k|	setcos_ops.card_ctl = setcos_card_ctl;
 1125|       |
 1126|  3.69k|	return &setcos_drv;
 1127|  3.69k|}
card-setcos.c:setcos_match_card:
   83|    862|{
   84|    862|	sc_apdu_t apdu;
   85|    862|	u8 buf[6];
   86|    862|	int i;
   87|       |
   88|    862|	i = _sc_match_atr(card, setcos_atrs, &card->type);
   89|    862|	if (i < 0) {
  ------------------
  |  Branch (89:6): [True: 859, False: 3]
  ------------------
   90|    859|		if (match_hist_bytes(card, "FISE", 0)) {
  ------------------
  |  Branch (90:7): [True: 12, False: 847]
  ------------------
   91|     12|			card->type = SC_CARD_TYPE_SETCOS_GENERIC;
   92|     12|			return 1;
   93|     12|		}
   94|       |		/* Check if it's a EID2.x applet by reading the version info */
   95|    847|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xCA, 0xDF, 0x30);
  ------------------
  |  |  292|    847|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
   96|    847|		apdu.cla = 0x00;
   97|    847|		apdu.resp = buf;
   98|    847|		apdu.resplen = 5;
   99|    847|		apdu.le = 5;
  100|    847|		i = sc_transmit_apdu(card, &apdu);
  101|    847|		if (i == 0 && apdu.sw1 == 0x90 && apdu.sw2 == 0x00 && apdu.resplen == 5) {
  ------------------
  |  Branch (101:7): [True: 847, False: 0]
  |  Branch (101:17): [True: 221, False: 626]
  |  Branch (101:37): [True: 216, False: 5]
  |  Branch (101:57): [True: 210, False: 6]
  ------------------
  102|    210|			if (memcmp(buf, "v2.0", 4) == 0)
  ------------------
  |  Branch (102:8): [True: 29, False: 181]
  ------------------
  103|     29|				card->type = SC_CARD_TYPE_SETCOS_EID_V2_0;
  104|    181|			else if (memcmp(buf, "v2.1", 4) == 0)
  ------------------
  |  Branch (104:13): [True: 111, False: 70]
  ------------------
  105|    111|				card->type = SC_CARD_TYPE_SETCOS_EID_V2_1;
  106|     70|			else {
  107|     70|				buf[sizeof(buf) - 1] = '\0';
  108|     70|				sc_log(card->ctx,  "SetCOS EID applet %s is not supported", (char *) buf);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  109|     70|				return 0;
  110|     70|			}
  111|    140|			return 1;
  112|    210|		}
  113|       |
  114|    637|		return 0;
  115|    847|	}
  116|      3|	card->flags = setcos_atrs[i].flags;
  117|      3|	return 1;
  118|    862|}
card-setcos.c:match_hist_bytes:
   64|    859|{
   65|    859|	const char *src = (const char *) card->reader->atr_info.hist_bytes;
   66|    859|	size_t srclen = card->reader->atr_info.hist_bytes_len;
   67|    859|	size_t offset = 0;
   68|       |
   69|    859|	if (len == 0)
  ------------------
  |  Branch (69:6): [True: 859, False: 0]
  ------------------
   70|    859|		len = strlen(str);
   71|    859|	if (srclen < len)
  ------------------
  |  Branch (71:6): [True: 720, False: 139]
  ------------------
   72|    720|		return 0;
   73|  1.11k|	while (srclen - offset > len) {
  ------------------
  |  Branch (73:9): [True: 988, False: 127]
  ------------------
   74|    988|		if (memcmp(src + offset, str, len) == 0) {
  ------------------
  |  Branch (74:7): [True: 12, False: 976]
  ------------------
   75|     12|			return 1;
   76|     12|		}
   77|    976|		offset++;
   78|    976|	}
   79|    127|	return 0;
   80|    139|}
card-setcos.c:setcos_init:
  133|    155|{
  134|    155|	card->name = "SetCOS";
  135|       |
  136|       |	/* Handle unknown or forced cards */
  137|    155|	if (card->type < 0) {
  ------------------
  |  Branch (137:6): [True: 0, False: 155]
  ------------------
  138|      0|		card->type = SC_CARD_TYPE_SETCOS_GENERIC;
  139|      0|	}
  140|       |
  141|    155|	switch (card->type) {
  142|      0|	case SC_CARD_TYPE_SETCOS_NIDEL:
  ------------------
  |  Branch (142:2): [True: 0, False: 155]
  ------------------
  143|      0|		card->cla = 0x00;
  144|      0|		select_pkcs15_app(card);
  145|      0|		if (card->flags & SC_CARD_FLAG_RNG)
  ------------------
  |  |  543|      0|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  |  Branch (145:7): [True: 0, False: 0]
  ------------------
  146|      0|			card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|      0|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  147|      0|		break;
  148|      3|	case SC_CARD_TYPE_SETCOS_44:
  ------------------
  |  Branch (148:2): [True: 3, False: 152]
  ------------------
  149|     32|	case SC_CARD_TYPE_SETCOS_EID_V2_0:
  ------------------
  |  Branch (149:2): [True: 29, False: 126]
  ------------------
  150|    143|	case SC_CARD_TYPE_SETCOS_EID_V2_1:
  ------------------
  |  Branch (150:2): [True: 111, False: 44]
  ------------------
  151|    143|		card->cla = 0x00;
  152|    143|		card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  564|    143|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  153|    143|		card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|    143|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  154|    143|		card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|    143|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  155|    143|		break;
  156|     12|	default:
  ------------------
  |  Branch (156:2): [True: 12, False: 143]
  ------------------
  157|       |		/* XXX: Get SetCOS version */
  158|     12|		card->cla = 0x80;	/* SetCOS 4.3.x */
  159|       |		/* State that we have an RNG */
  160|     12|		card->caps |= SC_CARD_CAP_RNG;
  ------------------
  |  |  557|     12|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  161|     12|		break;
  162|    155|	}
  163|       |
  164|    155|	switch (card->type) {
  ------------------
  |  Branch (164:10): [True: 143, False: 12]
  ------------------
  165|      0|	case SC_CARD_TYPE_SETCOS_PKI: {
  ------------------
  |  Branch (165:2): [True: 0, False: 155]
  ------------------
  166|      0|		unsigned long flags;
  167|       |
  168|      0|		flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|      0|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              		flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  120|      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) */
  |  |  ------------------
  |  |  |  |  118|      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) */
  |  |  ------------------
  |  |  |  |  119|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  169|      0|		flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  142|      0|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              		flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  143|      0|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  170|       |
  171|      0|		_sc_card_add_rsa_alg(card, 1024, flags, 0);
  172|      0|		_sc_card_add_rsa_alg(card, 2048, flags, 0);
  173|      0|	} break;
  174|      3|	case SC_CARD_TYPE_SETCOS_44:
  ------------------
  |  Branch (174:2): [True: 3, False: 152]
  ------------------
  175|      3|	case SC_CARD_TYPE_SETCOS_NIDEL:
  ------------------
  |  Branch (175:2): [True: 0, False: 155]
  ------------------
  176|     32|	case SC_CARD_TYPE_SETCOS_EID_V2_0:
  ------------------
  |  Branch (176:2): [True: 29, False: 126]
  ------------------
  177|    143|	case SC_CARD_TYPE_SETCOS_EID_V2_1:
  ------------------
  |  Branch (177:2): [True: 111, False: 44]
  ------------------
  178|    143|		{
  179|    143|			unsigned long flags;
  180|       |
  181|    143|			flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  111|    143|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
              			flags = SC_ALGORITHM_RSA_RAW | SC_ALGORITHM_RSA_PAD_PKCS1;
  ------------------
  |  |  120|    143|#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) */
  |  |  ------------------
  |  |  |  |  118|    143|#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) */
  |  |  ------------------
  |  |  |  |  119|    143|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  182|    143|			flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  142|    143|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
              			flags |= SC_ALGORITHM_RSA_HASH_NONE | SC_ALGORITHM_RSA_HASH_SHA1;
  ------------------
  |  |  143|    143|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  183|    143|			flags |= SC_ALGORITHM_ONBOARD_KEY_GEN;
  ------------------
  |  |  102|    143|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  184|       |
  185|    143|			_sc_card_add_rsa_alg(card, 512, flags, 0);
  186|    143|			_sc_card_add_rsa_alg(card, 768, flags, 0);
  187|    143|			_sc_card_add_rsa_alg(card, 1024, flags, 0);
  188|    143|			_sc_card_add_rsa_alg(card, 2048, flags, 0);
  189|    143|		}
  190|    143|		break;
  191|    155|	}
  192|    155|	return 0;
  193|    155|}
card-setcos.c:setcos_create_file:
  501|     38|{
  502|     38|	if (card->type == SC_CARD_TYPE_SETCOS_44 || SETCOS_IS_EID_APPLET(card))
  ------------------
  |  |   46|     38|#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: 21, False: 17]
  |  |  |  Branch (46:85): [True: 15, False: 2]
  |  |  ------------------
  ------------------
  |  Branch (502:6): [True: 0, False: 38]
  ------------------
  503|     36|		return setcos_create_file_44(card, file);
  504|       |
  505|      2|	if (file->prop_attr_len == 0)
  ------------------
  |  Branch (505:6): [True: 2, False: 0]
  ------------------
  506|      2|		sc_file_set_prop_attr(file, (const u8 *) "\x03\x00\x00", 3);
  507|      2|	if (file->sec_attr_len == 0) {
  ------------------
  |  Branch (507:6): [True: 2, False: 0]
  ------------------
  508|      2|		int idx[6], i;
  509|      2|		u8 buf[6];
  510|       |
  511|      2|		if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|      2|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (511:7): [True: 1, False: 1]
  ------------------
  512|      1|			const int df_idx[6] = {
  513|      1|				SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  166|      1|#define SC_AC_OP_SELECT			0
  ------------------
              				SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  167|      1|#define SC_AC_OP_LOCK			1
  ------------------
              				SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  168|      1|#define SC_AC_OP_DELETE			2
  ------------------
  514|      1|				SC_AC_OP_CREATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  169|      1|#define SC_AC_OP_CREATE			3
  ------------------
              				SC_AC_OP_CREATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|      1|#define SC_AC_OP_REHABILITATE		4
  ------------------
  515|      1|				SC_AC_OP_INVALIDATE
  ------------------
  |  |  171|      1|#define SC_AC_OP_INVALIDATE		5
  ------------------
  516|      1|			};
  517|      7|			for (i = 0; i < 6; i++)
  ------------------
  |  Branch (517:16): [True: 6, False: 1]
  ------------------
  518|      6|				idx[i] = df_idx[i];
  519|      1|		} else {
  520|      1|			const int ef_idx[6] = {
  521|      1|				SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  188|      1|#define SC_AC_OP_READ			22
  ------------------
              				SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
              				SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  190|      1|#define SC_AC_OP_WRITE			24
  ------------------
  522|      1|				SC_AC_OP_ERASE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  202|      1|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|      1|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
              				SC_AC_OP_ERASE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|      1|#define SC_AC_OP_REHABILITATE		4
  ------------------
  523|      1|				SC_AC_OP_INVALIDATE
  ------------------
  |  |  171|      1|#define SC_AC_OP_INVALIDATE		5
  ------------------
  524|      1|			};
  525|      7|			for (i = 0; i < 6; i++)
  ------------------
  |  Branch (525:16): [True: 6, False: 1]
  ------------------
  526|      6|				idx[i] = ef_idx[i];
  527|      1|		}
  528|     14|		for (i = 0; i < 6; i++) {
  ------------------
  |  Branch (528:15): [True: 12, False: 2]
  ------------------
  529|     12|			const struct sc_acl_entry *entry;
  530|     12|			entry = sc_file_get_acl_entry(file, idx[i]);
  531|     12|			buf[i] = acl_to_byte(entry);
  532|     12|		}
  533|       |
  534|      2|		sc_file_set_sec_attr(file, buf, 6);
  535|      2|	}
  536|       |
  537|      2|	return iso_ops->create_file(card, file);
  538|     38|}
card-setcos.c:setcos_create_file_44:
  382|     36|{
  383|     36|	const u8 bFileStatus = file->status == SC_FILE_STATUS_CREATION ?
  ------------------
  |  |  240|     36|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (383:25): [True: 18, False: 18]
  ------------------
  384|     18|		SETEC_LCSI_CREATE : SETEC_LCSI_ACTIVATED;
  ------------------
  |  |   49|     18|#define SETEC_LCSI_CREATE      0x01
  ------------------
              		SETEC_LCSI_CREATE : SETEC_LCSI_ACTIVATED;
  ------------------
  |  |   51|     54|#define SETEC_LCSI_ACTIVATED   0x07
  ------------------
  385|     36|	u8 bCommands_always = 0;
  386|     36|	int pins[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
  387|     36|	u8 bCommands_pin[sizeof(pins)/sizeof(pins[0])]; /* both 7 entries big */
  388|     36|	u8 bCommands_key = 0;
  389|     36|	u8 bNumber = 0;
  390|     36|	u8 bKeyNumber = 0;
  391|     36|	unsigned int bMethod = 0;
  392|       |
  393|       |	/* -1 means RFU */
  394|     36|	const int df_idx[8] = {  /* byte 1 = OpenSC type of AC Bit0,  byte 2 = OpenSC type of AC Bit1 ...*/
  395|     36|		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  168|     36|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  169|     36|#define SC_AC_OP_CREATE			3
  ------------------
              		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  169|     36|#define SC_AC_OP_CREATE			3
  ------------------
  396|     36|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|     36|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|     36|#define SC_AC_OP_REHABILITATE		4
  ------------------
  397|     36|		SC_AC_OP_LOCK, SC_AC_OP_DELETE, -1};
  ------------------
  |  |  167|     36|#define SC_AC_OP_LOCK			1
  ------------------
              		SC_AC_OP_LOCK, SC_AC_OP_DELETE, -1};
  ------------------
  |  |  168|     36|#define SC_AC_OP_DELETE			2
  ------------------
  398|     36|	const int ef_idx[8] = {  /* note: SC_AC_OP_SELECT to be ignored, actually RFU */
  399|     36|		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  188|     36|#define SC_AC_OP_READ			22
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  189|     36|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  190|     36|#define SC_AC_OP_WRITE			24
  ------------------
  400|     36|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|     36|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|     36|#define SC_AC_OP_REHABILITATE		4
  ------------------
  401|     36|		-1, SC_AC_OP_ERASE, -1};
  ------------------
  |  |  202|     36|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     36|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  402|     36|	const int efi_idx[8] = {  /* internal EF used for RSA keys */
  403|     36|		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  188|     36|#define SC_AC_OP_READ			22
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  202|     36|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     36|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  189|     36|#define SC_AC_OP_UPDATE			23
  ------------------
  404|     36|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|     36|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|     36|#define SC_AC_OP_REHABILITATE		4
  ------------------
  405|     36|		-1, SC_AC_OP_ERASE, -1};
  ------------------
  |  |  202|     36|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     36|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  406|       |
  407|       |	/* Set file creation status  */
  408|     36|	sc_file_set_prop_attr(file, &bFileStatus, 1);
  409|       |
  410|       |	/* Build ACL from local structure = get AC for each operation group */
  411|     36|	if (file->sec_attr_len == 0) {
  ------------------
  |  Branch (411:6): [True: 36, False: 0]
  ------------------
  412|     36|		const int* p_idx;
  413|     36|		int	       i;
  414|     36|		int	       len = 0;
  415|     36|		u8         bBuf[64];
  416|       |
  417|       |		/* Get specific operation groups for specified file-type */
  418|     36|		switch (file->type){
  419|     16|		case SC_FILE_TYPE_DF:           /* DF */
  ------------------
  |  |  214|     16|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (419:3): [True: 16, False: 20]
  ------------------
  420|     16|			p_idx = df_idx;
  421|     16|			break;
  422|      1|		case SC_FILE_TYPE_INTERNAL_EF:  /* EF for RSA keys */
  ------------------
  |  |  215|      1|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (422:3): [True: 1, False: 35]
  ------------------
  423|      1|			p_idx = efi_idx;
  424|      1|			break;
  425|     19|		default:                        /* SC_FILE_TYPE_WORKING_EF */
  ------------------
  |  Branch (425:3): [True: 19, False: 17]
  ------------------
  426|     19|			p_idx = ef_idx;
  427|     19|			break;
  428|     36|		}
  429|       |
  430|       |		/* Get enabled commands + required Keys/Pins  */
  431|     36|		memset(bCommands_pin, 0, sizeof(bCommands_pin));
  432|    317|		for (i = 7; i >= 0; i--) {  /* for each AC Setcos operation */
  ------------------
  |  Branch (432:15): [True: 282, False: 35]
  ------------------
  433|    282|			int pin_index;
  434|    282|			bCommands_always <<= 1;
  435|    282|			bCommands_key <<= 1;
  436|       |
  437|    282|			if (p_idx[i] == -1)  /* -1 means that bit is RFU -> set to 0 */
  ------------------
  |  Branch (437:8): [True: 55, False: 227]
  ------------------
  438|     55|				continue;
  439|       |
  440|    227|			bMethod = acl_to_byte_44(file->acl[ p_idx[i] ], &bNumber);
  441|       |			/* Convert to OpenSc-index, convert to pin/key number */
  442|    227|			switch(bMethod){
  ------------------
  |  Branch (442:11): [True: 220, False: 7]
  ------------------
  443|    158|			case SC_AC_NONE:			/* always allowed */
  ------------------
  |  |  150|    158|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (443:4): [True: 158, False: 69]
  ------------------
  444|    158|				bCommands_always |= 1;
  445|    158|				break;
  446|     62|			case SC_AC_CHV:				/* pin */
  ------------------
  |  |  151|     62|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (446:4): [True: 62, False: 165]
  ------------------
  447|     62|				if ((bNumber & 0x7F) == 0 || (bNumber & 0x7F) > 7) {
  ------------------
  |  Branch (447:9): [True: 0, False: 62]
  |  Branch (447:34): [True: 1, False: 61]
  ------------------
  448|      1|					sc_log(card->ctx,  "SetCOS 4.4 PIN refs can only be 1..7\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  449|      1|					return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  450|      1|				}
  451|     61|				pin_index = setcos_pin_index_44(pins, sizeof(pins) / sizeof(pins[0]), (int)bNumber);
  452|     61|				if (pin_index < 0) {
  ------------------
  |  Branch (452:9): [True: 0, False: 61]
  ------------------
  453|      0|					return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  454|      0|				}
  455|     61|				bCommands_pin[pin_index] |= 1 << i;
  456|     61|				break;
  457|      0|			case SC_AC_TERM:			/* key */
  ------------------
  |  |  152|      0|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (457:4): [True: 0, False: 227]
  ------------------
  458|      0|				bKeyNumber = bNumber;	/* There should be only 1 key */
  459|      0|				bCommands_key |= 1;
  460|      0|				break;
  461|    227|			}
  462|    227|		}
  463|       |
  464|       |		/* Add the commands that are always allowed */
  465|     35|		if (bCommands_always) {
  ------------------
  |  Branch (465:7): [True: 33, False: 2]
  ------------------
  466|     33|			bBuf[len++] = 1;
  467|     33|			bBuf[len++] = bCommands_always;
  468|     33|		}
  469|       |		/* Add commands that require pins */
  470|     62|		for (i = 0; i < (int)sizeof(bCommands_pin) && pins[i] != -1; i++) {
  ------------------
  |  Branch (470:15): [True: 62, False: 0]
  |  Branch (470:49): [True: 27, False: 35]
  ------------------
  471|     27|			bBuf[len++] = 2;
  472|     27|			bBuf[len++] = bCommands_pin[i];
  473|     27|			if (SETCOS_IS_EID_APPLET(card))
  ------------------
  |  |   46|     27|#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: 13, False: 14]
  |  |  |  Branch (46:85): [True: 14, False: 0]
  |  |  ------------------
  ------------------
  474|     27|				bBuf[len++] = pins[i];  /* pin ref */
  475|      0|			else
  476|      0|				bBuf[len++] = pins[i] & 0x07;  /* pin ref */
  477|     27|		}
  478|       |		/* Add commands that require the key */
  479|     35|		if (bCommands_key) {
  ------------------
  |  Branch (479:7): [True: 0, False: 35]
  ------------------
  480|      0|			bBuf[len++] = 2 | 0x20;			/* indicate keyNumber present */
  481|      0|			bBuf[len++] = bCommands_key;
  482|      0|			bBuf[len++] = bKeyNumber;
  483|      0|		}
  484|       |		/* RSA signing/decryption requires AC adaptive coding,  can't be put
  485|       |		   in AC simple coding. Only implemented for pins, not for a key. */
  486|     35|		if ( (file->type == SC_FILE_TYPE_INTERNAL_EF) &&
  ------------------
  |  |  215|     35|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (486:8): [True: 1, False: 34]
  ------------------
  487|      1|		     (acl_to_byte_44(file->acl[SC_AC_OP_CRYPTO], &bNumber) == SC_AC_CHV) ) {
  ------------------
  |  |  173|      1|#define SC_AC_OP_CRYPTO			7
  ------------------
              		     (acl_to_byte_44(file->acl[SC_AC_OP_CRYPTO], &bNumber) == SC_AC_CHV) ) {
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (487:8): [True: 0, False: 1]
  ------------------
  488|      0|			bBuf[len++] = 0x83;
  489|      0|			bBuf[len++] = 0x01;
  490|      0|			bBuf[len++] = 0x2A;  /* INS byte for the sign/decrypt APDU */
  491|      0|			bBuf[len++] = bNumber & 0x07;  /* pin ref */
  492|      0|		}
  493|       |
  494|     35|		sc_file_set_sec_attr(file, bBuf, len);
  495|     35|	}
  496|       |
  497|     35|	return iso_ops->create_file(card, file);
  498|     36|}
card-setcos.c:acl_to_byte_44:
  347|    228|{
  348|       |	/* Handle special fixed values */
  349|    228|	if (e == (sc_acl_entry_t *) 1)           /* SC_AC_NEVER */
  ------------------
  |  Branch (349:6): [True: 5, False: 223]
  ------------------
  350|      5|		return SC_AC_NEVER;
  ------------------
  |  |  163|      5|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  351|    223|	else if ((e == (sc_acl_entry_t *) 2) ||  /* SC_AC_NONE */
  ------------------
  |  Branch (351:11): [True: 159, False: 64]
  ------------------
  352|     64|	         (e == (sc_acl_entry_t *) 3) ||  /* SC_AC_UNKNOWN */
  ------------------
  |  Branch (352:11): [True: 0, False: 64]
  ------------------
  353|     64|	         (e == (sc_acl_entry_t *) 0))
  ------------------
  |  Branch (353:11): [True: 0, False: 64]
  ------------------
  354|    159|		return SC_AC_NONE;
  ------------------
  |  |  150|    159|#define SC_AC_NONE			0x00000000
  ------------------
  355|       |
  356|       |	/* Handle standard values */
  357|     64|	*p_bNumber = e->key_ref;
  358|     64|	return(e->method);
  359|    228|}
card-setcos.c:setcos_pin_index_44:
  364|     61|{
  365|     61|	int i;
  366|     77|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (366:14): [True: 77, False: 0]
  ------------------
  367|     77|		if (pins[i] == pin)
  ------------------
  |  Branch (367:7): [True: 34, False: 43]
  ------------------
  368|     34|			return i;
  369|     43|		if (pins[i] == -1) {
  ------------------
  |  Branch (369:7): [True: 27, False: 16]
  ------------------
  370|     27|			pins[i] = pin;
  371|     27|			return i;
  372|     27|		}
  373|     43|	}
  374|      0|	if (i == len)
  ------------------
  |  Branch (374:6): [True: 0, False: 0]
  ------------------
  375|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  376|      0|	return 0;
  377|      0|}
card-setcos.c:acl_to_byte:
  322|     12|{
  323|     12|	switch (e->method) {
  ------------------
  |  Branch (323:10): [True: 12, False: 0]
  ------------------
  324|      3|	case SC_AC_NONE:
  ------------------
  |  |  150|      3|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (324:2): [True: 3, False: 9]
  ------------------
  325|      3|		return 0x00;
  326|      1|	case SC_AC_CHV:
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (326:2): [True: 1, False: 11]
  ------------------
  327|      1|		switch (e->key_ref) {
  328|      0|		case 1:
  ------------------
  |  Branch (328:3): [True: 0, False: 1]
  ------------------
  329|      0|			return 0x01;
  330|      0|			break;
  331|      0|		case 2:
  ------------------
  |  Branch (331:3): [True: 0, False: 1]
  ------------------
  332|      0|			return 0x02;
  333|      0|			break;
  334|      1|		default:
  ------------------
  |  Branch (334:3): [True: 1, False: 0]
  ------------------
  335|      1|			return 0x00;
  336|      1|		}
  337|      0|		break;
  338|      0|	case SC_AC_TERM:
  ------------------
  |  |  152|      0|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  |  Branch (338:2): [True: 0, False: 12]
  ------------------
  339|      0|		return 0x04;
  340|      8|	case SC_AC_NEVER:
  ------------------
  |  |  163|      8|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (340:2): [True: 8, False: 4]
  ------------------
  341|      8|		return 0x0F;
  342|     12|	}
  343|      0|	return 0x00;
  344|     12|}
card-setcos.c:setcos_select_file:
  895|  33.1k|{
  896|  33.1k|	int r;
  897|       |
  898|  33.1k|	r = iso_ops->select_file(card, in_path, file);
  899|  33.1k|	if (r)
  ------------------
  |  Branch (899:6): [True: 30.1k, False: 3.02k]
  ------------------
  900|  30.1k|		return r;
  901|  3.02k|	if (file != NULL) {
  ------------------
  |  Branch (901:6): [True: 2.69k, False: 326]
  ------------------
  902|  2.69k|		if (card->type == SC_CARD_TYPE_SETCOS_44 ||
  ------------------
  |  Branch (902:7): [True: 58, False: 2.63k]
  ------------------
  903|  2.63k|		    card->type == SC_CARD_TYPE_SETCOS_NIDEL ||
  ------------------
  |  Branch (903:7): [True: 0, False: 2.63k]
  ------------------
  904|  2.63k|		    SETCOS_IS_EID_APPLET(card))
  ------------------
  |  |   46|  2.63k|#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: 429, False: 2.20k]
  |  |  |  Branch (46:85): [True: 2.18k, False: 25]
  |  |  ------------------
  ------------------
  905|  2.67k|			parse_sec_attr_44(*file, (*file)->sec_attr, (*file)->sec_attr_len);
  906|     25|		else
  907|     25|			parse_sec_attr(*file, (*file)->sec_attr, (*file)->sec_attr_len);
  908|  2.69k|	}
  909|  3.02k|	return 0;
  910|  33.1k|}
card-setcos.c:parse_sec_attr_44:
  740|  2.67k|{
  741|       |	/* OpenSc Operation values for each command operation-type */
  742|  2.67k|	const int df_idx[8] = {	 /* byte 1 = OpenSC type of AC Bit0,  byte 2 = OpenSC type of AC Bit1 ...*/
  743|  2.67k|		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  168|  2.67k|#define SC_AC_OP_DELETE			2
  ------------------
              		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  169|  2.67k|#define SC_AC_OP_CREATE			3
  ------------------
              		SC_AC_OP_DELETE, SC_AC_OP_CREATE, SC_AC_OP_CREATE,
  ------------------
  |  |  169|  2.67k|#define SC_AC_OP_CREATE			3
  ------------------
  744|  2.67k|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|  2.67k|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|  2.67k|#define SC_AC_OP_REHABILITATE		4
  ------------------
  745|  2.67k|		SC_AC_OP_LOCK, SC_AC_OP_DELETE, -1};
  ------------------
  |  |  167|  2.67k|#define SC_AC_OP_LOCK			1
  ------------------
              		SC_AC_OP_LOCK, SC_AC_OP_DELETE, -1};
  ------------------
  |  |  168|  2.67k|#define SC_AC_OP_DELETE			2
  ------------------
  746|  2.67k|	const int ef_idx[8] = {
  747|  2.67k|		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  188|  2.67k|#define SC_AC_OP_READ			22
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  189|  2.67k|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  190|  2.67k|#define SC_AC_OP_WRITE			24
  ------------------
  748|  2.67k|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|  2.67k|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|  2.67k|#define SC_AC_OP_REHABILITATE		4
  ------------------
  749|  2.67k|		-1, SC_AC_OP_ERASE, -1};
  ------------------
  |  |  202|  2.67k|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|  2.67k|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  750|  2.67k|	const int efi_idx[8] = { /* internal EF used for RSA keys */
  751|  2.67k|		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  188|  2.67k|#define SC_AC_OP_READ			22
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  202|  2.67k|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|  2.67k|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
              		SC_AC_OP_READ, SC_AC_OP_ERASE, SC_AC_OP_UPDATE,
  ------------------
  |  |  189|  2.67k|#define SC_AC_OP_UPDATE			23
  ------------------
  752|  2.67k|		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  171|  2.67k|#define SC_AC_OP_INVALIDATE		5
  ------------------
              		SC_AC_OP_INVALIDATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|  2.67k|#define SC_AC_OP_REHABILITATE		4
  ------------------
  753|  2.67k|		-1, SC_AC_OP_ERASE, -1};
  ------------------
  |  |  202|  2.67k|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|  2.67k|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  754|       |
  755|  2.67k|	u8		bValue;
  756|  2.67k|	int		i;
  757|  2.67k|	int		iKeyRef = 0;
  758|  2.67k|	int		iMethod;
  759|  2.67k|	int		iPinCount;
  760|  2.67k|	int		iOffset = 0;
  761|  2.67k|	int		iOperation;
  762|  2.67k|	const int*	p_idx;
  763|       |
  764|       |	/* Check all sub-AC definitions within the total AC */
  765|  4.61k|	while (len > 1 && (size_t)iOffset < len) {	/* minimum length = 2 */
  ------------------
  |  Branch (765:9): [True: 2.63k, False: 1.97k]
  |  Branch (765:20): [True: 2.44k, False: 192]
  ------------------
  766|  2.44k|		size_t iACLen   = buf[iOffset] & 0x0F;
  767|  2.44k|		if (iACLen >= len)
  ------------------
  |  Branch (767:7): [True: 277, False: 2.16k]
  ------------------
  768|    277|			break;
  769|       |
  770|  2.16k|		iMethod = SC_AC_NONE;		/* default no authentication required */
  ------------------
  |  |  150|  2.16k|#define SC_AC_NONE			0x00000000
  ------------------
  771|       |
  772|  2.16k|		if (buf[iOffset] & 0X80) { /* AC in adaptive coding */
  ------------------
  |  Branch (772:7): [True: 828, False: 1.33k]
  ------------------
  773|       |			/* Evaluates only the command-byte, not the optional P1/P2/Option bytes */
  774|    828|			size_t	iParmLen = 1;			/* command-byte is always present */
  775|    828|			size_t	iKeyLen  = 0;			/* Encryption key is optional */
  776|       |
  777|    828|			if (buf[iOffset]   & 0x20) iKeyLen++;
  ------------------
  |  Branch (777:8): [True: 401, False: 427]
  ------------------
  778|    828|			if (buf[iOffset+1] & 0x40) iParmLen++;
  ------------------
  |  Branch (778:8): [True: 484, False: 344]
  ------------------
  779|    828|			if (buf[iOffset+1] & 0x20) iParmLen++;
  ------------------
  |  Branch (779:8): [True: 422, False: 406]
  ------------------
  780|    828|			if (buf[iOffset+1] & 0x10) iParmLen++;
  ------------------
  |  Branch (780:8): [True: 487, False: 341]
  ------------------
  781|    828|			if (buf[iOffset+1] & 0x08) iParmLen++;
  ------------------
  |  Branch (781:8): [True: 303, False: 525]
  ------------------
  782|       |
  783|       |			/* Get KeyNumber if available */
  784|    828|			if(iKeyLen) {
  ------------------
  |  Branch (784:7): [True: 401, False: 427]
  ------------------
  785|    401|				int iSC;
  786|    401|				if (len < 1 + iACLen)
  ------------------
  |  Branch (786:9): [True: 0, False: 401]
  ------------------
  787|      0|					break;
  788|    401|				iSC = buf[iOffset+iACLen];
  789|       |
  790|    401|				switch( (iSC>>5) & 0x03 ){
  ------------------
  |  Branch (790:13): [True: 401, False: 0]
  ------------------
  791|     60|				case 0:
  ------------------
  |  Branch (791:5): [True: 60, False: 341]
  ------------------
  792|     60|					iMethod = SC_AC_TERM;		/* key authentication */
  ------------------
  |  |  152|     60|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  793|     60|					break;
  794|      0|				case 1:
  ------------------
  |  Branch (794:5): [True: 0, False: 401]
  ------------------
  795|      0|					iMethod = SC_AC_AUT;		/* key authentication  */
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  796|      0|					break;
  797|     12|				case 2:
  ------------------
  |  Branch (797:5): [True: 12, False: 389]
  ------------------
  798|    341|				case 3:
  ------------------
  |  Branch (798:5): [True: 329, False: 72]
  ------------------
  799|    341|					iMethod = SC_AC_PRO;		/* secure messaging */
  ------------------
  |  |  153|    341|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  800|    341|					break;
  801|    401|				}
  802|    401|				iKeyRef = iSC & 0x1F;			/* get key number */
  803|    401|			}
  804|       |
  805|       |			/* Get PinNumber if available */
  806|    828|			if (iACLen > (1+iParmLen+iKeyLen)) {  /* check via total length if pin is present */
  ------------------
  |  Branch (806:8): [True: 83, False: 745]
  ------------------
  807|     83|				if (len < 1+1+1+(size_t)iParmLen)
  ------------------
  |  Branch (807:9): [True: 0, False: 83]
  ------------------
  808|      0|					break;
  809|     83|				iKeyRef = buf[iOffset+1+1+iParmLen];  /* PTL + AM-header + parameter-bytes */
  810|     83|				iMethod = SC_AC_CHV;
  ------------------
  |  |  151|     83|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  811|     83|			}
  812|       |
  813|       |			/* Convert SETCOS command to OpenSC command group */
  814|    828|			if (len < 1+2)
  ------------------
  |  Branch (814:8): [True: 226, False: 602]
  ------------------
  815|    226|				break;
  816|    602|			switch(buf[iOffset+2]){
  817|     12|			case 0x2A:			/* crypto operation */
  ------------------
  |  Branch (817:4): [True: 12, False: 590]
  ------------------
  818|     12|				iOperation = SC_AC_OP_CRYPTO;
  ------------------
  |  |  173|     12|#define SC_AC_OP_CRYPTO			7
  ------------------
  819|     12|				break;
  820|      0|			case 0x46:			/* key-generation operation */
  ------------------
  |  Branch (820:4): [True: 0, False: 602]
  ------------------
  821|      0|				iOperation = SC_AC_OP_UPDATE;
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  822|      0|				break;
  823|    590|			default:
  ------------------
  |  Branch (823:4): [True: 590, False: 12]
  ------------------
  824|    590|				iOperation = SC_AC_OP_SELECT;
  ------------------
  |  |  166|    590|#define SC_AC_OP_SELECT			0
  ------------------
  825|    590|				break;
  826|    602|			}
  827|    602|			sc_file_add_acl_entry(file, iOperation, iMethod, iKeyRef);
  828|    602|		}
  829|  1.33k|		else { /* AC in simple coding */
  830|       |			   /* Initial AC is treated as an operational AC */
  831|       |
  832|       |			/* Get specific Cmd groups for specified file-type */
  833|  1.33k|			switch (file->type) {
  834|     80|			case SC_FILE_TYPE_DF:            /* DF */
  ------------------
  |  |  214|     80|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (834:4): [True: 80, False: 1.25k]
  ------------------
  835|     80|				p_idx = df_idx;
  836|     80|				break;
  837|     35|			case SC_FILE_TYPE_INTERNAL_EF:   /* EF for RSA keys */
  ------------------
  |  |  215|     35|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (837:4): [True: 35, False: 1.30k]
  ------------------
  838|     35|				p_idx = efi_idx;
  839|     35|				break;
  840|  1.22k|			default:                         /* EF */
  ------------------
  |  Branch (840:4): [True: 1.22k, False: 115]
  ------------------
  841|  1.22k|				p_idx = ef_idx;
  842|  1.22k|				break;
  843|  1.33k|			}
  844|       |
  845|       |			/* Encryption key present ? */
  846|  1.33k|			iPinCount = iACLen > 0 ? (int)iACLen - 1 : 0;
  ------------------
  |  Branch (846:16): [True: 1.20k, False: 131]
  ------------------
  847|       |
  848|  1.33k|			if (buf[iOffset] & 0x20) {
  ------------------
  |  Branch (848:8): [True: 160, False: 1.17k]
  ------------------
  849|    160|				int iSC;
  850|    160|				if (len < 1 + (size_t)iACLen)
  ------------------
  |  Branch (850:9): [True: 0, False: 160]
  ------------------
  851|      0|					break;
  852|    160|				iSC = buf[iOffset + iACLen];
  853|       |
  854|    160|				switch( (iSC>>5) & 0x03 ) {
  ------------------
  |  Branch (854:13): [True: 160, False: 0]
  ------------------
  855|    146|				case 0:
  ------------------
  |  Branch (855:5): [True: 146, False: 14]
  ------------------
  856|    146|					iMethod = SC_AC_TERM;		/* key authentication */
  ------------------
  |  |  152|    146|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  857|    146|					break;
  858|      5|				case 1:
  ------------------
  |  Branch (858:5): [True: 5, False: 155]
  ------------------
  859|      5|					iMethod = SC_AC_AUT;		/* key authentication  */
  ------------------
  |  |  154|      5|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  860|      5|					break;
  861|      1|				case 2:
  ------------------
  |  Branch (861:5): [True: 1, False: 159]
  ------------------
  862|      9|				case 3:
  ------------------
  |  Branch (862:5): [True: 8, False: 152]
  ------------------
  863|      9|					iMethod = SC_AC_PRO;		/* secure messaging */
  ------------------
  |  |  153|      9|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  864|      9|					break;
  865|    160|				}
  866|    160|				iKeyRef = iSC & 0x1F;			/* get key number */
  867|       |
  868|    160|				iPinCount--;				/* one byte used for keyReference  */
  869|    160|			}
  870|       |
  871|       |			/* Pin present ? */
  872|  1.33k|			if ( iPinCount > 0 ) {
  ------------------
  |  Branch (872:9): [True: 190, False: 1.14k]
  ------------------
  873|    190|				if (len < 1 + 2)
  ------------------
  |  Branch (873:9): [True: 0, False: 190]
  ------------------
  874|      0|					break;
  875|    190|				iKeyRef = buf[iOffset + 2];	/* pin ref */
  876|    190|				iMethod = SC_AC_CHV;
  ------------------
  |  |  151|    190|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  877|    190|			}
  878|       |
  879|       |			/* Add AC for each command-operationType into OpenSc structure */
  880|  1.33k|			bValue = buf[iOffset + 1];
  881|  12.0k|			for (i = 0; i < 8; i++) {
  ------------------
  |  Branch (881:16): [True: 10.7k, False: 1.33k]
  ------------------
  882|  10.7k|				if((bValue & 1) && (p_idx[i] >= 0))
  ------------------
  |  Branch (882:8): [True: 7.07k, False: 3.63k]
  |  Branch (882:24): [True: 5.90k, False: 1.16k]
  ------------------
  883|  5.90k|					sc_file_add_acl_entry(file, p_idx[i], iMethod, iKeyRef);
  884|  10.7k|				bValue >>= 1;
  885|  10.7k|			}
  886|  1.33k|		}
  887|       |		/* Current field treated, get next AC sub-field */
  888|  1.94k|		iOffset += iACLen +1;		/* AC + PTL-byte */
  889|  1.94k|		len     -= iACLen +1;
  890|  1.94k|	}
  891|  2.67k|}
card-setcos.c:parse_sec_attr:
  712|     25|{
  713|     25|	int i;
  714|     25|	int idx[6];
  715|       |
  716|     25|	if (len < 6)
  ------------------
  |  Branch (716:6): [True: 10, False: 15]
  ------------------
  717|     10|		return;
  718|     15|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     15|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (718:6): [True: 1, False: 14]
  ------------------
  719|      1|		const int df_idx[6] = {
  720|      1|			SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  166|      1|#define SC_AC_OP_SELECT			0
  ------------------
              			SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  167|      1|#define SC_AC_OP_LOCK			1
  ------------------
              			SC_AC_OP_SELECT, SC_AC_OP_LOCK, SC_AC_OP_DELETE,
  ------------------
  |  |  168|      1|#define SC_AC_OP_DELETE			2
  ------------------
  721|      1|			SC_AC_OP_CREATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  169|      1|#define SC_AC_OP_CREATE			3
  ------------------
              			SC_AC_OP_CREATE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|      1|#define SC_AC_OP_REHABILITATE		4
  ------------------
  722|      1|			SC_AC_OP_INVALIDATE
  ------------------
  |  |  171|      1|#define SC_AC_OP_INVALIDATE		5
  ------------------
  723|      1|		};
  724|      7|		for (i = 0; i < 6; i++)
  ------------------
  |  Branch (724:15): [True: 6, False: 1]
  ------------------
  725|      6|			idx[i] = df_idx[i];
  726|     14|	} else {
  727|     14|		const int ef_idx[6] = {
  728|     14|			SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  188|     14|#define SC_AC_OP_READ			22
  ------------------
              			SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  189|     14|#define SC_AC_OP_UPDATE			23
  ------------------
              			SC_AC_OP_READ, SC_AC_OP_UPDATE, SC_AC_OP_WRITE,
  ------------------
  |  |  190|     14|#define SC_AC_OP_WRITE			24
  ------------------
  729|     14|			SC_AC_OP_ERASE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  202|     14|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|     14|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
              			SC_AC_OP_ERASE, SC_AC_OP_REHABILITATE,
  ------------------
  |  |  170|     14|#define SC_AC_OP_REHABILITATE		4
  ------------------
  730|     14|			SC_AC_OP_INVALIDATE
  ------------------
  |  |  171|     14|#define SC_AC_OP_INVALIDATE		5
  ------------------
  731|     14|		};
  732|     98|		for (i = 0; i < 6; i++)
  ------------------
  |  Branch (732:15): [True: 84, False: 14]
  ------------------
  733|     84|			idx[i] = ef_idx[i];
  734|     14|	}
  735|    105|	for (i = 0; i < 6; i++)
  ------------------
  |  Branch (735:14): [True: 90, False: 15]
  ------------------
  736|     90|		add_acl_entry(file, idx[i], buf[i]);
  737|     15|}
card-setcos.c:add_acl_entry:
  683|     90|{
  684|     90|	unsigned int method, key_ref = SC_AC_KEY_REF_NONE;
  ------------------
  |  |  204|     90|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  685|       |
  686|     90|	switch (byte >> 4) {
  687|     19|	case 0:
  ------------------
  |  Branch (687:2): [True: 19, False: 71]
  ------------------
  688|     19|		method = SC_AC_NONE;
  ------------------
  |  |  150|     19|#define SC_AC_NONE			0x00000000
  ------------------
  689|     19|		break;
  690|      0|	case 1:
  ------------------
  |  Branch (690:2): [True: 0, False: 90]
  ------------------
  691|      0|		method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  692|      0|		key_ref = 1;
  693|      0|		break;
  694|      2|	case 2:
  ------------------
  |  Branch (694:2): [True: 2, False: 88]
  ------------------
  695|      2|		method = SC_AC_CHV;
  ------------------
  |  |  151|      2|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  696|      2|		key_ref = 2;
  697|      2|		break;
  698|      0|	case 4:
  ------------------
  |  Branch (698:2): [True: 0, False: 90]
  ------------------
  699|      0|		method = SC_AC_TERM;
  ------------------
  |  |  152|      0|#define SC_AC_TERM			0x00000002 /* Terminal auth. */
  ------------------
  700|      0|		break;
  701|     12|	case 15:
  ------------------
  |  Branch (701:2): [True: 12, False: 78]
  ------------------
  702|     12|		method = SC_AC_NEVER;
  ------------------
  |  |  163|     12|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  703|     12|		break;
  704|     57|	default:
  ------------------
  |  Branch (704:2): [True: 57, False: 33]
  ------------------
  705|     57|		method = SC_AC_UNKNOWN;
  ------------------
  |  |  162|     57|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  706|     57|		break;
  707|     90|	}
  708|     90|	sc_file_add_acl_entry(file, op, method, key_ref);
  709|     90|}
card-setcos.c:setcos_process_fci:
  936|  2.66k|{
  937|  2.66k|	int r = iso_ops->process_fci(card, file, buf, buflen);
  938|       |
  939|       |	/* SetCOS 4.4: RSA key file is an internal EF but it's
  940|       |	 * file descriptor doesn't seem to follow ISO7816. */
  941|  2.66k|	if (r >= 0 && (card->type == SC_CARD_TYPE_SETCOS_44 ||
  ------------------
  |  Branch (941:6): [True: 2.66k, False: 0]
  |  Branch (941:17): [True: 57, False: 2.60k]
  ------------------
  942|  2.63k|	               SETCOS_IS_EID_APPLET(card))) {
  ------------------
  |  |   46|  2.60k|#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: 408, False: 2.19k]
  |  |  |  Branch (46:85): [True: 2.17k, False: 23]
  |  |  ------------------
  ------------------
  943|  2.63k|		const u8 *tag;
  944|  2.63k|		size_t taglen = 1;
  945|  2.63k|		tag = (u8 *) sc_asn1_find_tag(card->ctx, buf, buflen, 0x82, &taglen);
  946|  2.63k|		if (tag != NULL && taglen == 1 && *tag == 0x11)
  ------------------
  |  Branch (946:7): [True: 1.34k, False: 1.28k]
  |  Branch (946:22): [True: 875, False: 474]
  |  Branch (946:37): [True: 16, False: 859]
  ------------------
  947|     16|			file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|     16|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  948|  2.63k|	}
  949|       |
  950|  2.66k|	return r;
  951|  2.66k|}
card-setcos.c:setcos_construct_fci:
  312|     37|{
  313|     37|	if (card->type == SC_CARD_TYPE_SETCOS_44 ||
  ------------------
  |  Branch (313:6): [True: 0, False: 37]
  ------------------
  314|     37|	    card->type == SC_CARD_TYPE_SETCOS_NIDEL ||
  ------------------
  |  Branch (314:6): [True: 0, False: 37]
  ------------------
  315|     37|	    SETCOS_IS_EID_APPLET(card))
  ------------------
  |  |   46|     37|#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: 21, False: 16]
  |  |  |  Branch (46:85): [True: 14, False: 2]
  |  |  ------------------
  ------------------
  316|     35|		return setcos_construct_fci_44(card, file, out, outlen);
  317|      2|	else
  318|      2|		return iso_ops->construct_fci(card, file, out, outlen);
  319|     37|}
card-setcos.c:setcos_construct_fci_44:
  198|     35|{
  199|     35|	u8 *p = out;
  200|     35|	u8 buf[64];
  201|     35|	const u8 *pin_key_info;
  202|     35|	int len;
  203|       |
  204|       |	/* Command */
  205|     35|	*p++ = 0x6F;
  206|     35|	p++;
  207|       |
  208|       |	/* Size (set to 0 for keys/PINs on a Java card) */
  209|     35|	if (SETCOS_IS_EID_APPLET(card) &&
  ------------------
  |  |   46|     70|#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: 21, False: 14]
  |  |  |  Branch (46:85): [True: 14, False: 0]
  |  |  ------------------
  ------------------
  210|     35|	    (file->type == SC_FILE_TYPE_INTERNAL_EF ||
  ------------------
  |  |  215|     70|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (210:7): [True: 1, False: 34]
  ------------------
  211|     34|	     (file->type == SC_FILE_TYPE_WORKING_EF && file->ef_structure == 0x22)))
  ------------------
  |  |  216|     68|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (211:8): [True: 15, False: 19]
  |  Branch (211:49): [True: 0, False: 15]
  ------------------
  212|      1|	     	buf[0] = buf[1] = 0x00;
  213|     34|	else {
  214|     34|		buf[0] = (file->size >> 8) & 0xFF;
  215|     34|		buf[1] = file->size & 0xFF;
  216|     34|	}
  217|     35|	sc_asn1_put_tag(0x81, buf, 2, p, *outlen - (p - out), &p);
  218|       |
  219|       |	/* Type */
  220|     35|	if (file->type_attr_len) {
  ------------------
  |  Branch (220:6): [True: 0, False: 35]
  ------------------
  221|      0|		memcpy(buf, file->type_attr, file->type_attr_len);
  222|      0|		sc_asn1_put_tag(0x82, buf, file->type_attr_len, p, *outlen - (p - out), &p);
  223|     35|	} else {
  224|     35|		u8	bLen = 1;
  225|       |
  226|     35|		buf[0] = file->shareable ? 0x40 : 0;
  ------------------
  |  Branch (226:12): [True: 0, False: 35]
  ------------------
  227|     35|		switch (file->type) {
  228|      1|		case SC_FILE_TYPE_INTERNAL_EF:				/* RSA keyfile */
  ------------------
  |  |  215|      1|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (228:3): [True: 1, False: 34]
  ------------------
  229|      1|			buf[0] = 0x11;
  230|      1|			break;
  231|     15|		case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|     15|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (231:3): [True: 15, False: 20]
  ------------------
  232|     15|			if (file->ef_structure == 0x22) {		/* pin-file */
  ------------------
  |  Branch (232:8): [True: 0, False: 15]
  ------------------
  233|      0|				buf[0] = 0x0A;				/* EF linear fixed EF for ISF keys */
  234|      0|				if (SETCOS_IS_EID_APPLET(card))
  ------------------
  |  |   46|      0|#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: 0, False: 0]
  |  |  |  Branch (46:85): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  235|      0|					bLen = 1;
  236|      0|				else {
  237|       |					/* Setcos V4.4 */
  238|      0|					bLen = 5;
  239|      0|					buf[1] = 0x41;				/* fixed */
  240|      0|					buf[2] = file->record_length >> 8;	/* 2 byte record length  */
  241|      0|					buf[3] = file->record_length & 0xFF;
  242|      0|					buf[4] = file->size / file->record_length; /* record count */
  243|      0|				}
  244|     15|			} else {
  245|     15|				buf[0] |= file->ef_structure & 7;	/* set file-type, only for EF, not for DF objects  */
  246|     15|			}
  247|     15|			break;
  248|     16|		case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|     16|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (248:3): [True: 16, False: 19]
  ------------------
  249|     16|			buf[0] = 0x38;
  250|     16|			break;
  251|      3|		default:
  ------------------
  |  Branch (251:3): [True: 3, False: 32]
  ------------------
  252|      3|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  253|     35|		}
  254|     32|		sc_asn1_put_tag(0x82, buf, bLen, p, *outlen - (p - out), &p);
  255|     32|	}
  256|       |
  257|       |	/* File ID */
  258|     32|	buf[0] = (file->id >> 8) & 0xFF;
  259|     32|	buf[1] = file->id & 0xFF;
  260|     32|	sc_asn1_put_tag(0x83, buf, 2, p, *outlen - (p - out), &p);
  261|       |
  262|       |	/* DF name */
  263|     32|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     32|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (263:6): [True: 16, False: 16]
  ------------------
  264|     16|		if (file->name[0] != 0)
  ------------------
  |  Branch (264:7): [True: 1, False: 15]
  ------------------
  265|      1|			sc_asn1_put_tag(0x84, (u8 *) file->name, file->namelen, p, *outlen - (p - out), &p);
  266|     15|		else { /* Name required -> take the FID if not specified */
  267|     15|			buf[0] = (file->id >> 8) & 0xFF;
  268|     15|			buf[1] = file->id & 0xFF;
  269|     15|			sc_asn1_put_tag(0x84, buf, 2, p, *outlen - (p - out), &p);
  270|     15|		}
  271|     16|	}
  272|       |
  273|       |	/* Security Attributes */
  274|     32|	memcpy(buf, file->sec_attr, file->sec_attr_len);
  275|     32|	sc_asn1_put_tag(0x86, buf, file->sec_attr_len, p, *outlen - (p - out), &p);
  276|       |
  277|       |	/* Life cycle status */
  278|     32|	if (file->prop_attr_len) {
  ------------------
  |  Branch (278:6): [True: 32, False: 0]
  ------------------
  279|     32|		memcpy(buf, file->prop_attr, file->prop_attr_len);
  280|     32|		sc_asn1_put_tag(0x8A, buf, file->prop_attr_len, p, *outlen - (p - out), &p);
  281|     32|	}
  282|       |
  283|       |	/* PIN definitions */
  284|     32|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     32|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (284:6): [True: 16, False: 16]
  ------------------
  285|     16|		if (card->type == SC_CARD_TYPE_SETCOS_EID_V2_1) {
  ------------------
  |  Branch (285:7): [True: 9, False: 7]
  ------------------
  286|      9|			pin_key_info = (const u8*)"\xC1\x04\x81\x82\x83\x84";
  287|      9|			len = 6;
  288|      9|		}
  289|      7|		else if (card->type == SC_CARD_TYPE_SETCOS_EID_V2_0) {
  ------------------
  |  Branch (289:12): [True: 7, False: 0]
  ------------------
  290|      7|			pin_key_info = (const u8*)"\xC1\x04\x81\x82"; /* Max 2 PINs supported */
  291|      7|			len = 4;
  292|      7|		}
  293|      0|		else {
  294|       |			/* Pin/key info: define 4 pins, no keys */
  295|      0|			if(file->path.len == 2)
  ------------------
  |  Branch (295:7): [True: 0, False: 0]
  ------------------
  296|      0|				pin_key_info = (const u8*)"\xC1\x04\x81\x82\x83\x84\xC2\x00";	/* root-MF: use local pin-file */
  297|      0|			else
  298|      0|				pin_key_info = (const u8 *)"\xC1\x04\x01\x02\x03\x04\xC2\x00";	/* sub-DF: use parent pin-file in root-MF */
  299|      0|			len = 8;
  300|      0|		}
  301|     16|		sc_asn1_put_tag(0xA5, pin_key_info, len, p, *outlen - (p - out), &p);
  302|     16|	}
  303|       |
  304|       |	/* Length */
  305|     32|	out[1] = p - out - 2;
  306|       |
  307|     32|	*outlen = p - out;
  308|     32|	return 0;
  309|     35|}
card-setcos.c:setcos_card_ctl:
 1086|    206|{
 1087|    206|	if (card->type != SC_CARD_TYPE_SETCOS_44 && !SETCOS_IS_EID_APPLET(card))
  ------------------
  |  |   46|    203|#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: 66, False: 137]
  |  |  |  Branch (46:85): [True: 120, False: 17]
  |  |  ------------------
  ------------------
  |  Branch (1087:6): [True: 203, False: 3]
  ------------------
 1088|     17|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     17|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1089|       |
 1090|    189|	switch(cmd) {
  ------------------
  |  Branch (1090:9): [True: 19, False: 170]
  ------------------
 1091|      0|	case SC_CARDCTL_SETCOS_PUTDATA:
  ------------------
  |  Branch (1091:2): [True: 0, False: 189]
  ------------------
 1092|      0|		return setcos_putdata(card,
 1093|      0|				(struct sc_cardctl_setcos_data_obj*) ptr);
 1094|      0|		break;
 1095|      9|	case SC_CARDCTL_SETCOS_GETDATA:
  ------------------
  |  Branch (1095:2): [True: 9, False: 180]
  ------------------
 1096|      9|		return setcos_getdata(card,
 1097|      9|				(struct sc_cardctl_setcos_data_obj*) ptr);
 1098|      0|		break;
 1099|     10|	case SC_CARDCTL_SETCOS_GENERATE_STORE_KEY:
  ------------------
  |  Branch (1099:2): [True: 10, False: 179]
  ------------------
 1100|     10|		return setcos_generate_store_key(card,
 1101|     10|				(struct sc_cardctl_setcos_gen_store_key_info *) ptr);
 1102|      0|	case SC_CARDCTL_SETCOS_ACTIVATE_FILE:
  ------------------
  |  Branch (1102:2): [True: 0, False: 189]
  ------------------
 1103|      0|		return setcos_activate_file(card);
 1104|    189|	}
 1105|       |
 1106|    170|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    170|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1107|    189|}
card-setcos.c:setcos_getdata:
  982|      9|{
  983|      9|	int				r;
  984|      9|	struct sc_apdu			apdu;
  985|       |
  986|      9|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|      9|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|      9|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|      9|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 9]
  |  |  ------------------
  ------------------
  987|       |
  988|      9|	memset(&apdu, 0, sizeof(apdu));
  989|      9|	apdu.cse     = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|      9|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  990|      9|	apdu.cla     = 0x00;
  991|      9|	apdu.ins     = 0xCA;			/* GET DATA */
  992|      9|	apdu.p1      = data_obj->P1;
  993|      9|	apdu.p2      = data_obj->P2;
  994|      9|	apdu.lc      = 0;
  995|      9|	apdu.datalen = 0;
  996|      9|	apdu.data    = data_obj->Data;
  997|       |
  998|      9|	apdu.le      = 256;
  999|      9|	apdu.resp    = data_obj->Data;
 1000|      9|	apdu.resplen = data_obj->DataLen;
 1001|       |
 1002|      9|	r = sc_transmit_apdu(card, &apdu);
 1003|      9|	LOG_TEST_RET(card->ctx, r, "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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1004|       |
 1005|      9|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1006|      9|	LOG_TEST_RET(card->ctx, r, "GET_DATA returned 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1007|       |
 1008|      9|	if (apdu.resplen > data_obj->DataLen)
  ------------------
  |  Branch (1008:6): [True: 0, False: 9]
  ------------------
 1009|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 1010|      9|	else
 1011|      9|		data_obj->DataLen = apdu.resplen;
 1012|       |
 1013|      9|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1014|      9|}
card-setcos.c:setcos_generate_store_key:
 1019|     10|{
 1020|     10|	struct	sc_apdu apdu;
 1021|     10|	u8	sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1022|     10|	int	r, len;
 1023|       |
 1024|     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]
  |  |  ------------------
  ------------------
 1025|       |
 1026|       |	/* Setup key-generation parameters */
 1027|     10|	len = 0;
 1028|     10|	if (data->op_type == OP_TYPE_GENERATE)
  ------------------
  |  |  529|     10|#define OP_TYPE_GENERATE	0
  ------------------
  |  Branch (1028:6): [True: 10, False: 0]
  ------------------
 1029|     10|		sbuf[len++] = 0x92;	/* algo ID: RSA CRT */
 1030|      0|	else
 1031|      0|		sbuf[len++] = 0x9A;	/* algo ID: EXTERNALLY GENERATED RSA CRT */
 1032|     10|	sbuf[len++] = 0x00;
 1033|     10|	sbuf[len++] = data->mod_len / 256;	/* 2 bytes for modulus bitlength */
 1034|     10|	sbuf[len++] = data->mod_len % 256;
 1035|       |
 1036|     10|	sbuf[len++] = data->pubexp_len / 256;   /* 2 bytes for pubexp bitlength */
 1037|     10|	sbuf[len++] = data->pubexp_len % 256;
 1038|     10|	memcpy(sbuf + len, data->pubexp, BYTES4BITS(data->pubexp_len));
  ------------------
  |  |  146|     10|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 1039|     10|	len += BYTES4BITS(data->pubexp_len);
  ------------------
  |  |  146|     10|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 1040|       |
 1041|     10|	if (data->op_type == OP_TYPE_STORE) {
  ------------------
  |  |  530|     10|#define OP_TYPE_STORE		1
  ------------------
  |  Branch (1041:6): [True: 0, False: 10]
  ------------------
 1042|      0|		sbuf[len++] = data->primep_len / 256;
 1043|      0|		sbuf[len++] = data->primep_len % 256;
 1044|      0|		memcpy(sbuf + len, data->primep, BYTES4BITS(data->primep_len));
  ------------------
  |  |  146|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 1045|      0|		len += BYTES4BITS(data->primep_len);
  ------------------
  |  |  146|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 1046|      0|		sbuf[len++] = data->primeq_len / 256;
 1047|      0|		sbuf[len++] = data->primeq_len % 256;
 1048|      0|		memcpy(sbuf + len, data->primeq, BYTES4BITS(data->primeq_len));
  ------------------
  |  |  146|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 1049|      0|		len += BYTES4BITS(data->primeq_len);
  ------------------
  |  |  146|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
 1050|      0|	}
 1051|       |
 1052|     10|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x46, 0x00, 0x00);
  ------------------
  |  |  293|     10|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1053|     10|	apdu.cla = 0x00;
 1054|     10|	apdu.data = sbuf;
 1055|     10|	apdu.datalen = len;
 1056|     10|	apdu.lc	= len;
 1057|       |
 1058|     10|	r = sc_transmit_apdu(card, &apdu);
 1059|     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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1060|       |
 1061|     10|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1062|     10|	LOG_TEST_RET(card->ctx, r, "STORE/GENERATE_KEY returned 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1063|       |
 1064|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1065|     10|}

sc_get_skeid_driver:
  179|  3.69k|{
  180|  3.69k|	if (iso_ops == NULL) iso_ops = sc_get_iso7816_driver()->ops;
  ------------------
  |  Branch (180:6): [True: 1, False: 3.69k]
  ------------------
  181|  3.69k|	skeid_ops = *iso_ops;
  182|  3.69k|	skeid_ops.match_card = skeid_match_card;
  183|  3.69k|	skeid_ops.init = skeid_init;
  184|  3.69k|	skeid_ops.set_security_env = skeid_set_security_env;
  185|  3.69k|	skeid_ops.logout = skeid_logout;
  186|  3.69k|	return &skeid_drv;
  187|  3.69k|}
card-skeid.c:skeid_match_card:
   73|  3.64k|{
   74|  3.64k|	if (_sc_match_atr(card, skeid_atrs, &card->type) < 0 || skeid_known_url(card) != SC_SUCCESS)
  ------------------
  |  |   28|    129|#define SC_SUCCESS				0
  ------------------
  |  Branch (74:6): [True: 3.51k, False: 129]
  |  Branch (74:58): [True: 129, False: 0]
  ------------------
   75|  3.64k|		return 0;
   76|       |
   77|      0|	sc_log(card->ctx,  "Slovak eID card v3 (CardOS 5.4)");
  ------------------
  |  |   71|      0|#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|      0|	return 1;
   80|  3.64k|}
card-skeid.c:skeid_known_url:
   53|    129|{
   54|    129|	const struct sc_aid skeid_aid_eid = {{0xE8, 0x07, 0x04, 0x00, 0x7F, 0x00, 0x07, 0x03, 0x02}, 9};
   55|    129|	const char *known_url = "\x80\x01\x00\x5F\x50\x28http://www.minv.sk/cif/cif-sk-eid-v3.xml";
   56|    129|	u8 buf[SKEID_KNOWN_URL_LEN];
   57|       |
   58|    129|	sc_path_t url_path;
   59|       |
   60|    129|	int r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|    129|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
   61|       |
   62|    129|	sc_path_set(&url_path, SC_PATH_TYPE_DF_NAME, skeid_aid_eid.value, skeid_aid_eid.len, 0, 0);
  ------------------
  |  |  118|    129|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
   63|       |
   64|    129|	if (sc_select_file(card, &url_path, NULL) == SC_SUCCESS
  ------------------
  |  |   28|    258|#define SC_SUCCESS				0
  ------------------
  |  Branch (64:6): [True: 1, False: 128]
  ------------------
   65|      1|		&& sc_get_data(card, 0x7F62, buf, SKEID_KNOWN_URL_LEN) == SKEID_KNOWN_URL_LEN
  ------------------
  |  |   30|      1|#define SKEID_KNOWN_URL_LEN 46
  ------------------
              		&& sc_get_data(card, 0x7F62, buf, SKEID_KNOWN_URL_LEN) == SKEID_KNOWN_URL_LEN
  ------------------
  |  |   30|    130|#define SKEID_KNOWN_URL_LEN 46
  ------------------
  |  Branch (65:6): [True: 0, False: 1]
  ------------------
   66|      0|		&& !memcmp(buf, known_url, SKEID_KNOWN_URL_LEN))
  ------------------
  |  |   30|      0|#define SKEID_KNOWN_URL_LEN 46
  ------------------
  |  Branch (66:6): [True: 0, False: 0]
  ------------------
   67|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
   68|       |
   69|    129|	return r;
   70|    129|}

sc_get_srbeid_driver:
  301|  3.69k|{
  302|       |	/* Save ISO ops for delegation, then override what we handle. */
  303|  3.69k|	iso_ops = sc_get_iso7816_driver()->ops;
  304|  3.69k|	srbeid_ops = *iso_ops;
  305|  3.69k|	srbeid_ops.match_card = srbeid_match_card;
  306|  3.69k|	srbeid_ops.init = srbeid_init;
  307|  3.69k|	srbeid_ops.select_file = srbeid_select_file;
  308|  3.69k|	srbeid_ops.set_security_env = srbeid_set_security_env;
  309|  3.69k|	srbeid_ops.compute_signature = srbeid_compute_signature;
  310|  3.69k|	srbeid_ops.decipher = srbeid_decipher;
  311|       |
  312|  3.69k|	return &srbeid_drv;
  313|  3.69k|}
card-srbeid.c:srbeid_match_card:
   71|  1.35k|{
   72|  1.35k|	int i = _sc_match_atr(card, srbeid_atrs, &card->type);
   73|  1.35k|	if (i >= 0 && iso7816_select_aid(card, AID_PKCS15, AID_PKCS15_LEN, NULL, NULL) == SC_SUCCESS) {
  ------------------
  |  |   30|      0|#define AID_PKCS15_LEN (sizeof(AID_PKCS15))
  ------------------
              	if (i >= 0 && iso7816_select_aid(card, AID_PKCS15, AID_PKCS15_LEN, NULL, NULL) == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (73:6): [True: 0, False: 1.35k]
  |  Branch (73:16): [True: 0, False: 0]
  ------------------
   74|      0|		card->name = srbeid_atrs[i].name;
   75|      0|		return 1;
   76|      0|	}
   77|  1.35k|	return 0;
   78|  1.35k|}

sc_get_starcos_driver:
 2118|  3.69k|{
 2119|  3.69k|	return sc_get_driver();
 2120|  3.69k|}
card-starcos.c:sc_get_driver:
 2093|  3.69k|{
 2094|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
 2095|  3.69k|	if (iso_ops == NULL)
  ------------------
  |  Branch (2095:6): [True: 1, False: 3.69k]
  ------------------
 2096|      1|		iso_ops = iso_drv->ops;
 2097|       |
 2098|  3.69k|	starcos_ops = *iso_drv->ops;
 2099|  3.69k|	starcos_ops.match_card = starcos_match_card;
 2100|  3.69k|	starcos_ops.init   = starcos_init;
 2101|  3.69k|	starcos_ops.finish = starcos_finish;
 2102|  3.69k|	starcos_ops.select_file = starcos_select_file;
 2103|  3.69k|	starcos_ops.get_challenge = starcos_get_challenge;
 2104|  3.69k|	starcos_ops.check_sw    = starcos_check_sw;
 2105|  3.69k|	starcos_ops.create_file = starcos_create_file;
 2106|  3.69k|	starcos_ops.delete_file = NULL;
 2107|  3.69k|	starcos_ops.set_security_env  = starcos_set_security_env;
 2108|  3.69k|	starcos_ops.compute_signature = starcos_compute_signature;
 2109|  3.69k|	starcos_ops.decipher = starcos_decipher;
 2110|  3.69k|	starcos_ops.card_ctl    = starcos_card_ctl;
 2111|  3.69k|	starcos_ops.logout      = starcos_logout;
 2112|  3.69k|	starcos_ops.pin_cmd     = starcos_pin_cmd;
 2113|       |
 2114|  3.69k|	return &starcos_drv;
 2115|  3.69k|}
card-starcos.c:starcos_match_card:
  125|  3.40k|{
  126|  3.40k|	int i;
  127|       |
  128|  3.40k|	i = _sc_match_atr(card, starcos_atrs, &card->type);
  129|  3.40k|	if (i < 0)
  ------------------
  |  Branch (129:6): [True: 3.30k, False: 97]
  ------------------
  130|  3.30k|		return 0;
  131|     97|	return 1;
  132|  3.40k|}
card-starcos.c:starcos_init:
  359|     97|{
  360|     97|	unsigned int flags;
  361|     97|	starcos_ex_data *ex_data;
  362|       |
  363|     97|	ex_data = calloc(1, sizeof(starcos_ex_data));
  364|     97|	if (ex_data == NULL)
  ------------------
  |  Branch (364:6): [True: 0, False: 97]
  ------------------
  365|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  366|       |
  367|     97|	card->name = "STARCOS";
  368|     97|	card->cla  = 0x00;
  369|     97|	card->drv_data = (void *)ex_data;
  370|     97|	ex_data->pin_encoding = PIN_ENCODING_DETERMINE;
  ------------------
  |  |   96|     97|#define PIN_ENCODING_DETERMINE	0
  ------------------
  371|       |
  372|     97|	flags = SC_ALGORITHM_RSA_PAD_PKCS1
  ------------------
  |  |  120|     97|#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) */
  |  |  ------------------
  |  |  |  |  118|     97|#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) */
  |  |  ------------------
  |  |  |  |  119|     97|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  |  |  ------------------
  ------------------
  373|     97|		| SC_ALGORITHM_ONBOARD_KEY_GEN
  ------------------
  |  |  102|     97|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
  374|     97|		| SC_ALGORITHM_RSA_PAD_ISO9796
  ------------------
  |  |  115|     97|#define SC_ALGORITHM_RSA_PAD_ISO9796	0x00000008
  ------------------
  375|     97|		| SC_ALGORITHM_RSA_HASH_NONE
  ------------------
  |  |  142|     97|#define SC_ALGORITHM_RSA_HASH_NONE	0x00000100 /* only applies to PKCS1 padding */
  ------------------
  376|     97|		| SC_ALGORITHM_RSA_HASH_SHA1
  ------------------
  |  |  143|     97|#define SC_ALGORITHM_RSA_HASH_SHA1	0x00000200
  ------------------
  377|     97|		| SC_ALGORITHM_RSA_HASH_MD5
  ------------------
  |  |  144|     97|#define SC_ALGORITHM_RSA_HASH_MD5	0x00000400
  ------------------
  378|     97|		| SC_ALGORITHM_RSA_HASH_RIPEMD160
  ------------------
  |  |  146|     97|#define SC_ALGORITHM_RSA_HASH_RIPEMD160	0x00001000
  ------------------
  379|     97|		| SC_ALGORITHM_RSA_HASH_MD5_SHA1;
  ------------------
  |  |  145|     97|#define SC_ALGORITHM_RSA_HASH_MD5_SHA1	0x00000800
  ------------------
  380|       |
  381|     97|	card->caps = SC_CARD_CAP_RNG;
  ------------------
  |  |  557|     97|#define SC_CARD_CAP_RNG			0x00000004
  ------------------
  382|       |
  383|     97|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|    194|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|     97|#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: 66, False: 31]
  |  |  |  |  |  Branch (119:65): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|     31|#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: 12, False: 19]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  384|       |
  385|     78|		flags |= SC_CARD_FLAG_RNG
  ------------------
  |  |  543|     78|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  386|     78|			| SC_ALGORITHM_RSA_HASH_SHA224
  ------------------
  |  |  150|     78|#define SC_ALGORITHM_RSA_HASH_SHA224	0x00010000
  ------------------
  387|     78|			| SC_ALGORITHM_RSA_HASH_SHA256
  ------------------
  |  |  147|     78|#define SC_ALGORITHM_RSA_HASH_SHA256	0x00002000
  ------------------
  388|     78|			| SC_ALGORITHM_RSA_HASH_SHA384
  ------------------
  |  |  148|     78|#define SC_ALGORITHM_RSA_HASH_SHA384	0x00004000
  ------------------
  389|     78|			| SC_ALGORITHM_RSA_HASH_SHA512
  ------------------
  |  |  149|     78|#define SC_ALGORITHM_RSA_HASH_SHA512	0x00008000
  ------------------
  390|     78|			| SC_ALGORITHM_RSA_PAD_PSS;
  ------------------
  |  |  116|     78|#define SC_ALGORITHM_RSA_PAD_PSS	0x00000010 /* PKCS#1 v2.0 PSS */
  ------------------
  391|       |
  392|     78|		_sc_card_add_rsa_alg(card, 512, flags, 0x10001);
  393|     78|		_sc_card_add_rsa_alg(card, 768, flags, 0x10001);
  394|     78|		_sc_card_add_rsa_alg(card,1024, flags, 0x10001);
  395|     78|		_sc_card_add_rsa_alg(card,1728, flags, 0x10001);
  396|     78|		_sc_card_add_rsa_alg(card,1976, flags, 0x10001);
  397|     78|		_sc_card_add_rsa_alg(card,2048, flags, 0x10001);
  398|     78|		if ( IS_V34(card) ) {
  ------------------
  |  |  119|     78|#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: 66, False: 12]
  |  |  |  Branch (119:65): [True: 0, False: 12]
  |  |  ------------------
  ------------------
  399|     66|			card->name = "STARCOS 3.4";
  400|     66|			card->caps |= SC_CARD_CAP_ISO7816_PIN_INFO;
  ------------------
  |  |  560|     66|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  401|     66|		} else {
  402|     12|			card->name = "STARCOS 3.5";
  403|     12|			_sc_card_add_rsa_alg(card,3072, flags, 0x10001);
  404|     12|		}
  405|     78|		card->max_send_size = 255;
  406|     78|		card->max_recv_size = 256;
  407|     78|	} else {
  408|     19|		_sc_card_add_rsa_alg(card, 512, flags, 0x10001);
  409|     19|		_sc_card_add_rsa_alg(card, 768, flags, 0x10001);
  410|     19|		_sc_card_add_rsa_alg(card,1024, flags, 0x10001);
  411|       |
  412|       |		/* we need read_binary&friends with max 128 bytes per read */
  413|     19|		card->max_send_size = 128;
  414|     19|		card->max_recv_size = 128;
  415|     19|	}
  416|       |
  417|     97|	if (sc_parse_ef_atr(card) == SC_SUCCESS) {
  ------------------
  |  |   28|     97|#define SC_SUCCESS				0
  ------------------
  |  Branch (417:6): [True: 2, False: 95]
  ------------------
  418|      2|		size_t max_recv_size = 0;
  419|      2|		size_t max_send_size = 0;
  420|       |
  421|       |		/* Add max. length values from IAS/ECC specific issuer data */
  422|      2|		if ( card->ef_atr->issuer_data_len >= 4 ) {
  ------------------
  |  Branch (422:8): [True: 0, False: 2]
  ------------------
  423|      0|			max_recv_size = bebytes2ushort(card->ef_atr->issuer_data);
  424|      0|			max_send_size = bebytes2ushort(card->ef_atr->issuer_data + 2);
  425|      0|		}
  426|       |		/* which could be overridden with ISO7816 EF.ATR options, if present */
  427|      2|		if (card->ef_atr->max_response_apdu > 0) {
  ------------------
  |  Branch (427:7): [True: 0, False: 2]
  ------------------
  428|      0|			max_recv_size = card->ef_atr->max_response_apdu;
  429|      0|		}
  430|      2|		if (card->ef_atr->max_command_apdu > 0) {
  ------------------
  |  Branch (430:7): [True: 0, False: 2]
  ------------------
  431|      0|			max_send_size = card->ef_atr->max_command_apdu;
  432|      0|		}
  433|       |
  434|      2|		if ( max_send_size > 256 && max_recv_size > 256 ) {
  ------------------
  |  Branch (434:8): [True: 0, False: 2]
  |  Branch (434:31): [True: 0, False: 0]
  ------------------
  435|      0|			size_t max_recv_size_prev = card->max_recv_size;
  436|      0|			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|      0|			card->caps |= SC_CARD_CAP_APDU_EXT;
  ------------------
  |  |  554|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  439|       |			/* the received data should not exceed max_recv_size including the sw1/sw2 */
  440|      0|			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|      0|			card->max_send_size = max_send_size - 10;
  443|       |			/* probe reader for extended APDU support */
  444|      0|			if ( starcos_probe_reader_for_ext_apdu(card) ) {
  ------------------
  |  Branch (444:9): [True: 0, False: 0]
  ------------------
  445|      0|				sc_log(card->ctx, "Successfully probed extended APDU, enabling extended APDU with max send/recv %d/%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__
  |  |  ------------------
  ------------------
  446|      0|					(int)card->max_send_size, (int)card->max_recv_size);
  447|      0|			} else {
  448|      0|				card->caps &= ~(SC_CARD_CAP_APDU_EXT);
  ------------------
  |  |  554|      0|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  449|      0|				card->max_recv_size = max_recv_size_prev;
  450|      0|				card->max_send_size = max_send_size_prev;
  451|      0|				sc_log(card->ctx, "Ext APDU probing failed, the actual reader does not support ext 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__
  |  |  ------------------
  ------------------
  452|      0|			}
  453|      0|		}
  454|      2|	}
  455|       |
  456|     97|	if ( ex_data->pin_encoding == PIN_ENCODING_DETERMINE ) {
  ------------------
  |  |   96|     97|#define PIN_ENCODING_DETERMINE	0
  ------------------
  |  Branch (456:7): [True: 97, False: 0]
  ------------------
  457|       |		// about to determine PIN encoding
  458|     97|		ex_data->pin_encoding = starcos_determine_pin_encoding(card);
  459|     97|	}
  460|       |
  461|     97|	if ( card->type == SC_CARD_TYPE_STARCOS_V3_4 && starcos_has_esign_app(card) ) {
  ------------------
  |  Branch (461:7): [True: 66, False: 31]
  |  Branch (461:50): [True: 52, False: 14]
  ------------------
  462|     52|		card->type = SC_CARD_TYPE_STARCOS_V3_4_ESIGN;
  463|     52|		sc_log(card->ctx, "Card has eSign app, card type changed to %d", card->type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  464|     52|	}
  465|       |
  466|     97|	return 0;
  467|     97|}
card-starcos.c:starcos_determine_pin_encoding:
  269|     97|{
  270|     97|	unsigned int pin_format = PIN_FORMAT_DEFAULT;
  ------------------
  |  |  107|     97|#define PIN_FORMAT_DEFAULT		PIN_FORMAT_F2
  |  |  ------------------
  |  |  |  |  101|     97|#define PIN_FORMAT_F2			0x12
  |  |  ------------------
  ------------------
  271|     97|	unsigned int encoding = PIN_ENCODING_DETERMINE;
  ------------------
  |  |   96|     97|#define PIN_ENCODING_DETERMINE	0
  ------------------
  272|       |
  273|     97|	if ( IS_V34(card) ) {
  ------------------
  |  |  119|     97|#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: 66, False: 31]
  |  |  |  Branch (119:65): [True: 0, False: 31]
  |  |  ------------------
  ------------------
  274|     66|		starcos_determine_pin_format34(card, &pin_format);
  275|     66|	} else if ( IS_V35(card) ) {
  ------------------
  |  |  120|     31|#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: 12, False: 19]
  |  |  |  Branch (120:65): [True: 0, False: 19]
  |  |  ------------------
  ------------------
  276|     12|		starcos_determine_pin_format35(card, &pin_format);
  277|     12|	}
  278|       |
  279|     97|	switch (pin_format) {
  ------------------
  |  Branch (279:10): [True: 97, False: 0]
  ------------------
  280|      0|	case PIN_FORMAT_PW_ASCII:
  ------------------
  |  |  105|      0|#define PIN_FORMAT_PW_ASCII		0x21
  ------------------
  |  Branch (280:2): [True: 0, False: 97]
  ------------------
  281|      0|	case PIN_FORMAT_ASCII:
  ------------------
  |  |  104|      0|#define PIN_FORMAT_ASCII		0x14
  ------------------
  |  Branch (281:2): [True: 0, False: 97]
  ------------------
  282|      0|		encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  432|      0|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  283|      0|		break;
  284|      0|	case PIN_FORMAT_BCD:
  ------------------
  |  |  103|      0|#define PIN_FORMAT_BCD			0x13
  ------------------
  |  Branch (284:2): [True: 0, False: 97]
  ------------------
  285|      0|		encoding = SC_PIN_ENCODING_BCD;
  ------------------
  |  |  433|      0|#define SC_PIN_ENCODING_BCD	1
  ------------------
  286|      0|		break;
  287|      0|	case PIN_FORMAT_F1:
  ------------------
  |  |  100|      0|#define PIN_FORMAT_F1			0x11
  ------------------
  |  Branch (287:2): [True: 0, False: 97]
  ------------------
  288|     97|	case PIN_FORMAT_F2:
  ------------------
  |  |  101|     97|#define PIN_FORMAT_F2			0x12
  ------------------
  |  Branch (288:2): [True: 97, False: 0]
  ------------------
  289|     97|		encoding = SC_PIN_ENCODING_GLP;
  ------------------
  |  |  434|     97|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  290|     97|		break;
  291|     97|	}
  292|       |
  293|     97|	sc_log(card->ctx, "Determined PIN encoding: %d", encoding);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  294|     97|	return encoding;
  295|     97|}
card-starcos.c:starcos_determine_pin_format34:
  189|     66|{
  190|     66|	struct sc_context *ctx = card->ctx;
  191|     66|	struct sc_path path;
  192|     66|	struct sc_file *file;
  193|     66|	unsigned char buf[256];
  194|     66|	int rv;
  195|     66|	int retval = SC_SUCCESS;
  ------------------
  |  |   28|     66|#define SC_SUCCESS				0
  ------------------
  196|     66|	int rec_no=1;
  197|       |
  198|     66|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  199|       |
  200|     66|	sc_format_path(starcos_ef_pwdd, &path);
  201|     66|	rv = sc_select_file(card, &path, &file);
  202|     66|	LOG_TEST_RET(ctx, rv, "Cannot select EF.PWDD file");
  ------------------
  |  |  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: 65, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  169|     65|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     65|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     65|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     65|		return _ret; \
  |  |  |  |  172|     65|	} \
  |  |  |  |  173|     66|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  203|       |
  204|      1|	if ( (rv = sc_read_record(card, rec_no, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR)) > 0 ) {
  ------------------
  |  | 1305|      1|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (204:7): [True: 0, False: 1]
  ------------------
  205|      0|		starcos_ctrl_ref_template ctrl_ref_template;
  206|      0|		memset((void*)&ctrl_ref_template, 0, sizeof(ctrl_ref_template));
  207|      0|		rv = starcos_parse_supported_sec_mechanisms(card, buf, rv, &ctrl_ref_template);
  208|      0|		if ( rv == SC_SUCCESS ) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (208:8): [True: 0, False: 0]
  ------------------
  209|      0|			*pin_format = ctrl_ref_template.transmission_format;
  210|      0|			sc_log(ctx, "Determined StarCOS 3.4 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__
  |  |  ------------------
  ------------------
  211|      0|		} else {
  212|      0|			sc_log(ctx, "Failed to parse record %d of EF.PWD, err=%d", rec_no, 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__
  |  |  ------------------
  ------------------
  213|      0|			retval = rv;
  214|      0|		}
  215|      1|	} else {
  216|      1|		sc_log(ctx, "Failed to read record %d of EF.PWDD, err=%d", rec_no, 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__
  |  |  ------------------
  ------------------
  217|      1|		retval = rv;
  218|      1|	}
  219|       |
  220|      1|	sc_file_free(file);
  221|      1|	LOG_FUNC_RETURN(ctx, retval);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|      1|}
card-starcos.c:starcos_parse_supported_sec_mechanisms:
  158|    289|{
  159|    289|	struct sc_context *ctx = card->ctx;
  160|    289|	const unsigned char *supported_sec_mechanisms_tag = NULL;
  161|    289|	size_t taglen;
  162|       |
  163|    289|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    289|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    289|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    289|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    289|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 289]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|       |
  165|    289|	supported_sec_mechanisms_tag = sc_asn1_find_tag(ctx, buf, buflen, TAG_STARCOS3X_SUPPORTED_SEC_MECHANISMS_tag, &taglen);
  ------------------
  |  |  146|    289|#define TAG_STARCOS3X_SUPPORTED_SEC_MECHANISMS_tag		0x7B
  ------------------
  166|    289|	if (supported_sec_mechanisms_tag != NULL && taglen >= 1)   {
  ------------------
  |  Branch (166:6): [True: 0, False: 289]
  |  Branch (166:46): [True: 0, False: 0]
  ------------------
  167|      0|		const unsigned char *tx_fmt_tag = NULL;
  168|      0|		const unsigned char *ctrl_ref_template_tag = NULL;
  169|      0|		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|      0|		ctrl_ref_template_tag = sc_asn1_find_tag(ctx, supported_sec_mechanisms_tag, taglen, TAG_STARCOS3X_CTRL_REF_TEMPLATE, &taglen);
  ------------------
  |  |  147|      0|#define TAG_STARCOS3X_CTRL_REF_TEMPLATE				0xA4
  ------------------
  173|      0|		if ( ctrl_ref_template_tag == NULL || taglen == 0 ) {
  ------------------
  |  Branch (173:8): [True: 0, False: 0]
  |  Branch (173:41): [True: 0, False: 0]
  ------------------
  174|      0|			ctrl_ref_template_tag = supported_sec_mechanisms_tag;
  175|      0|			taglen = supported_sec_mechanisms_taglen;
  176|      0|		}
  177|       |
  178|      0|		tx_fmt_tag = sc_asn1_find_tag(ctx, ctrl_ref_template_tag, taglen, TAG_STARCOS3X_TRANSMISSION_FORMAT, &taglen);
  ------------------
  |  |  148|      0|#define TAG_STARCOS3X_TRANSMISSION_FORMAT			0x89
  ------------------
  179|      0|		if ( tx_fmt_tag != NULL && taglen >= 1 ) {
  ------------------
  |  Branch (179:8): [True: 0, False: 0]
  |  Branch (179:30): [True: 0, False: 0]
  ------------------
  180|      0|			ctrl_ref_template->transmission_format = *(tx_fmt_tag + 0);
  181|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|      0|		}
  183|      0|	}
  184|       |
  185|    289|	LOG_FUNC_RETURN(ctx, SC_ERROR_TEMPLATE_NOT_FOUND);
  ------------------
  |  |  164|    289|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    289|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    289|	int _ret = r; \
  |  |  |  |  155|    289|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 289, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    289|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    289|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 289, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    289|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    289|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    289|	return _ret; \
  |  |  |  |  163|    289|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  186|    289|}
card-starcos.c:starcos_determine_pin_format35:
  225|     12|{
  226|     12|	struct sc_context *ctx = card->ctx;
  227|     12|	struct sc_path path;
  228|     12|	struct sc_file *file;
  229|     12|	unsigned char buf[256];
  230|     12|	int rv;
  231|     12|	int retval = SC_ERROR_RECORD_NOT_FOUND;
  ------------------
  |  |   52|     12|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  232|     12|	int rec_no=1;
  233|     12|	starcos_ctrl_ref_template ctrl_ref_template;
  234|       |
  235|     12|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     12|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|       |
  237|     12|	sc_format_path(starcos_ef_keyd, &path);
  238|     12|	rv = sc_select_file(card, &path, &file);
  239|     12|	LOG_TEST_RET(ctx, rv, "Cannot select EF.KEYD file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  240|       |
  241|    737|	while ( (rv = sc_read_record(card, rec_no++, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR)) > 0 ) {
  ------------------
  |  | 1305|    737|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (241:10): [True: 726, False: 11]
  ------------------
  242|    726|		if ( buf[0] != TAG_STARCOS35_PIN_REFERENCE ) continue;
  ------------------
  |  |  145|    726|#define TAG_STARCOS35_PIN_REFERENCE					0x88
  ------------------
  |  Branch (242:8): [True: 437, False: 289]
  ------------------
  243|       |
  244|    289|		memset((void*)&ctrl_ref_template, 0, sizeof(ctrl_ref_template));
  245|    289|		rv = starcos_parse_supported_sec_mechanisms(card, buf, rv, &ctrl_ref_template);
  246|    289|		if ( rv == SC_SUCCESS ) {
  ------------------
  |  |   28|    289|#define SC_SUCCESS				0
  ------------------
  |  Branch (246:8): [True: 0, False: 289]
  ------------------
  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|    289|		} else {
  253|    289|			sc_log(ctx, "Failed to parse record %d of EF.KEYD, err=%d", rec_no-1, rv);
  ------------------
  |  |   71|    289|#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|    289|			retval = rv;
  255|    289|		}
  256|    289|	}
  257|       |
  258|     11|	sc_file_free(file);
  259|     11|	LOG_FUNC_RETURN(ctx, retval);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|     11|}
card-starcos.c:starcos_has_esign_app:
  339|     66|static int starcos_has_esign_app(sc_card_t * card) {
  340|     66|	static const char * starcos_esign_aid = "A0:00:00:02:45:53:69:67:6E";
  341|     66|	int rv;
  342|       |
  343|     66|	rv = starcos_select_mf(card);
  344|     66|	if ( rv == SC_SUCCESS ) {
  ------------------
  |  |   28|     66|#define SC_SUCCESS				0
  ------------------
  |  Branch (344:7): [True: 65, False: 1]
  ------------------
  345|     65|		u8 aid[SC_MAX_PATH_SIZE];
  346|     65|		size_t len = sizeof(aid);
  347|       |
  348|     65|		rv = sc_hex_to_bin(starcos_esign_aid, aid, &len);
  349|     65|		LOG_TEST_RET(card->ctx, rv, "Failed to convert eSing AID");
  ------------------
  |  |  174|     65|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     65|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     65|	int _ret = (r); \
  |  |  |  |  168|     65|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 65]
  |  |  |  |  ------------------
  |  |  |  |  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|     65|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|     65|		rv = starcos_select_aid(card, aid, len, NULL);
  351|     65|		if ( rv == SC_SUCCESS ) {
  ------------------
  |  |   28|     65|#define SC_SUCCESS				0
  ------------------
  |  Branch (351:8): [True: 52, False: 13]
  ------------------
  352|     52|			starcos_select_mf(card);
  353|     52|		}
  354|     65|	}
  355|     66|	return ( rv == SC_SUCCESS );
  ------------------
  |  |   28|     66|#define SC_SUCCESS				0
  ------------------
  356|     66|}
card-starcos.c:starcos_select_mf:
  318|    118|static int starcos_select_mf(sc_card_t * card) {
  319|    118|	sc_apdu_t apdu;
  320|    118|	const u8 mf_buf[2] = {0x3f, 0x00};
  321|       |
  322|    118|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x00, 0x0C);
  ------------------
  |  |  293|    118|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  323|    118|	apdu.le = 0;
  324|    118|	apdu.lc = 2;
  325|    118|	apdu.data    = mf_buf;
  326|    118|	apdu.datalen = 2;
  327|    118|	apdu.resplen = 0;
  328|       |
  329|    118|	return sc_transmit_apdu(card, &apdu);
  330|    118|}
card-starcos.c:starcos_select_aid:
  749|    454|{
  750|    454|	sc_apdu_t apdu;
  751|    454|	int r;
  752|    454|	size_t i = 0;
  753|       |
  754|    454|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 0x04, 0x0C);
  ------------------
  |  |  293|    454|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  755|    454|	apdu.lc = len;
  756|    454|	apdu.data = (u8*)aid;
  757|    454|	apdu.datalen = len;
  758|    454|	apdu.resplen = 0;
  759|    454|	apdu.le = 0;
  760|    454|	r = sc_transmit_apdu(card, &apdu);
  761|    454|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    454|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    454|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    454|	int _ret = (r); \
  |  |  |  |  168|    454|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 454]
  |  |  |  |  ------------------
  |  |  |  |  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|    454|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 454]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  762|       |
  763|       |	/* check return value */
  764|    454|	if (!(apdu.sw1 == 0x90 && apdu.sw2 == 0x00) && apdu.sw1 != 0x61 )
  ------------------
  |  Branch (764:8): [True: 294, False: 160]
  |  Branch (764:28): [True: 273, False: 21]
  |  Branch (764:49): [True: 181, False: 0]
  ------------------
  765|    181|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  766|       |
  767|    273|	if (file_out) {
  ------------------
  |  Branch (767:6): [True: 17, False: 256]
  ------------------
  768|     17|		sc_file_t *file = sc_file_new();
  769|     17|		if (!file)
  ------------------
  |  Branch (769:7): [True: 0, False: 17]
  ------------------
  770|     17|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  771|     17|		file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     17|#define SC_FILE_TYPE_DF			0x04
  ------------------
  772|     17|		file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     17|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  773|     17|		file->path.len = 0;
  774|     17|		file->size = 0;
  775|       |		/* AID */
  776|     47|		for (i = 0; i < len; i++)
  ------------------
  |  Branch (776:15): [True: 30, False: 17]
  ------------------
  777|     30|			file->name[i] = aid[i];
  778|     17|		file->namelen = len;
  779|     17|		file->id = 0x0000;
  780|     17|		file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|     17|#define SC_FILE_MAGIC			0x14426950
  ------------------
  781|       |
  782|     17|		*file_out = file;
  783|     17|	}
  784|    273|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|    273|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    273|	int _ret = r; \
  |  |  155|    273|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 273, False: 0]
  |  |  ------------------
  |  |  156|    273|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 273]
  |  |  ------------------
  |  |  157|    273|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    273|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    273|	return _ret; \
  |  |  163|    273|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  785|    273|}
card-starcos.c:starcos_finish:
  470|     97|{
  471|     97|	if (card->drv_data)
  ------------------
  |  Branch (471:6): [True: 97, False: 0]
  ------------------
  472|     97|		free((starcos_ex_data *)card->drv_data);
  473|     97|	return 0;
  474|     97|}
card-starcos.c:starcos_select_file:
  917|  1.43k|{
  918|  1.43k|	u8 pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  919|  1.43k|	int    r, pathtype;
  920|  1.43k|	size_t i, pathlen;
  921|       |
  922|  1.43k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.43k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.43k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.43k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.43k]
  |  |  ------------------
  ------------------
  923|       |
  924|  1.43k|	if ( in_path->len > sizeof(pathbuf) ) {
  ------------------
  |  Branch (924:7): [True: 0, False: 1.43k]
  ------------------
  925|      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]
  |  |  ------------------
  ------------------
  926|      0|	}
  927|  1.43k|	memcpy(path, in_path->value, in_path->len);
  928|  1.43k|	pathlen = in_path->len;
  929|  1.43k|	pathtype = in_path->type;
  930|       |
  931|  1.43k|	if (in_path->aid.len) {
  ------------------
  |  Branch (931:6): [True: 76, False: 1.35k]
  ------------------
  932|     76|		if (!pathlen) {
  ------------------
  |  Branch (932:7): [True: 65, False: 11]
  ------------------
  933|     65|			if ( in_path->aid.len > sizeof(pathbuf) ) {
  ------------------
  |  Branch (933:9): [True: 0, False: 65]
  ------------------
  934|      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]
  |  |  ------------------
  ------------------
  935|      0|			}
  936|     65|			memcpy(path, in_path->aid.value, in_path->aid.len);
  937|     65|			pathlen = in_path->aid.len;
  938|     65|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|     65|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  939|     65|		} else {
  940|     11|			r = starcos_select_aid(card, in_path->aid.value, in_path->aid.len, NULL);
  941|     11|			LOG_TEST_RET(card->ctx, r, "Could not select AID!");
  ------------------
  |  |  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: 2, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  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|     11|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  942|       |
  943|      9|			if (pathtype == SC_PATH_TYPE_DF_NAME) {
  ------------------
  |  |  118|      9|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (943:8): [True: 2, False: 7]
  ------------------
  944|      2|				pathtype = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      2|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  945|      2|			}
  946|      9|		}
  947|     76|	}
  948|       |
  949|  1.43k|	if (pathtype == SC_PATH_TYPE_FILE_ID)
  ------------------
  |  |  117|  1.43k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (949:6): [True: 33, False: 1.39k]
  ------------------
  950|     33|	{	/* SELECT EF/DF with ID */
  951|       |		/* Select with 2byte File-ID */
  952|     33|		if (pathlen != 2)
  ------------------
  |  Branch (952:7): [True: 28, False: 5]
  ------------------
  953|     28|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  954|      5|		r = starcos_select_fid(card, path[0],
  955|      5|				path[1], path[0] == 0x3F && path[1] == 0x00 ? NULL : file_out, 1);
  ------------------
  |  Branch (955:14): [True: 0, False: 5]
  |  Branch (955:33): [True: 0, False: 0]
  ------------------
  956|      5|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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|      4|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 4, False: 1]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  957|      5|	}
  958|  1.39k|	else if (pathtype == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  1.39k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (958:11): [True: 378, False: 1.01k]
  ------------------
  959|    378|	{	/* SELECT DF with AID */
  960|       |		/* Select with 1-16byte Application-ID */
  961|    378|		r = starcos_select_aid(card, pathbuf, pathlen, file_out);
  962|    378|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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: 378, False: 0]
  |  |  ------------------
  |  |  156|    378|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 212]
  |  |  ------------------
  |  |  157|    378|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    378|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    378|	return _ret; \
  |  |  163|    378|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  963|    378|	}
  964|  1.01k|	else if (pathtype == SC_PATH_TYPE_PATH)
  ------------------
  |  |  119|  1.01k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (964:11): [True: 1.01k, False: 0]
  ------------------
  965|  1.01k|	{
  966|  1.01k|		u8 n_pathbuf[SC_MAX_PATH_SIZE];
  967|       |
  968|       |		/* Select with path (sequence of File-IDs) */
  969|       |		/* Starcos (S 2.1 and SPK 2.3) only supports one
  970|       |		 * level of subdirectories, therefore a path is
  971|       |		 * at most 3 FID long (the last one being the FID
  972|       |		 * of a EF) => pathlen must be even and less than 6
  973|       |		 */
  974|  1.01k|		if (pathlen%2 != 0 || pathlen > 6 || pathlen <= 0)
  ------------------
  |  Branch (974:7): [True: 0, False: 1.01k]
  |  Branch (974:25): [True: 0, False: 1.01k]
  |  Branch (974:40): [True: 0, False: 1.01k]
  ------------------
  975|      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]
  |  |  ------------------
  ------------------
  976|       |		/* if pathlen == 6 then the first FID must be MF (== 3F00) */
  977|  1.01k|		if (pathlen == 6 && ( path[0] != 0x3f || path[1] != 0x00 ))
  ------------------
  |  Branch (977:7): [True: 291, False: 728]
  |  Branch (977:25): [True: 0, False: 291]
  |  Branch (977:44): [True: 0, False: 291]
  ------------------
  978|      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]
  |  |  ------------------
  ------------------
  979|       |
  980|  1.01k|		if ( IS_V3x(card) ) {
  ------------------
  |  |  121|  2.03k|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|  1.01k|#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: 210, False: 809]
  |  |  |  |  |  Branch (119:65): [True: 507, False: 302]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|    302|#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: 49, False: 253]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 253]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  981|       |			/* unify path (the first FID should be MF) */
  982|    766|			if (path[0] != 0x3f || path[1] != 0x00)
  ------------------
  |  Branch (982:8): [True: 72, False: 694]
  |  Branch (982:27): [True: 0, False: 694]
  ------------------
  983|     72|			{
  984|     72|				n_pathbuf[0] = 0x3f;
  985|     72|				n_pathbuf[1] = 0x00;
  986|     72|				memcpy(n_pathbuf+2, path, pathlen);
  987|     72|				path = n_pathbuf;
  988|     72|				pathlen += 2;
  989|     72|			}
  990|    766|		}
  991|       |
  992|  1.48k|		for ( i=0; i<pathlen-2; i+=2 )
  ------------------
  |  Branch (992:14): [True: 1.01k, False: 473]
  ------------------
  993|  1.01k|		{
  994|  1.01k|			r = starcos_select_fid(card, path[i], path[i+1], NULL, 0);
  995|  1.01k|			LOG_TEST_RET(card->ctx, r, "SELECT FILE (DF-ID) failed");
  ------------------
  |  |  174|  1.01k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.01k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.01k|	int _ret = (r); \
  |  |  |  |  168|  1.01k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 546, False: 468]
  |  |  |  |  ------------------
  |  |  |  |  169|    546|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    546|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    546|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    546|		return _ret; \
  |  |  |  |  172|    546|	} \
  |  |  |  |  173|  1.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 468]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  996|  1.01k|		}
  997|    473|		r = starcos_select_fid(card, path[pathlen-2], path[pathlen-1], file_out, 1);
  998|    473|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|    473|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    473|	int _ret = r; \
  |  |  155|    473|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 473, False: 0]
  |  |  ------------------
  |  |  156|    473|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    213|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 213, False: 260]
  |  |  ------------------
  |  |  157|    473|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    473|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    473|	return _ret; \
  |  |  163|    473|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  999|    473|	}
 1000|      0|	else
 1001|      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]
  |  |  ------------------
  ------------------
 1002|  1.43k|}
card-starcos.c:starcos_select_fid:
  790|  1.49k|{
  791|  1.49k|	sc_apdu_t apdu;
  792|  1.49k|	u8 data[] = {id_hi & 0xff, id_lo & 0xff};
  793|  1.49k|	u8 resp[SC_MAX_APDU_BUFFER_SIZE];
  794|  1.49k|	int bIsDF = 0, r;
  795|  1.49k|	int isFCP = 0;
  796|  1.49k|	int isMF = 0;
  797|       |
  798|       |	/* request FCI to distinguish between EFs and DFs */
  799|  1.49k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0x00, 0x00);
  ------------------
  |  |  294|  1.49k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  800|  1.49k|	apdu.p2   = 0x00;
  801|  1.49k|	apdu.resp = (u8*)resp;
  802|  1.49k|	apdu.resplen = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|  1.49k|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
  803|  1.49k|	apdu.le = 256;
  804|  1.49k|	apdu.lc = 2;
  805|  1.49k|	apdu.data = (u8*)data;
  806|  1.49k|	apdu.datalen = 2;
  807|       |
  808|  1.49k|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|  2.98k|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|  1.49k|#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: 294, False: 1.19k]
  |  |  |  |  |  Branch (119:65): [True: 742, False: 456]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|    456|#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: 71, False: 385]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 385]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  809|  1.10k|		if (id_hi == 0x3f && id_lo == 0x0) {
  ------------------
  |  Branch (809:7): [True: 766, False: 341]
  |  Branch (809:24): [True: 766, False: 0]
  ------------------
  810|    766|			apdu.p1 = 0x0;
  811|    766|			apdu.p2 = 0x0C;
  812|    766|			apdu.le = 0;
  813|    766|			apdu.resplen = 0;
  814|    766|			apdu.resp = NULL;
  815|    766|			apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|    766|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  816|    766|			isMF = 1;
  817|    766|		} else if (file_out || is_file) {
  ------------------
  |  Branch (817:14): [True: 217, False: 124]
  |  Branch (817:26): [True: 42, False: 82]
  ------------------
  818|       |			// last component (i.e. file or path)
  819|    259|			apdu.p1 = 0x2;
  820|    259|			apdu.p2 = 0x4;
  821|    259|		} else {
  822|       |			// path component
  823|     82|			apdu.p1 = 0x1;
  824|     82|			apdu.p2 = 0x0;
  825|     82|		}
  826|  1.10k|	}
  827|       |
  828|  1.49k|	r = sc_transmit_apdu(card, &apdu);
  829|  1.49k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.49k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.49k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.49k|	int _ret = (r); \
  |  |  |  |  168|  1.49k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 20, False: 1.47k]
  |  |  |  |  ------------------
  |  |  |  |  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.49k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  830|       |
  831|  1.47k|	if (apdu.p2 == 0x00 && apdu.sw1 == 0x62 && apdu.sw2 == 0x84 ) {
  ------------------
  |  Branch (831:6): [True: 456, False: 1.01k]
  |  Branch (831:25): [True: 0, False: 456]
  |  Branch (831:45): [True: 0, False: 0]
  ------------------
  832|       |		/* no FCI => we have a DF (see comment in process_fci()) */
  833|      0|		bIsDF = 1;
  834|      0|		apdu.p2 = 0x0C;
  835|      0|		apdu.cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|      0|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  836|      0|		apdu.resplen = 0;
  837|      0|		apdu.le = 0;
  838|      0|		r = sc_transmit_apdu(card, &apdu);
  839|      0|		LOG_TEST_RET(card->ctx, r, "APDU re-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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  840|  1.47k|	} else if ((IS_V3x(card))
  ------------------
  |  |  121|  1.47k|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|  1.47k|#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: 294, False: 1.17k]
  |  |  |  |  |  Branch (119:65): [True: 730, False: 448]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|    448|#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: 71, False: 377]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 377]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  841|  1.09k|			&& apdu.p2 == 0x4 && apdu.sw1 == 0x6a && apdu.sw2 == 0x82) {
  ------------------
  |  Branch (841:7): [True: 254, False: 841]
  |  Branch (841:25): [True: 36, False: 218]
  |  Branch (841:45): [True: 31, False: 5]
  ------------------
  842|       |		/* not a file, could be a path */
  843|     31|		bIsDF = 1;
  844|     31|		apdu.p1 = 0x1;
  845|     31|		apdu.p2 = 0x0;
  846|     31|		apdu.resplen = sizeof(resp);
  847|     31|		apdu.le = 256;
  848|     31|		apdu.lc = 2;
  849|     31|		r = sc_transmit_apdu(card, &apdu);
  850|     31|		LOG_TEST_RET(card->ctx, r, "APDU re-transmit failed");
  ------------------
  |  |  174|     31|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     31|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     31|	int _ret = (r); \
  |  |  |  |  168|     31|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 31]
  |  |  |  |  ------------------
  |  |  |  |  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|     31|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 31]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  851|  1.44k|	} else if (apdu.sw1 == 0x61 || (apdu.sw1 == 0x90 && apdu.sw2 == 0x00 && !isMF)) {
  ------------------
  |  Branch (851:13): [True: 0, False: 1.44k]
  |  Branch (851:34): [True: 870, False: 571]
  |  Branch (851:54): [True: 806, False: 64]
  |  Branch (851:74): [True: 472, False: 334]
  ------------------
  852|       |		/* SELECT returned some data (possible FCI) =>
  853|       |		 * try a READ BINARY to see if a EF is selected */
  854|    472|		sc_apdu_t apdu2;
  855|    472|		u8 resp2[2];
  856|    472|		sc_format_apdu(card, &apdu2, SC_APDU_CASE_2_SHORT, 0xB0, 0, 0);
  ------------------
  |  |  292|    472|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  857|    472|		apdu2.resp = (u8*)resp2;
  858|    472|		apdu2.resplen = 2;
  859|    472|		apdu2.le = 1;
  860|    472|		apdu2.lc = 0;
  861|    472|		r = sc_transmit_apdu(card, &apdu2);
  862|    472|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    472|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    472|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    472|	int _ret = (r); \
  |  |  |  |  168|    472|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 471]
  |  |  |  |  ------------------
  |  |  |  |  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|    472|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 471]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  863|    471|		if (apdu2.sw1 == 0x69 && apdu2.sw2 == 0x86) {
  ------------------
  |  Branch (863:7): [True: 2, False: 469]
  |  Branch (863:28): [True: 0, False: 2]
  ------------------
  864|       |			/* no current EF is selected => we have a DF */
  865|      0|			bIsDF = 1;
  866|    471|		} else {
  867|    471|			isFCP = 1;
  868|    471|		}
  869|    471|	}
  870|       |
  871|  1.47k|	if (apdu.sw1 != 0x61 && (apdu.sw1 != 0x90 || apdu.sw2 != 0x00))
  ------------------
  |  Branch (871:6): [True: 1.47k, False: 0]
  |  Branch (871:27): [True: 571, False: 900]
  |  Branch (871:47): [True: 65, False: 835]
  ------------------
  872|    636|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  153|    636|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    636|	int _ret = r; \
  |  |  155|    636|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 636, False: 0]
  |  |  ------------------
  |  |  156|    636|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|    636|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 636, False: 0]
  |  |  ------------------
  |  |  157|    636|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    636|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    636|	return _ret; \
  |  |  163|    636|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  873|       |
  874|    835|	if (file_out) {
  ------------------
  |  Branch (874:6): [True: 230, False: 605]
  ------------------
  875|    230|		sc_file_t *file = sc_file_new();
  876|    230|		if (!file)
  ------------------
  |  Branch (876:7): [True: 0, False: 230]
  ------------------
  877|    230|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  878|    230|		file->id = (id_hi << 8) + id_lo;
  879|       |
  880|    230|		if (bIsDF || isMF) {
  ------------------
  |  Branch (880:7): [True: 30, False: 200]
  |  Branch (880:16): [True: 6, False: 194]
  ------------------
  881|       |			/* we have a DF */
  882|     36|			file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     36|#define SC_FILE_TYPE_DF			0x04
  ------------------
  883|     36|			file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     36|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  884|     36|			file->size = 0;
  885|     36|			file->namelen = 0;
  886|     36|			file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|     36|#define SC_FILE_MAGIC			0x14426950
  ------------------
  887|     36|			*file_out = file;
  888|    194|		} else {
  889|       |			/* ok, assume we have a EF */
  890|    194|			if ( IS_V3x(card) ) {
  ------------------
  |  |  121|    388|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|    194|#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: 39, False: 155]
  |  |  |  |  |  Branch (119:65): [True: 107, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|     48|#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: 6, False: 42]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 42]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  891|    152|				if (isFCP) {
  ------------------
  |  Branch (891:9): [True: 152, False: 0]
  ------------------
  892|    152|					r = process_fcp_v3_4(card->ctx, file, apdu.resp,
  893|    152|							apdu.resplen);
  894|    152|				} else {
  895|      0|					r = process_fci_v3_4(card->ctx, file, apdu.resp,
  896|      0|							apdu.resplen);
  897|      0|				}
  898|    152|			} else {
  899|     42|				r = process_fci(card->ctx, file, apdu.resp,
  900|     42|						apdu.resplen);
  901|     42|			}
  902|    194|			if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    194|#define SC_SUCCESS				0
  ------------------
  |  Branch (902:8): [True: 106, False: 88]
  ------------------
  903|    106|				sc_file_free(file);
  904|    106|				return r;
  905|    106|			}
  906|       |
  907|     88|			*file_out = file;
  908|     88|		}
  909|    230|	}
  910|       |
  911|    729|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  153|    729|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    729|	int _ret = r; \
  |  |  155|    729|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 729, False: 0]
  |  |  ------------------
  |  |  156|    729|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 729]
  |  |  ------------------
  |  |  157|    729|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    729|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    729|	return _ret; \
  |  |  163|    729|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  912|    729|}
card-starcos.c:process_fcp_v3_4:
  606|    152|{
  607|    152|	size_t taglen, len = buflen;
  608|    152|	const u8 *tag = NULL, *p;
  609|       |
  610|    152|	sc_log(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__
  |  |  ------------------
  ------------------
  611|    152|		 "processing %"SC_FORMAT_LEN_SIZE_T"u FCP bytes\n", buflen);
  612|       |
  613|    152|	if (buflen < 2)
  ------------------
  |  Branch (613:6): [True: 18, False: 134]
  ------------------
  614|     18|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     18|#define SC_ERROR_INTERNAL			-1400
  ------------------
  615|    134|	if (buf[0] != 0x62)
  ------------------
  |  Branch (615:6): [True: 74, False: 60]
  ------------------
  616|     74|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     74|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  617|     60|	len = (size_t)buf[1];
  618|     60|	if (buflen - 2 < len)
  ------------------
  |  Branch (618:6): [True: 0, False: 60]
  ------------------
  619|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  620|     60|	p = buf + 2;
  621|       |
  622|     60|	tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
  623|     60|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (623:6): [True: 20, False: 40]
  |  Branch (623:21): [True: 15, False: 5]
  ------------------
  624|     15|		int bytes = (tag[0] << 8) + tag[1];
  625|     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__
  |  |  ------------------
  ------------------
  626|     15|			"  bytes in file: %d\n", bytes);
  627|     15|		file->size = bytes;
  628|     15|	}
  629|       |
  630|     60|	tag = sc_asn1_find_tag(ctx, p, len, 0xc5, &taglen);
  631|     60|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (631:6): [True: 0, False: 60]
  |  Branch (631:21): [True: 0, False: 0]
  ------------------
  632|      0|		int bytes = (tag[0] << 8) + tag[1];
  633|      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__
  |  |  ------------------
  ------------------
  634|      0|			"  bytes in file 2: %d\n", bytes);
  635|      0|		file->size = bytes;
  636|      0|	}
  637|       |
  638|     60|	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
  639|     60|	if (tag != NULL) {
  ------------------
  |  Branch (639:6): [True: 0, False: 60]
  ------------------
  640|      0|		const char *type = "unknown";
  641|      0|		const char *structure = "unknown";
  642|       |
  643|      0|		if (taglen >= 1) {
  ------------------
  |  Branch (643:7): [True: 0, False: 0]
  ------------------
  644|      0|			unsigned char byte = tag[0];
  645|      0|			if (byte & 0x40) {
  ------------------
  |  Branch (645:8): [True: 0, False: 0]
  ------------------
  646|      0|				file->shareable = 1;
  647|      0|			}
  648|      0|			if (byte == 0x38) {
  ------------------
  |  Branch (648:8): [True: 0, False: 0]
  ------------------
  649|      0|				type = "DF";
  650|      0|				file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  651|      0|				file->shareable = 1;
  652|      0|			}
  653|      0|			switch (byte & 7) {
  654|      0|			case 1:
  ------------------
  |  Branch (654:4): [True: 0, False: 0]
  ------------------
  655|       |				/* transparent EF */
  656|      0|				type = "working EF";
  657|      0|				structure = "transparent";
  658|      0|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  659|      0|				file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  660|      0|				break;
  661|      0|			case 2:
  ------------------
  |  Branch (661:4): [True: 0, False: 0]
  ------------------
  662|       |				/* linear fixed EF */
  663|      0|				type = "working EF";
  664|      0|				structure = "linear fixed";
  665|      0|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  666|      0|				file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  667|      0|				break;
  668|      0|			case 4:
  ------------------
  |  Branch (668:4): [True: 0, False: 0]
  ------------------
  669|       |				/* linear variable EF */
  670|      0|				type = "working EF";
  671|      0|				structure = "linear variable";
  672|      0|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  673|      0|				file->ef_structure = SC_FILE_EF_LINEAR_VARIABLE;
  ------------------
  |  |  224|      0|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  674|      0|				break;
  675|      0|			case 6:
  ------------------
  |  Branch (675:4): [True: 0, False: 0]
  ------------------
  676|       |				/* cyclic EF */
  677|      0|				type = "working EF";
  678|      0|				structure = "cyclic";
  679|      0|				file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  680|      0|				file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  681|      0|				break;
  682|      0|			default:
  ------------------
  |  Branch (682:4): [True: 0, False: 0]
  ------------------
  683|       |				/* use defaults from above */
  684|      0|				break;
  685|      0|			}
  686|      0|		}
  687|      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__
  |  |  ------------------
  ------------------
  688|      0|			"  type: %s\n", type);
  689|      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__
  |  |  ------------------
  ------------------
  690|      0|			"  EF structure: %s\n", structure);
  691|      0|		if (taglen >= 2) {
  ------------------
  |  Branch (691:7): [True: 0, False: 0]
  ------------------
  692|      0|			if (tag[1] != 0x41 || taglen != 5) {
  ------------------
  |  Branch (692:8): [True: 0, False: 0]
  |  Branch (692:26): [True: 0, False: 0]
  ------------------
  693|      0|				SC_FUNC_RETURN(ctx, 2,SC_ERROR_INVALID_DATA);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_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|      0|			}
  695|       |			/* formatted EF */
  696|      0|			file->record_length = (tag[2] << 8) + tag[3];
  697|      0|			file->record_count = tag[4];
  698|      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__
  |  |  ------------------
  ------------------
  699|      0|				"  rec_len: %"SC_FORMAT_LEN_SIZE_T"u  rec_cnt: %"SC_FORMAT_LEN_SIZE_T"u\n\n",
  700|      0|				file->record_length, file->record_count);
  701|      0|		}
  702|      0|	}
  703|       |
  704|     60|	tag = sc_asn1_find_tag(ctx, p, len, 0x83, &taglen);
  705|     60|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (705:6): [True: 15, False: 45]
  |  Branch (705:21): [True: 15, False: 0]
  ------------------
  706|     15|		file->id = (tag[0] << 8) | tag[1];
  707|     15|		sc_log(ctx,  "  file identifier: 0x%02X%02X\n",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  708|     15|			tag[0], tag[1]);
  709|     15|	}
  710|       |
  711|     60|	tag = sc_asn1_find_tag(ctx, p, len, 0x84, &taglen);
  712|     60|	if (tag != NULL && taglen > 0 && taglen <= 16) {
  ------------------
  |  Branch (712:6): [True: 0, False: 60]
  |  Branch (712:21): [True: 0, False: 0]
  |  Branch (712:35): [True: 0, False: 0]
  ------------------
  713|      0|		memcpy(file->name, tag, taglen);
  714|      0|		file->namelen = taglen;
  715|      0|		sc_log(ctx,  "  filename %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__
  |  |  ------------------
  ------------------
  716|      0|			sc_dump_hex(file->name, file->namelen));
  717|      0|	}
  718|       |
  719|     60|	tag = sc_asn1_find_tag(ctx, p, len, 0x8a, &taglen);
  720|     60|	if (tag != NULL && taglen == 1) {
  ------------------
  |  Branch (720:6): [True: 0, False: 60]
  |  Branch (720:21): [True: 0, False: 0]
  ------------------
  721|      0|		char* status = "unknown";
  722|      0|		switch (tag[0]) {
  723|      0|		case 1:
  ------------------
  |  Branch (723:3): [True: 0, False: 0]
  ------------------
  724|      0|			status = "creation";
  725|      0|			file->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|      0|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  726|      0|			break;
  727|      0|		case 5:
  ------------------
  |  Branch (727:3): [True: 0, False: 0]
  ------------------
  728|      0|			status = "operational active";
  729|      0|			file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      0|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  730|      0|			break;
  731|      0|		case 12:
  ------------------
  |  Branch (731:3): [True: 0, False: 0]
  ------------------
  732|      0|		case 13:
  ------------------
  |  Branch (732:3): [True: 0, False: 0]
  ------------------
  733|      0|			status = "creation";
  734|      0|			file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|      0|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  735|      0|			break;
  736|      0|		default:
  ------------------
  |  Branch (736:3): [True: 0, False: 0]
  ------------------
  737|      0|			break;
  738|      0|		}
  739|      0|		sc_log(ctx,  "  file status: %s\n", status);
  ------------------
  |  |   71|      0|#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|	}
  741|       |
  742|     60|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|     60|#define SC_FILE_MAGIC			0x14426950
  ------------------
  743|     60|	return SC_SUCCESS;
  ------------------
  |  |   28|     60|#define SC_SUCCESS				0
  ------------------
  744|     60|}
card-starcos.c:process_fci:
  478|     42|{
  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|     42|	size_t taglen, len = buflen;
  486|     42|	const u8 *tag = NULL, *p;
  487|       |
  488|     42|	sc_log(ctx,  "processing FCI bytes\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  489|       |
  490|     42|	if (buflen < 2)
  ------------------
  |  Branch (490:6): [True: 14, False: 28]
  ------------------
  491|     14|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     14|#define SC_ERROR_INTERNAL			-1400
  ------------------
  492|     28|	if (buf[0] != 0x6f)
  ------------------
  |  Branch (492:6): [True: 0, False: 28]
  ------------------
  493|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  494|     28|	len = (size_t)buf[1];
  495|     28|	if (buflen - 2 < len)
  ------------------
  |  Branch (495:6): [True: 0, False: 28]
  ------------------
  496|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  497|     28|	p = buf + 2;
  498|       |
  499|       |	/* defaults */
  500|     28|	file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     28|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  501|     28|	file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|     28|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  502|     28|	file->shareable = 0;
  503|     28|	file->record_length = 0;
  504|     28|	file->size = 0;
  505|       |
  506|     28|	tag = sc_asn1_find_tag(ctx, p, len, 0x80, &taglen);
  507|     28|	if (tag != NULL && taglen >= 2) {
  ------------------
  |  Branch (507:6): [True: 10, False: 18]
  |  Branch (507:21): [True: 10, False: 0]
  ------------------
  508|     10|		int bytes = (tag[0] << 8) + tag[1];
  509|     10|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  510|     10|			"  bytes in file: %d\n", bytes);
  511|     10|		file->size = bytes;
  512|     10|	}
  513|       |
  514|     28|	tag = sc_asn1_find_tag(ctx, p, len, 0x82, &taglen);
  515|     28|	if (tag != NULL) {
  ------------------
  |  Branch (515:6): [True: 19, False: 9]
  ------------------
  516|     19|		const char *type = "unknown";
  517|     19|		const char *structure = "unknown";
  518|       |
  519|     19|		if (taglen == 1 && tag[0] == 0x01) {
  ------------------
  |  Branch (519:7): [True: 14, False: 5]
  |  Branch (519:22): [True: 6, False: 8]
  ------------------
  520|       |			/* transparent EF */
  521|      6|			type = "working EF";
  522|      6|			structure = "transparent";
  523|      6|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      6|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  524|      6|			file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      6|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  525|     13|		} else if (taglen == 1 && tag[0] == 0x11) {
  ------------------
  |  Branch (525:14): [True: 8, False: 5]
  |  Branch (525:29): [True: 1, False: 7]
  ------------------
  526|       |			/* object EF */
  527|      1|			type = "working EF";
  528|      1|			structure = "object";
  529|      1|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      1|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  530|      1|			file->ef_structure = SC_FILE_EF_TRANSPARENT; /* TODO */
  ------------------
  |  |  221|      1|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  531|     12|		} else if (taglen == 3 && tag[1] == 0x21) {
  ------------------
  |  Branch (531:14): [True: 0, False: 12]
  |  Branch (531:29): [True: 0, False: 0]
  ------------------
  532|      0|			type = "working EF";
  533|      0|			file->record_length = tag[2];
  534|      0|			file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      0|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  535|       |			/* linear fixed, cyclic or compute */
  536|      0|			switch ( tag[0] )
  537|      0|			{
  538|      0|				case 0x02:
  ------------------
  |  Branch (538:5): [True: 0, False: 0]
  ------------------
  539|      0|					structure = "linear fixed";
  540|      0|					file->ef_structure = SC_FILE_EF_LINEAR_FIXED;
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  541|      0|					break;
  542|      0|				case 0x07:
  ------------------
  |  Branch (542:5): [True: 0, False: 0]
  ------------------
  543|      0|					structure = "cyclic";
  544|      0|					file->ef_structure = SC_FILE_EF_CYCLIC;
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  545|      0|					break;
  546|      0|				case 0x17:
  ------------------
  |  Branch (546:5): [True: 0, False: 0]
  ------------------
  547|      0|					structure = "compute";
  548|      0|					file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      0|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  549|      0|					break;
  550|      0|				default:
  ------------------
  |  Branch (550:5): [True: 0, False: 0]
  ------------------
  551|      0|					structure = "unknown";
  552|      0|					file->ef_structure = SC_FILE_EF_UNKNOWN;
  ------------------
  |  |  220|      0|#define SC_FILE_EF_UNKNOWN		0x00
  ------------------
  553|      0|					file->record_length = 0;
  554|      0|					break;
  555|      0|			}
  556|      0|		}
  557|       |
  558|     19|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  559|     19|			"  type: %s\n", type);
  560|     19|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  561|     19|			"  EF structure: %s\n", structure);
  562|     19|	}
  563|     28|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|     28|#define SC_FILE_MAGIC			0x14426950
  ------------------
  564|       |
  565|     28|	return SC_SUCCESS;
  ------------------
  |  |   28|     28|#define SC_SUCCESS				0
  ------------------
  566|     28|}
card-starcos.c:starcos_check_sw:
 1939|  10.7k|{
 1940|  10.7k|	const int err_count = sizeof(starcos_errors)/sizeof(starcos_errors[0]);
 1941|  10.7k|	int i;
 1942|       |
 1943|  10.7k|	sc_log(card->ctx,
  ------------------
  |  |   71|  10.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__
  |  |  ------------------
  ------------------
 1944|  10.7k|		"sw1 = 0x%02x, sw2 = 0x%02x\n", sw1, sw2);
 1945|       |
 1946|  10.7k|	if (sw1 == 0x90 && sw2 == 0x00)
  ------------------
  |  Branch (1946:6): [True: 9.79k, False: 966]
  |  Branch (1946:21): [True: 9.55k, False: 240]
  ------------------
 1947|  9.55k|		return SC_SUCCESS;
  ------------------
  |  |   28|  9.55k|#define SC_SUCCESS				0
  ------------------
 1948|  1.20k|	if (sw1 == 0x63 && (sw2 & ~0x0fU) == 0xc0 )
  ------------------
  |  Branch (1948:6): [True: 1, False: 1.20k]
  |  Branch (1948:21): [True: 0, False: 1]
  ------------------
 1949|      0|	{
 1950|      0|		sc_log(card->ctx,  "Verification failed (remaining tries: %d)\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__
  |  |  ------------------
  ------------------
 1951|      0|		(sw2 & 0x0f));
 1952|      0|		return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      0|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
 1953|      0|	}
 1954|       |
 1955|       |	/* check starcos error messages */
 1956|  17.8k|	for (i = 0; i < err_count; i++)
  ------------------
  |  Branch (1956:14): [True: 16.6k, False: 1.19k]
  ------------------
 1957|  16.6k|		if (starcos_errors[i].SWs == ((sw1 << 8) | sw2))
  ------------------
  |  Branch (1957:7): [True: 15, False: 16.6k]
  ------------------
 1958|     15|		{
 1959|     15|			sc_log(card->ctx,  "%s\n", starcos_errors[i].errorstr);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1960|     15|			return starcos_errors[i].errorno;
 1961|     15|		}
 1962|       |
 1963|       |	/* iso error */
 1964|  1.19k|	return iso_ops->check_sw(card, sw1, sw2);
 1965|  1.20k|}
card-starcos.c:starcos_create_file:
 1325|      4|{
 1326|      4|	int    r;
 1327|      4|	sc_starcos_create_data data;
 1328|       |
 1329|      4|	CHECK_NOT_SUPPORTED_V3_4(card);
  ------------------
  |  |  110|      4|	do { \
  |  |  111|      4|		if ((card)->type == SC_CARD_TYPE_STARCOS_V3_4) { \
  |  |  ------------------
  |  |  |  Branch (111:7): [True: 0, False: 4]
  |  |  ------------------
  |  |  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|      4|	} while (0);
  |  |  ------------------
  |  |  |  Branch (116:11): [Folded, False: 4]
  |  |  ------------------
  ------------------
 1330|       |
 1331|      4|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 1332|       |
 1333|      4|	if (file->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|      4|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1333:6): [True: 3, False: 1]
  ------------------
 1334|      3|		if (file->id == 0x3f00) {
  ------------------
  |  Branch (1334:7): [True: 0, False: 3]
  ------------------
 1335|       |			/* CREATE MF */
 1336|      0|			r = starcos_process_acl(card, file, &data);
 1337|      0|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1337:8): [True: 0, False: 0]
  ------------------
 1338|      0|				return r;
 1339|      0|			return starcos_create_mf(card, &data);
 1340|      3|		} else {
 1341|       |			/* CREATE DF */
 1342|      3|			r = starcos_process_acl(card, file, &data);
 1343|      3|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  |  Branch (1343:8): [True: 0, False: 3]
  ------------------
 1344|      0|				return r;
 1345|      3|			return starcos_create_df(card, &data);
 1346|      3|		}
 1347|      3|	} else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|      1|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1347:13): [True: 1, False: 0]
  ------------------
 1348|       |		/* CREATE EF */
 1349|      1|		r = starcos_process_acl(card, file, &data);
 1350|      1|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (1350:7): [True: 0, False: 1]
  ------------------
 1351|      0|			return r;
 1352|      1|		return starcos_create_ef(card, &data);
 1353|      1|	} else
 1354|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1355|      4|}
card-starcos.c:starcos_process_acl:
 1052|      4|{
 1053|      4|	u8     tmp, *p;
 1054|      4|	static const u8 def_key[] = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
 1055|       |
 1056|      4|	if (file->type == SC_FILE_TYPE_DF && file->id == 0x3f00) {
  ------------------
  |  |  214|      8|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1056:6): [True: 3, False: 1]
  |  Branch (1056:39): [True: 0, False: 3]
  ------------------
 1057|      0|		p    = data->data.mf.header;
 1058|      0|		memcpy(p, def_key, 8);
 1059|      0|		p   += 8;
 1060|      0|		*p++ = (file->size >> 8) & 0xff;
 1061|      0|		*p++ = file->size & 0xff;
 1062|       |		/* guess isf size (mf_size / 4) */
 1063|      0|		*p++ = (file->size >> 10) & 0xff;
 1064|      0|		*p++ = (file->size >> 2)  & 0xff;
 1065|       |		/* ac create ef  */
 1066|      0|		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  | 1015|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1067|       |		/* ac create key */
 1068|      0|		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  | 1015|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1069|       |		/* ac create df  */
 1070|      0|		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  | 1015|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1071|       |		/* use the same ac for register df and create df */
 1072|      0|		*p++ = data->data.mf.header[14];
 1073|       |		/* if sm is required use combined mode */
 1074|      0|		if (file->acl[SC_AC_OP_CREATE] && (sc_file_get_acl_entry(file, SC_AC_OP_CREATE))->method & SC_AC_PRO)
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              		if (file->acl[SC_AC_OP_CREATE] && (sc_file_get_acl_entry(file, SC_AC_OP_CREATE))->method & SC_AC_PRO)
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              		if (file->acl[SC_AC_OP_CREATE] && (sc_file_get_acl_entry(file, SC_AC_OP_CREATE))->method & SC_AC_PRO)
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (1074:7): [True: 0, False: 0]
  |  Branch (1074:37): [True: 0, False: 0]
  ------------------
 1075|      0|			tmp = 0x03;	/* combined mode */
 1076|      0|		else
 1077|      0|			tmp = 0x00;	/* no sm */
 1078|      0|		*p++ = tmp;	/* use the same sm mode for all ops */
 1079|      0|		*p++ = tmp;
 1080|      0|		*p = tmp;
 1081|      0|		data->type = SC_STARCOS_MF_DATA;
  ------------------
  |  |  373|      0|#define	SC_STARCOS_MF_DATA	0x01
  ------------------
 1082|       |
 1083|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1084|      4|	} else if (file->type == SC_FILE_TYPE_DF){
  ------------------
  |  |  214|      4|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1084:13): [True: 3, False: 1]
  ------------------
 1085|      3|		p    = data->data.df.header;
 1086|      3|		*p++ = (file->id >> 8) & 0xff;
 1087|      3|		*p++ = file->id & 0xff;
 1088|      3|		if (file->namelen) {
  ------------------
  |  Branch (1088:7): [True: 1, False: 2]
  ------------------
 1089|       |			/* copy aid */
 1090|      1|			*p++ = file->namelen & 0xff;
 1091|      1|			memset(p, 0, 16);
 1092|      1|			memcpy(p, file->name, (u8)file->namelen);
 1093|      1|			p   += 16;
 1094|      2|		} else {
 1095|       |			/* use the fid as aid */
 1096|      2|			*p++ = 2;
 1097|      2|			memset(p, 0, 16);
 1098|      2|			*p++ = (file->id >> 8) & 0xff;
 1099|      2|			*p++ = file->id & 0xff;
 1100|      2|			p   += 14;
 1101|      2|		}
 1102|       |		/* guess isf size */
 1103|      3|		*p++ = (file->size >> 10) & 0xff;	/* ISF space */
 1104|      3|		*p++ = (file->size >> 2)  & 0xff;	/* ISF space */
 1105|       |		/* ac create ef  */
 1106|      3|		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  |  169|      3|#define SC_AC_OP_CREATE			3
  ------------------
              		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  | 1015|      3|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1107|       |		/* ac create key */
 1108|      3|		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  |  169|      3|#define SC_AC_OP_CREATE			3
  ------------------
              		*p++ = process_acl_entry(file,SC_AC_OP_CREATE,STARCOS_AC_ALWAYS);
  ------------------
  |  | 1015|      3|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1109|       |		/* set sm byte (same for keys and ef) */
 1110|      3|		if (file->acl[SC_AC_OP_CREATE] &&
  ------------------
  |  |  169|      3|#define SC_AC_OP_CREATE			3
  ------------------
  |  Branch (1110:7): [True: 3, False: 0]
  ------------------
 1111|      3|		    (sc_file_get_acl_entry(file, SC_AC_OP_CREATE)->method &
  ------------------
  |  |  169|      3|#define SC_AC_OP_CREATE			3
  ------------------
  |  Branch (1111:7): [True: 0, False: 3]
  ------------------
 1112|      3|		     SC_AC_PRO))
  ------------------
  |  |  153|      3|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
 1113|      0|			tmp = 0x03;
 1114|      3|		else
 1115|      3|			tmp = 0x00;
 1116|      3|		*p++ = tmp;	/* SM CR  */
 1117|      3|		*p = tmp;	/* SM ISF */
 1118|       |
 1119|      3|		data->data.df.size[0] = (file->size >> 8) & 0xff;
 1120|      3|		data->data.df.size[1] = file->size & 0xff;
 1121|      3|		data->type = SC_STARCOS_DF_DATA;
  ------------------
  |  |  374|      3|#define SC_STARCOS_DF_DATA	0x02
  ------------------
 1122|       |
 1123|      3|		return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
 1124|      3|	} else if (file->type == SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|      1|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1124:13): [True: 1, False: 0]
  ------------------
 1125|      1|		p    = data->data.ef.header;
 1126|      1|		*p++ = (file->id >> 8) & 0xff;
 1127|      1|		*p++ = file->id & 0xff;
 1128|       |		/* ac read  */
 1129|      1|		*p++ = process_acl_entry(file, SC_AC_OP_READ,STARCOS_AC_ALWAYS);
  ------------------
  |  |  188|      1|#define SC_AC_OP_READ			22
  ------------------
              		*p++ = process_acl_entry(file, SC_AC_OP_READ,STARCOS_AC_ALWAYS);
  ------------------
  |  | 1015|      1|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1130|       |		/* ac write */
 1131|      1|		*p++ = process_acl_entry(file, SC_AC_OP_WRITE,STARCOS_AC_ALWAYS);
  ------------------
  |  |  190|      1|#define SC_AC_OP_WRITE			24
  ------------------
              		*p++ = process_acl_entry(file, SC_AC_OP_WRITE,STARCOS_AC_ALWAYS);
  ------------------
  |  | 1015|      1|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1132|       |		/* ac erase */
 1133|      1|		*p++ = process_acl_entry(file, SC_AC_OP_ERASE,STARCOS_AC_ALWAYS);
  ------------------
  |  |  202|      1|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|      1|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
              		*p++ = process_acl_entry(file, SC_AC_OP_ERASE,STARCOS_AC_ALWAYS);
  ------------------
  |  | 1015|      1|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1134|      1|		*p++ = STARCOS_AC_ALWAYS;	/* AC LOCK     */
  ------------------
  |  | 1015|      1|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1135|      1|		*p++ = STARCOS_AC_ALWAYS;	/* AC UNLOCK   */
  ------------------
  |  | 1015|      1|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1136|      1|		*p++ = STARCOS_AC_ALWAYS;	/* AC INCREASE */
  ------------------
  |  | 1015|      1|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1137|      1|		*p++ = STARCOS_AC_ALWAYS;	/* AC DECREASE */
  ------------------
  |  | 1015|      1|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
 1138|      1|		*p++ = 0x00;			/* rfu         */
 1139|      1|		*p++ = 0x00;			/* rfu         */
 1140|       |		/* use sm (in combined mode) if wanted */
 1141|      1|		if ((file->acl[SC_AC_OP_READ]   && (sc_file_get_acl_entry(file, SC_AC_OP_READ)->method & SC_AC_PRO)) ||
  ------------------
  |  |  188|      1|#define SC_AC_OP_READ			22
  ------------------
              		if ((file->acl[SC_AC_OP_READ]   && (sc_file_get_acl_entry(file, SC_AC_OP_READ)->method & SC_AC_PRO)) ||
  ------------------
  |  |  188|      1|#define SC_AC_OP_READ			22
  ------------------
              		if ((file->acl[SC_AC_OP_READ]   && (sc_file_get_acl_entry(file, SC_AC_OP_READ)->method & SC_AC_PRO)) ||
  ------------------
  |  |  153|      1|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (1141:8): [True: 1, False: 0]
  |  Branch (1141:38): [True: 0, False: 1]
  ------------------
 1142|      1|		    (file->acl[SC_AC_OP_UPDATE] && (sc_file_get_acl_entry(file, SC_AC_OP_UPDATE)->method & SC_AC_PRO)) ||
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
              		    (file->acl[SC_AC_OP_UPDATE] && (sc_file_get_acl_entry(file, SC_AC_OP_UPDATE)->method & SC_AC_PRO)) ||
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
              		    (file->acl[SC_AC_OP_UPDATE] && (sc_file_get_acl_entry(file, SC_AC_OP_UPDATE)->method & SC_AC_PRO)) ||
  ------------------
  |  |  153|      1|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (1142:8): [True: 1, False: 0]
  |  Branch (1142:38): [True: 0, False: 1]
  ------------------
 1143|      1|		    (file->acl[SC_AC_OP_WRITE]  && (sc_file_get_acl_entry(file, SC_AC_OP_WRITE)->method & SC_AC_PRO)) )
  ------------------
  |  |  190|      1|#define SC_AC_OP_WRITE			24
  ------------------
              		    (file->acl[SC_AC_OP_WRITE]  && (sc_file_get_acl_entry(file, SC_AC_OP_WRITE)->method & SC_AC_PRO)) )
  ------------------
  |  |  190|      1|#define SC_AC_OP_WRITE			24
  ------------------
              		    (file->acl[SC_AC_OP_WRITE]  && (sc_file_get_acl_entry(file, SC_AC_OP_WRITE)->method & SC_AC_PRO)) )
  ------------------
  |  |  153|      1|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (1143:8): [True: 1, False: 0]
  |  Branch (1143:38): [True: 0, False: 1]
  ------------------
 1144|      0|			tmp = 0x03;
 1145|      1|		else
 1146|      1|			tmp = 0x00;
 1147|      1|		*p++ = tmp;			/* SM byte     */
 1148|      1|		*p++ = 0x00;			/* use the least significant 5 bits
 1149|       |					 	 * of the FID as SID */
 1150|      1|		switch (file->ef_structure)
 1151|      1|		{
 1152|      1|		case SC_FILE_EF_TRANSPARENT:
  ------------------
  |  |  221|      1|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (1152:3): [True: 1, False: 0]
  ------------------
 1153|      1|			*p++ = 0x81;
 1154|      1|			*p++ = (file->size >> 8) & 0xff;
 1155|      1|			*p = file->size & 0xff;
 1156|      1|			break;
 1157|      0|		case SC_FILE_EF_LINEAR_FIXED:
  ------------------
  |  |  222|      0|#define SC_FILE_EF_LINEAR_FIXED		0x02
  ------------------
  |  Branch (1157:3): [True: 0, False: 1]
  ------------------
 1158|      0|			*p++ = 0x82;
 1159|      0|			*p++ = file->record_count  & 0xff;
 1160|      0|			*p = file->record_length & 0xff;
 1161|      0|			break;
 1162|      0|		case SC_FILE_EF_CYCLIC:
  ------------------
  |  |  226|      0|#define SC_FILE_EF_CYCLIC		0x06
  ------------------
  |  Branch (1162:3): [True: 0, False: 1]
  ------------------
 1163|      0|			*p++ = 0x84;
 1164|      0|			*p++ = file->record_count  & 0xff;
 1165|      0|			*p = file->record_length & 0xff;
 1166|      0|			break;
 1167|      0|		default:
  ------------------
  |  Branch (1167:3): [True: 0, False: 1]
  ------------------
 1168|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1169|      1|		}
 1170|      1|		data->type = SC_STARCOS_EF_DATA;
  ------------------
  |  |  375|      1|#define SC_STARCOS_EF_DATA	0x04
  ------------------
 1171|       |
 1172|      1|		return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
 1173|      1|	} else
 1174|      0|                return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1175|      4|}
card-starcos.c:process_acl_entry:
 1020|      9|{
 1021|      9|	u8 def = (u8)in_def;
 1022|      9|	const sc_acl_entry_t *entry = sc_file_get_acl_entry(in, method);
 1023|      9|	if (!entry)
  ------------------
  |  Branch (1023:6): [True: 0, False: 9]
  ------------------
 1024|      0|		return def;
 1025|      9|	else if (entry->method & SC_AC_CHV) {
  ------------------
  |  |  151|      9|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1025:11): [True: 0, False: 9]
  ------------------
 1026|      0|		unsigned int key_ref = entry->key_ref;
 1027|      0|		if (key_ref == SC_AC_KEY_REF_NONE)
  ------------------
  |  |  204|      0|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  |  Branch (1027:7): [True: 0, False: 0]
  ------------------
 1028|      0|			return def;
 1029|      0|		else if ((key_ref & 0x0f) == 1)
  ------------------
  |  Branch (1029:12): [True: 0, False: 0]
  ------------------
 1030|       |			/* SOPIN */
 1031|      0|			return (key_ref & 0x80 ? 0x10 : 0x00) | 0x01;
  ------------------
  |  Branch (1031:12): [True: 0, False: 0]
  ------------------
 1032|      0|		else
 1033|      0|			return (key_ref & 0x80 ? 0x10 : 0x00) | STARCOS_PINID2STATE(key_ref);
  ------------------
  |  | 1017|      0|#define STARCOS_PINID2STATE(a)	((((a) & 0x0f) == 0x01) ? ((a) & 0x0f) : (0x0f - ((0x0f & (a)) >> 1)))
  |  |  ------------------
  |  |  |  Branch (1017:33): [True: 0, False: 0]
  |  |  ------------------
  ------------------
  |  Branch (1033:12): [True: 0, False: 0]
  ------------------
 1034|      9|	} else if (entry->method & SC_AC_NEVER)
  ------------------
  |  |  163|      9|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (1034:13): [True: 0, False: 9]
  ------------------
 1035|      0|		return STARCOS_AC_NEVER;
  ------------------
  |  | 1016|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
 1036|      9|	else
 1037|      9|		return def;
 1038|      9|}
card-starcos.c:starcos_create_df:
 1218|     16|{
 1219|     16|	int    r;
 1220|     16|	size_t len;
 1221|     16|	sc_apdu_t       apdu;
 1222|     16|	sc_context_t   *ctx = card->ctx;
 1223|       |
 1224|     16|	CHECK_NOT_SUPPORTED_V3_4(card);
  ------------------
  |  |  110|     16|	do { \
  |  |  111|     16|		if ((card)->type == SC_CARD_TYPE_STARCOS_V3_4) { \
  |  |  ------------------
  |  |  |  Branch (111:7): [True: 0, False: 16]
  |  |  ------------------
  |  |  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|     16|	} while (0);
  |  |  ------------------
  |  |  |  Branch (116:11): [Folded, False: 16]
  |  |  ------------------
  ------------------
 1225|       |
 1226|     16|	sc_log(ctx,  "creating DF\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1227|       |	/* first step: REGISTER DF */
 1228|     16|	sc_log(ctx,  "calling REGISTER DF\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1229|       |
 1230|     16|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x52,
  ------------------
  |  |  293|     16|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1231|     16|		       data->data.df.size[0], data->data.df.size[1]);
 1232|     16|	len  = 3 + data->data.df.header[2];
 1233|     16|	apdu.cla |= 0x80;
 1234|     16|	apdu.lc   = len;
 1235|     16|	apdu.datalen = len;
 1236|     16|	apdu.data = data->data.df.header;
 1237|       |
 1238|     16|	r = sc_transmit_apdu(card, &apdu);
 1239|     16|	LOG_TEST_RET(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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1240|       |	/* second step: CREATE DF */
 1241|     16|	sc_log(ctx,  "calling CREATE DF\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1242|       |
 1243|     16|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x01, 0x00);
  ------------------
  |  |  293|     16|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1244|     16|	apdu.cla |= 0x80;
 1245|     16|	apdu.lc   = 25;
 1246|     16|	apdu.datalen = 25;
 1247|     16|	apdu.data = data->data.df.header;
 1248|       |
 1249|     16|	r = sc_transmit_apdu(card, &apdu);
 1250|     16|	LOG_TEST_RET(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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1251|     16|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
 1252|     16|}
card-starcos.c:starcos_create_ef:
 1264|     13|{
 1265|     13|	int    r;
 1266|     13|	sc_apdu_t       apdu;
 1267|     13|	sc_context_t   *ctx = card->ctx;
 1268|       |
 1269|     13|	CHECK_NOT_SUPPORTED_V3_4(card);
  ------------------
  |  |  110|     13|	do { \
  |  |  111|     13|		if ((card)->type == SC_CARD_TYPE_STARCOS_V3_4) { \
  |  |  ------------------
  |  |  |  Branch (111:7): [True: 0, False: 13]
  |  |  ------------------
  |  |  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|     13|	} while (0);
  |  |  ------------------
  |  |  |  Branch (116:11): [Folded, False: 13]
  |  |  ------------------
  ------------------
 1270|       |
 1271|     13|	sc_log(ctx,  "creating EF\n");
  ------------------
  |  |   71|     13|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1272|       |
 1273|     13|	sc_format_apdu(card,&apdu,SC_APDU_CASE_3_SHORT,0xE0,0x03,0x00);
  ------------------
  |  |  293|     13|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1274|     13|	apdu.cla |= 0x80;
 1275|     13|	apdu.lc   = 16;
 1276|     13|	apdu.datalen = 16;
 1277|     13|	apdu.data = (u8 *) data->data.ef.header;
 1278|       |
 1279|     13|	r = sc_transmit_apdu(card, &apdu);
 1280|     13|	LOG_TEST_RET(card->ctx, r, "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: 0, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1281|     13|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
 1282|     13|}
card-starcos.c:starcos_card_ctl:
 2014|    392|{
 2015|    392|	sc_starcos_create_data *tmp;
 2016|       |
 2017|    392|	switch (cmd)
 2018|    392|	{
 2019|     25|	case SC_CARDCTL_STARCOS_CREATE_FILE:
  ------------------
  |  Branch (2019:2): [True: 25, False: 367]
  ------------------
 2020|     25|		tmp = (sc_starcos_create_data *) ptr;
 2021|     25|		if (tmp->type == SC_STARCOS_MF_DATA)
  ------------------
  |  |  373|     25|#define	SC_STARCOS_MF_DATA	0x01
  ------------------
  |  Branch (2021:7): [True: 0, False: 25]
  ------------------
 2022|      0|			return starcos_create_mf(card, tmp);
 2023|     25|		else if (tmp->type == SC_STARCOS_DF_DATA)
  ------------------
  |  |  374|     25|#define SC_STARCOS_DF_DATA	0x02
  ------------------
  |  Branch (2023:12): [True: 13, False: 12]
  ------------------
 2024|     13|			return starcos_create_df(card, tmp);
 2025|     12|		else if (tmp->type == SC_STARCOS_EF_DATA)
  ------------------
  |  |  375|     12|#define SC_STARCOS_EF_DATA	0x04
  ------------------
  |  Branch (2025:12): [True: 12, False: 0]
  ------------------
 2026|     12|			return starcos_create_ef(card, tmp);
 2027|      0|		else
 2028|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2029|     66|	case SC_CARDCTL_STARCOS_CREATE_END:
  ------------------
  |  Branch (2029:2): [True: 66, False: 326]
  ------------------
 2030|     66|		return starcos_create_end(card, (sc_file_t *)ptr);
 2031|     43|	case SC_CARDCTL_STARCOS_WRITE_KEY:
  ------------------
  |  Branch (2031:2): [True: 43, False: 349]
  ------------------
 2032|     43|		return starcos_write_key(card, (sc_starcos_wkey_data *)ptr);
 2033|      0|	case SC_CARDCTL_STARCOS_GENERATE_KEY:
  ------------------
  |  Branch (2033:2): [True: 0, False: 392]
  ------------------
 2034|      0|		return starcos_gen_key(card, (sc_starcos_gen_key_data *)ptr);
 2035|     63|	case SC_CARDCTL_ERASE_CARD:
  ------------------
  |  Branch (2035:2): [True: 63, False: 329]
  ------------------
 2036|     63|		return starcos_erase_card(card);
 2037|     94|	case SC_CARDCTL_GET_SERIALNR:
  ------------------
  |  Branch (2037:2): [True: 94, False: 298]
  ------------------
 2038|     94|		return starcos_get_serialnr(card, (sc_serial_number_t *)ptr);
 2039|    101|	default:
  ------------------
  |  Branch (2039:2): [True: 101, False: 291]
  ------------------
 2040|    101|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    101|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2041|    392|	}
 2042|    392|}
card-starcos.c:starcos_create_end:
 1294|     66|{
 1295|     66|	int r;
 1296|     66|	u8  fid[2];
 1297|     66|	sc_apdu_t       apdu;
 1298|       |
 1299|     66|	if (file->type != SC_FILE_TYPE_DF)
  ------------------
  |  |  214|     66|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1299:6): [True: 0, False: 66]
  ------------------
 1300|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1301|       |
 1302|     66|	CHECK_NOT_SUPPORTED_V3_4(card);
  ------------------
  |  |  110|     66|	do { \
  |  |  111|     66|		if ((card)->type == SC_CARD_TYPE_STARCOS_V3_4) { \
  |  |  ------------------
  |  |  |  Branch (111:7): [True: 6, False: 60]
  |  |  ------------------
  |  |  112|      6|			sc_log((card)->ctx,  \
  |  |  ------------------
  |  |  |  |   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__
  |  |  |  |  ------------------
  |  |  ------------------
  |  |  113|      6|				"not supported for STARCOS 3.4 cards"); \
  |  |  114|      6|			return SC_ERROR_NOT_SUPPORTED; \
  |  |  ------------------
  |  |  |  |   89|      6|#define SC_ERROR_NOT_SUPPORTED			-1408
  |  |  ------------------
  |  |  115|      6|		} \
  |  |  116|     66|	} while (0);
  |  |  ------------------
  |  |  |  Branch (116:11): [Folded, False: 60]
  |  |  ------------------
  ------------------
 1303|       |
 1304|     60|	fid[0] = (file->id >> 8) & 0xff;
 1305|     60|	fid[1] = file->id & 0xff;
 1306|     60|	sc_format_apdu(card,&apdu,SC_APDU_CASE_3_SHORT, 0xE0, 0x02, 0x00);
  ------------------
  |  |  293|     60|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1307|     60|	apdu.cla |= 0x80;
 1308|     60|	apdu.lc   = 2;
 1309|     60|	apdu.datalen = 2;
 1310|     60|	apdu.data = fid;
 1311|     60|	r = sc_transmit_apdu(card, &apdu);
 1312|     60|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 0, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  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|     60|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1313|     60|	return sc_check_sw(card, apdu.sw1, apdu.sw2);
 1314|     60|}
card-starcos.c:starcos_write_key:
 1399|     43|{
 1400|     43|	int       r;
 1401|     43|	u8        sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1402|     43|	const u8 *p;
 1403|     43|	size_t    len = sizeof(sbuf), tlen, offset = 0;
 1404|     43|	sc_apdu_t       apdu;
 1405|       |
 1406|     43|	CHECK_NOT_SUPPORTED_V3_4(card);
  ------------------
  |  |  110|     43|	do { \
  |  |  111|     43|		if ((card)->type == SC_CARD_TYPE_STARCOS_V3_4) { \
  |  |  ------------------
  |  |  |  Branch (111:7): [True: 0, False: 43]
  |  |  ------------------
  |  |  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|     43|	} while (0);
  |  |  ------------------
  |  |  |  Branch (116:11): [Folded, False: 43]
  |  |  ------------------
  ------------------
 1407|       |
 1408|     43|	if (data->mode == 0) {	/* mode == 0 => install */
  ------------------
  |  Branch (1408:6): [True: 43, False: 0]
  ------------------
 1409|       |		/* install key header */
 1410|     43|		sbuf[0] = 0xc1;	/* key header tag    */
 1411|     43|		sbuf[1]	= 0x0c;	/* key header length */
 1412|     43|		memcpy(sbuf + 2, data->key_header, 12);
 1413|     43|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xf4,
  ------------------
  |  |  293|     43|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1414|     43|			       data->mode, 0x00);
 1415|     43|		apdu.cla |= 0x80;
 1416|     43|		apdu.lc   = 14;
 1417|     43|		apdu.datalen = 14;
 1418|     43|		apdu.data = sbuf;
 1419|       |
 1420|     43|		r = sc_transmit_apdu(card, &apdu);
 1421|     43|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 0, False: 43]
  |  |  |  |  ------------------
  |  |  |  |  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|     43|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 43]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1422|     43|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1422:7): [True: 12, False: 31]
  |  Branch (1422:27): [True: 1, False: 30]
  ------------------
 1423|     13|			return sc_check_sw(card, apdu.sw1, apdu.sw2);
 1424|     30|		if (data->key == NULL)
  ------------------
  |  Branch (1424:7): [True: 10, False: 20]
  ------------------
 1425|     10|			return SC_SUCCESS;
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
 1426|     30|	}
 1427|       |
 1428|     20|	if (data->key == NULL)
  ------------------
  |  Branch (1428:6): [True: 0, False: 20]
  ------------------
 1429|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1430|       |
 1431|     20|	p    = data->key;
 1432|     20|	tlen = data->key_len;
 1433|     38|	while (tlen != 0) {
  ------------------
  |  Branch (1433:9): [True: 20, False: 18]
  ------------------
 1434|       |		/* transmit the key in chunks of STARCOS_WKEY_CSIZE bytes */
 1435|     20|		u8 c_len = tlen < STARCOS_WKEY_CSIZE ? tlen : STARCOS_WKEY_CSIZE;
  ------------------
  |  | 1386|     20|#define STARCOS_WKEY_CSIZE	124
  ------------------
              		u8 c_len = tlen < STARCOS_WKEY_CSIZE ? tlen : STARCOS_WKEY_CSIZE;
  ------------------
  |  | 1386|     20|#define STARCOS_WKEY_CSIZE	124
  ------------------
  |  Branch (1435:14): [True: 20, False: 0]
  ------------------
 1436|     20|		sbuf[0] = 0xc2;
 1437|     20|		sbuf[1] = 3 + c_len;
 1438|     20|		sbuf[2] = data->kid;
 1439|     20|		sbuf[3] = (offset >> 8) & 0xff;
 1440|     20|		sbuf[4] = offset & 0xff;
 1441|     20|		memcpy(sbuf+5, p, c_len);
 1442|     20|		len = 5 + c_len;
 1443|     20|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xf4, data->mode, 0x00);
  ------------------
  |  |  293|     20|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1444|     20|		apdu.cla    |= 0x80;
 1445|     20|		apdu.lc      = len;
 1446|     20|		apdu.datalen = len;
 1447|     20|		apdu.data    = sbuf;
 1448|       |
 1449|     20|		r = sc_transmit_apdu(card, &apdu);
 1450|     20|		LOG_TEST_RET(card->ctx, r, "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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1451|     20|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (1451:7): [True: 0, False: 20]
  |  Branch (1451:27): [True: 2, False: 18]
  ------------------
 1452|      2|			return sc_check_sw(card, apdu.sw1, apdu.sw2);
 1453|     18|		offset += c_len;
 1454|     18|		p      += c_len;
 1455|     18|		tlen   -= c_len;
 1456|     18|	}
 1457|     18|	return SC_SUCCESS;
  ------------------
  |  |   28|     18|#define SC_SUCCESS				0
  ------------------
 1458|     20|}
card-starcos.c:starcos_erase_card:
 1365|     63|{	/* restore the delivery state */
 1366|     63|	int r;
 1367|     63|	u8  sbuf[2];
 1368|     63|	sc_apdu_t apdu = {0};
 1369|       |
 1370|     63|	sbuf[0] = 0x3f;
 1371|     63|	sbuf[1] = 0x00;
 1372|     63|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
  ------------------
  |  |  293|     63|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1373|     63|	apdu.cla |= 0x80;
 1374|     63|	apdu.lc   = 2;
 1375|     63|	apdu.datalen = 2;
 1376|     63|	apdu.data = sbuf;
 1377|       |
 1378|     63|	r = sc_transmit_apdu(card, &apdu);
 1379|     63|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 0, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  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|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 63]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1380|     63|	if (apdu.sw1 == 0x69 && apdu.sw2 == 0x85)
  ------------------
  |  Branch (1380:6): [True: 0, False: 63]
  |  Branch (1380:26): [True: 0, False: 0]
  ------------------
 1381|       |		/* no MF to delete, ignore error */
 1382|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1383|     63|	else return sc_check_sw(card, apdu.sw1, apdu.sw2);
 1384|     63|}
card-starcos.c:starcos_get_serialnr:
 1968|     94|{
 1969|     94|	int r;
 1970|     94|	u8  rbuf[SC_MAX_APDU_BUFFER_SIZE];
 1971|     94|	sc_apdu_t apdu;
 1972|       |
 1973|     94|	if (!serial)
  ------------------
  |  Branch (1973:6): [True: 0, False: 94]
  ------------------
 1974|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1975|       |
 1976|       |	/* see if we have cached serial number */
 1977|     94|	if (card->serialnr.len) {
  ------------------
  |  Branch (1977:6): [True: 3, False: 91]
  ------------------
 1978|      3|		memcpy(serial, &card->serialnr, sizeof(*serial));
 1979|      3|		return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
 1980|      3|	}
 1981|       |
 1982|     91|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|    182|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|     91|#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: 7, False: 84]
  |  |  |  |  |  Branch (119:65): [True: 58, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|     26|#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: 1, False: 25]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1983|     66|		card->serialnr.len = SC_MAX_SERIALNR;
  ------------------
  |  |  372|     66|#define SC_MAX_SERIALNR         32
  ------------------
 1984|     66|		r = sc_parse_ef_gdo(card, card->serialnr.value, &card->serialnr.len, NULL, 0);
 1985|     66|		if (r < 0) {
  ------------------
  |  Branch (1985:7): [True: 42, False: 24]
  ------------------
 1986|     42|			card->serialnr.len = 0;
 1987|     42|			return r;
 1988|     42|		}
 1989|     66|	} else {
 1990|       |		/* get serial number via GET CARD DATA */
 1991|     25|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xf6, 0x00, 0x00);
  ------------------
  |  |  292|     25|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
 1992|     25|		apdu.cla |= 0x80;
 1993|     25|		apdu.resp = rbuf;
 1994|     25|		apdu.resplen = sizeof(rbuf);
 1995|     25|		apdu.le   = 256;
 1996|     25|		apdu.lc   = 0;
 1997|     25|		apdu.datalen = 0;
 1998|     25|		r = sc_transmit_apdu(card, &apdu);
 1999|     25|		LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     25|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     25|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     25|	int _ret = (r); \
  |  |  |  |  168|     25|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2000|     24|		if (apdu.sw1 != 0x90 || apdu.sw2 != 0x00)
  ------------------
  |  Branch (2000:7): [True: 7, False: 17]
  |  Branch (2000:27): [True: 1, False: 16]
  ------------------
 2001|      8|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      8|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2002|       |		/* cache serial number */
 2003|     16|		memcpy(card->serialnr.value, apdu.resp, MIN(apdu.resplen, SC_MAX_SERIALNR));
  ------------------
  |  |   70|     16|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 16, False: 0]
  |  |  ------------------
  ------------------
 2004|     16|		card->serialnr.len = MIN(apdu.resplen, SC_MAX_SERIALNR);
  ------------------
  |  |   70|     16|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 16, False: 0]
  |  |  ------------------
  ------------------
 2005|     16|	}
 2006|       |
 2007|       |	/* copy and return serial number */
 2008|     40|	memcpy(serial, &card->serialnr, sizeof(*serial));
 2009|       |
 2010|     40|	return SC_SUCCESS;
  ------------------
  |  |   28|     40|#define SC_SUCCESS				0
  ------------------
 2011|     91|}
card-starcos.c:starcos_pin_cmd:
 2079|     53|{
 2080|     53|	int r;
 2081|       |
 2082|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2083|     53|	starcos_ex_data * ex_data = (starcos_ex_data*)card->drv_data;
 2084|     53|	if ( IS_V3x(card) ) {
  ------------------
  |  |  121|    106|#define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  119|     53|#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: 7, False: 46]
  |  |  |  |  |  Branch (119:65): [True: 35, False: 11]
  |  |  |  |  ------------------
  |  |  ------------------
  |  |               #define IS_V3x(card) IS_V34(card) || IS_V35(card)
  |  |  ------------------
  |  |  |  |  120|     11|#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: 1, False: 10]
  |  |  |  |  |  Branch (120:65): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2085|     43|		data->flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  429|     43|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
 2086|     43|		data->pin1.encoding = ex_data->pin_encoding;
 2087|     43|	}
 2088|     53|	r = iso_ops->pin_cmd(card, data);
 2089|     53|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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|     40|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 40, False: 13]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
 2090|     53|}

sc_get_tcos_driver:
  739|  3.69k|{
  740|  3.69k|	struct sc_card_driver *iso_drv = sc_get_iso7816_driver();
  741|       |
  742|  3.69k|	if (iso_ops == NULL) iso_ops = iso_drv->ops;
  ------------------
  |  Branch (742:6): [True: 1, False: 3.69k]
  ------------------
  743|  3.69k|	tcos_ops = *iso_drv->ops;
  744|       |
  745|  3.69k|	tcos_ops.match_card           = tcos_match_card;
  746|  3.69k|	tcos_ops.init                 = tcos_init;
  747|  3.69k|	tcos_ops.finish               = tcos_finish;
  748|  3.69k|	tcos_ops.create_file          = tcos_create_file;
  749|  3.69k|	tcos_ops.set_security_env     = tcos_set_security_env;
  750|  3.69k|	tcos_ops.select_file          = tcos_select_file;
  751|  3.69k|	tcos_ops.list_files           = tcos_list_files;
  752|  3.69k|	tcos_ops.delete_file          = tcos_delete_file;
  753|  3.69k|	tcos_ops.compute_signature    = tcos_compute_signature;
  754|  3.69k|	tcos_ops.decipher             = tcos_decipher;
  755|  3.69k|	tcos_ops.restore_security_env = tcos_restore_security_env;
  756|  3.69k|	tcos_ops.card_ctl             = tcos_card_ctl;
  757|       |
  758|  3.69k|	return &tcos_drv;
  759|  3.69k|}
card-tcos.c:tcos_match_card:
   77|  3.30k|{
   78|  3.30k|	int i;
   79|       |
   80|  3.30k|	i = _sc_match_atr(card, tcos_atrs, &card->type);
   81|  3.30k|	if (i < 0)
  ------------------
  |  Branch (81:6): [True: 3.30k, False: 0]
  ------------------
   82|  3.30k|		return 0;
   83|      0|	return 1;
   84|  3.30k|}

sc_check_sw:
   45|   545k|{
   46|   545k|	if (card == NULL)
  ------------------
  |  Branch (46:6): [True: 0, False: 545k]
  ------------------
   47|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   48|   545k|	if (card->ops->check_sw == NULL)
  ------------------
  |  Branch (48:6): [True: 0, False: 545k]
  ------------------
   49|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
   50|   545k|	return card->ops->check_sw(card, sw1, sw2);
   51|   545k|}
sc_format_apdu:
   55|   775k|{
   56|   775k|	if (card == NULL || apdu == NULL) {
  ------------------
  |  Branch (56:6): [True: 0, False: 775k]
  |  Branch (56:22): [True: 0, False: 775k]
  ------------------
   57|      0|		return;
   58|      0|	}
   59|   775k|	memset(apdu, 0, sizeof(*apdu));
   60|   775k|	apdu->cla = (u8) card->cla;
   61|   775k|	apdu->cse = cse;
   62|   775k|	apdu->ins = (u8) ins;
   63|   775k|	apdu->p1 = (u8) p1;
   64|   775k|	apdu->p2 = (u8) p2;
   65|   775k|}
sc_format_apdu_cse_lc_le:
   68|    162|{
   69|       |	/* TODO calculating the APDU case, Lc and Le should actually only be
   70|       |	 * done in sc_apdu2bytes, but to gradually change OpenSC we start here. */
   71|       |	/* Let sc_detect_apdu_cse set short or extended  and test for chaining */
   72|       |
   73|    162|	if (!apdu)
  ------------------
  |  Branch (73:6): [True: 0, False: 162]
  ------------------
   74|      0|		return;
   75|    162|	if (apdu->datalen > SC_MAX_APDU_DATA_SIZE
  ------------------
  |  |   35|    324|#define SC_MAX_APDU_DATA_SIZE		0xFF
  ------------------
  |  Branch (75:6): [True: 0, False: 162]
  ------------------
   76|    162|			|| apdu->resplen > SC_MAX_APDU_RESP_SIZE) {
  ------------------
  |  |   36|    162|#define SC_MAX_APDU_RESP_SIZE		(0xFF+1)
  ------------------
  |  Branch (76:7): [True: 0, False: 162]
  ------------------
   77|       |		/* extended length  or data chaining and/or get response */
   78|      0|		if (apdu->datalen <= SC_MAX_EXT_APDU_DATA_SIZE)
  ------------------
  |  |   38|      0|#define SC_MAX_EXT_APDU_DATA_SIZE		0xFFFF
  ------------------
  |  Branch (78:7): [True: 0, False: 0]
  ------------------
   79|      0|			apdu->lc = apdu->datalen;
   80|      0|		if (apdu->resplen <= SC_MAX_EXT_APDU_RESP_SIZE)
  ------------------
  |  |   39|      0|#define SC_MAX_EXT_APDU_RESP_SIZE		(0xFFFF+1)
  ------------------
  |  Branch (80:7): [True: 0, False: 0]
  ------------------
   81|      0|			apdu->le = apdu->resplen;
   82|      0|		if (apdu->resplen && !apdu->datalen)
  ------------------
  |  Branch (82:7): [True: 0, False: 0]
  |  Branch (82:24): [True: 0, False: 0]
  ------------------
   83|      0|			apdu->cse = SC_APDU_CASE_2;
  ------------------
  |  |  301|      0|#define SC_APDU_CASE_2			0x22
  ------------------
   84|      0|		if (!apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (84:7): [True: 0, False: 0]
  |  Branch (84:25): [True: 0, False: 0]
  ------------------
   85|      0|			apdu->cse = SC_APDU_CASE_3;
  ------------------
  |  |  302|      0|#define SC_APDU_CASE_3			0x23
  ------------------
   86|      0|		if (apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (86:7): [True: 0, False: 0]
  |  Branch (86:24): [True: 0, False: 0]
  ------------------
   87|      0|			apdu->cse = SC_APDU_CASE_4;
  ------------------
  |  |  303|      0|#define SC_APDU_CASE_4			0x24
  ------------------
   88|    162|	} else {
   89|       |		/* short length */
   90|    162|		if (apdu->datalen <= SC_MAX_APDU_DATA_SIZE)
  ------------------
  |  |   35|    162|#define SC_MAX_APDU_DATA_SIZE		0xFF
  ------------------
  |  Branch (90:7): [True: 162, False: 0]
  ------------------
   91|    162|			apdu->lc = apdu->datalen;
   92|    162|		if (apdu->resplen <= SC_MAX_APDU_RESP_SIZE)
  ------------------
  |  |   36|    162|#define SC_MAX_APDU_RESP_SIZE		(0xFF+1)
  ------------------
  |  Branch (92:7): [True: 162, False: 0]
  ------------------
   93|    162|			apdu->le = apdu->resplen;
   94|    162|		if (!apdu->resplen && !apdu->datalen)
  ------------------
  |  Branch (94:7): [True: 143, False: 19]
  |  Branch (94:25): [True: 0, False: 143]
  ------------------
   95|      0|			apdu->cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
   96|    162|		if (apdu->resplen && !apdu->datalen)
  ------------------
  |  Branch (96:7): [True: 19, False: 143]
  |  Branch (96:24): [True: 8, False: 11]
  ------------------
   97|      8|			apdu->cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|      8|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
   98|    162|		if (!apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (98:7): [True: 143, False: 19]
  |  Branch (98:25): [True: 143, False: 0]
  ------------------
   99|    143|			apdu->cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|    143|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  100|    162|		if (apdu->resplen && apdu->datalen)
  ------------------
  |  Branch (100:7): [True: 19, False: 143]
  |  Branch (100:24): [True: 11, False: 8]
  ------------------
  101|     11|			apdu->cse = SC_APDU_CASE_4_SHORT;
  ------------------
  |  |  294|     11|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  102|    162|	}
  103|    162|}
sc_format_apdu_ex:
  109|    162|{
  110|    162|	if (!apdu) {
  ------------------
  |  Branch (110:6): [True: 0, False: 162]
  ------------------
  111|      0|		return;
  112|      0|	}
  113|       |
  114|    162|	memset(apdu, 0, sizeof(*apdu));
  115|    162|	apdu->cla = cla;
  116|    162|	apdu->ins = ins;
  117|    162|	apdu->p1 = p1;
  118|    162|	apdu->p2 = p2;
  119|    162|	apdu->resp = resp;
  120|    162|	apdu->resplen = resplen;
  121|    162|	apdu->data = data;
  122|    162|	apdu->datalen = datalen;
  123|    162|	sc_format_apdu_cse_lc_le(apdu);
  124|    162|}
sc_get_max_recv_size:
  188|   399k|{
  189|   399k|	size_t max_recv_size;
  190|   399k|	if (card == NULL || card->reader == NULL) {
  ------------------
  |  Branch (190:6): [True: 0, False: 399k]
  |  Branch (190:22): [True: 0, False: 399k]
  ------------------
  191|      0|		return 0;
  192|      0|	}
  193|   399k|	max_recv_size = card->max_recv_size;
  194|       |
  195|       |	/* initialize max_recv_size to a meaningful value */
  196|   399k|	if (card->caps & SC_CARD_CAP_APDU_EXT) {
  ------------------
  |  |  554|   399k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (196:6): [True: 100k, False: 299k]
  ------------------
  197|   100k|		if (!max_recv_size)
  ------------------
  |  Branch (197:7): [True: 1.27k, False: 98.9k]
  ------------------
  198|  1.27k|			max_recv_size = 65536;
  199|   299k|	} else {
  200|   299k|		if (!max_recv_size)
  ------------------
  |  Branch (200:7): [True: 23.5k, False: 275k]
  ------------------
  201|  23.5k|			max_recv_size = 256;
  202|   299k|	}
  203|       |
  204|       |	/*  Override card limitations with reader limitations. */
  205|   399k|	if (card->reader->max_recv_size != 0
  ------------------
  |  Branch (205:6): [True: 44.6k, False: 354k]
  ------------------
  206|  44.6k|			&& (card->reader->max_recv_size < card->max_recv_size))
  ------------------
  |  Branch (206:7): [True: 0, False: 44.6k]
  ------------------
  207|      0|		max_recv_size = card->reader->max_recv_size;
  208|       |
  209|   399k|	return max_recv_size;
  210|   399k|}
sc_get_max_send_size:
  213|  53.6k|{
  214|  53.6k|	size_t max_send_size;
  215|       |
  216|  53.6k|	if (card == NULL || card->reader == NULL) {
  ------------------
  |  Branch (216:6): [True: 0, False: 53.6k]
  |  Branch (216:22): [True: 0, False: 53.6k]
  ------------------
  217|      0|		return 0;
  218|      0|	}
  219|       |
  220|  53.6k|	max_send_size = card->max_send_size;
  221|       |
  222|       |	/* initialize max_send_size to a meaningful value */
  223|  53.6k|	if (card->caps & SC_CARD_CAP_APDU_EXT
  ------------------
  |  |  554|   107k|#define SC_CARD_CAP_APDU_EXT		0x00000001
  ------------------
  |  Branch (223:6): [True: 5.05k, False: 48.5k]
  ------------------
  224|  5.05k|			&& card->reader->active_protocol != SC_PROTO_T0) {
  ------------------
  |  |  359|  5.05k|#define SC_PROTO_T0		0x00000001
  ------------------
  |  Branch (224:7): [True: 5.05k, False: 0]
  ------------------
  225|  5.05k|		if (!max_send_size)
  ------------------
  |  Branch (225:7): [True: 286, False: 4.76k]
  ------------------
  226|    286|			max_send_size = 65535;
  227|  48.5k|	} else {
  228|  48.5k|		if (!max_send_size)
  ------------------
  |  Branch (228:7): [True: 4.13k, False: 44.4k]
  ------------------
  229|  4.13k|			max_send_size = 255;
  230|  48.5k|	}
  231|       |
  232|       |	/*  Override card limitations with reader limitations. */
  233|  53.6k|	if (card->reader->max_send_size != 0
  ------------------
  |  Branch (233:6): [True: 0, False: 53.6k]
  ------------------
  234|      0|			&& (card->reader->max_send_size < card->max_send_size))
  ------------------
  |  Branch (234:7): [True: 0, False: 0]
  ------------------
  235|      0|		max_send_size = card->reader->max_send_size;
  236|       |
  237|  53.6k|	return max_send_size;
  238|  53.6k|}
sc_connect_card:
  241|  3.69k|{
  242|  3.69k|	sc_card_t *card;
  243|  3.69k|	sc_context_t *ctx;
  244|  3.69k|	struct sc_card_driver *driver;
  245|  3.69k|	int i, r = 0, idx, connected = 0;
  246|       |
  247|  3.69k|	if (card_out == NULL || reader == NULL)
  ------------------
  |  Branch (247:6): [True: 0, False: 3.69k]
  |  Branch (247:26): [True: 0, False: 3.69k]
  ------------------
  248|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  249|  3.69k|	ctx = reader->ctx;
  250|  3.69k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.69k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.69k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.69k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.69k]
  |  |  ------------------
  ------------------
  251|  3.69k|	if (reader->ops->connect == NULL)
  ------------------
  |  Branch (251:6): [True: 0, False: 3.69k]
  ------------------
  252|  3.69k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  253|       |
  254|  3.69k|	card = sc_card_new(ctx);
  255|  3.69k|	if (card == NULL)
  ------------------
  |  Branch (255:6): [True: 0, False: 3.69k]
  ------------------
  256|  3.69k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|  3.69k|	r = reader->ops->connect(reader);
  258|  3.69k|	if (r)
  ------------------
  |  Branch (258:6): [True: 0, False: 3.69k]
  ------------------
  259|      0|		goto err;
  260|       |
  261|  3.69k|	connected = 1;
  262|  3.69k|	card->reader = reader;
  263|  3.69k|	card->ctx = ctx;
  264|       |
  265|  3.69k|	if (reader->flags & SC_READER_ENABLE_ESCAPE)
  ------------------
  |  |  379|  3.69k|#define SC_READER_ENABLE_ESCAPE		0x00000040
  ------------------
  |  Branch (265:6): [True: 0, False: 3.69k]
  ------------------
  266|      0|		sc_detect_escape_cmds(reader);
  267|       |
  268|  3.69k|	memcpy(&card->atr, &reader->atr, sizeof(card->atr));
  269|  3.69k|	memcpy(&card->uid, &reader->uid, sizeof(card->uid));
  270|       |
  271|  3.69k|	_sc_parse_atr(reader);
  272|       |
  273|       |	/* See if the ATR matches any ATR specified in the config file */
  274|  3.69k|	if ((driver = ctx->forced_driver) == NULL) {
  ------------------
  |  Branch (274:6): [True: 3.69k, False: 0]
  ------------------
  275|  3.69k|		sc_log(ctx, "matching configured ATRs");
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  276|   166k|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (276:15): [True: 162k, False: 3.69k]
  ------------------
  277|   162k|			driver = ctx->card_drivers[i];
  278|       |
  279|   162k|			if (driver->atr_map == NULL ||
  ------------------
  |  Branch (279:8): [True: 162k, False: 0]
  ------------------
  280|   162k|			    !strcmp(driver->short_name, "default")) {
  ------------------
  |  Branch (280:8): [True: 0, False: 0]
  ------------------
  281|   162k|				driver = NULL;
  282|   162k|				continue;
  283|   162k|			}
  284|      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__
  |  |  ------------------
  ------------------
  285|      0|			idx = _sc_match_atr(card, driver->atr_map, NULL);
  286|      0|			if (idx >= 0) {
  ------------------
  |  Branch (286:8): [True: 0, False: 0]
  ------------------
  287|      0|				struct sc_atr_table *src = &driver->atr_map[idx];
  288|       |
  289|      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__
  |  |  ------------------
  ------------------
  290|       |				/* It's up to card driver to notice these correctly */
  291|      0|				card->name = src->name;
  292|      0|				card->type = src->type;
  293|      0|				card->flags = src->flags;
  294|      0|				break;
  295|      0|			}
  296|      0|			driver = NULL;
  297|      0|		}
  298|  3.69k|	}
  299|       |
  300|  3.69k|	if (driver != NULL) {
  ------------------
  |  Branch (300:6): [True: 0, False: 3.69k]
  ------------------
  301|       |		/* Forced driver, or matched via ATR mapping from config file */
  302|      0|		card->driver = driver;
  303|       |
  304|      0|		memcpy(card->ops, card->driver->ops, sizeof(struct sc_card_operations));
  305|      0|		if (card->ops->match_card != NULL)
  ------------------
  |  Branch (305:7): [True: 0, False: 0]
  ------------------
  306|      0|			if (card->ops->match_card(card) != 1)
  ------------------
  |  Branch (306:8): [True: 0, False: 0]
  ------------------
  307|      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__
  |  |  ------------------
  ------------------
  308|       |
  309|      0|		if (card->ops->init != NULL) {
  ------------------
  |  Branch (309:7): [True: 0, False: 0]
  ------------------
  310|      0|			r = card->ops->init(card);
  311|      0|			if (r) {
  ------------------
  |  Branch (311:8): [True: 0, False: 0]
  ------------------
  312|      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__
  |  |  ------------------
  ------------------
  313|      0|				goto err;
  314|      0|			}
  315|      0|		}
  316|      0|	}
  317|  3.69k|	else {
  318|  3.69k|		sc_card_t uninitialized = *card;
  319|  3.69k|		sc_log(ctx, "matching built-in ATRs");
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  320|  82.7k|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (320:15): [True: 82.6k, False: 142]
  ------------------
  321|       |			/* FIXME If we had a clean API description, we'd probably get a
  322|       |			 * cleaner implementation of the driver's match_card and init,
  323|       |			 * which should normally *not* modify the card object if
  324|       |			 * unsuccessful. However, after years of relentless hacking, reality
  325|       |			 * is different: The card object is changed in virtually every card
  326|       |			 * driver so in order to prevent unwanted interaction, we reset the
  327|       |			 * card object here and hope that the card driver at least doesn't
  328|       |			 * allocate any internal resources that need to be freed. If we
  329|       |			 * had more time, we should refactor the existing code to not
  330|       |			 * modify sc_card_t until complete success (possibly by combining
  331|       |			 * `match_card()` and `init()`) */
  332|  82.6k|			*card = uninitialized;
  333|       |
  334|  82.6k|			struct sc_card_driver *drv = ctx->card_drivers[i];
  335|  82.6k|			const struct sc_card_operations *ops = drv->ops;
  336|       |
  337|  82.6k|			sc_log(ctx, "trying driver '%s'", drv->short_name);
  ------------------
  |  |   71|  82.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__
  |  |  ------------------
  ------------------
  338|  82.6k|			if (ops == NULL || ops->match_card == NULL)   {
  ------------------
  |  Branch (338:8): [True: 0, False: 82.6k]
  |  Branch (338:23): [True: 0, False: 82.6k]
  ------------------
  339|      0|				continue;
  340|      0|			}
  341|  82.6k|			else if (!(ctx->flags & SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER)
  ------------------
  |  |  867|  82.6k|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  |  Branch (341:13): [True: 82.6k, False: 0]
  ------------------
  342|  82.6k|				   	&& !strcmp("default", drv->short_name))   {
  ------------------
  |  Branch (342:12): [True: 142, False: 82.5k]
  ------------------
  343|    142|				sc_log(ctx , "ignore 'default' card driver");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  344|    142|				continue;
  345|    142|			}
  346|       |
  347|       |			/* Needed if match_card() needs to talk with the card (e.g. card-muscle) */
  348|  82.5k|			*card->ops = *ops;
  349|  82.5k|			if (ops->match_card(card) != 1)
  ------------------
  |  Branch (349:8): [True: 78.7k, False: 3.72k]
  ------------------
  350|  78.7k|				continue;
  351|  3.72k|			sc_log(ctx, "matched: %s", drv->name);
  ------------------
  |  |   71|  3.72k|#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|  3.72k|			memcpy(card->ops, ops, sizeof(struct sc_card_operations));
  353|  3.72k|			card->driver = drv;
  354|  3.72k|			r = ops->init(card);
  355|  3.72k|			if (r) {
  ------------------
  |  Branch (355:8): [True: 268, False: 3.45k]
  ------------------
  356|    268|				sc_log(ctx, "driver '%s' init() failed: %s", drv->name, sc_strerror(r));
  ------------------
  |  |   71|    268|#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|    268|				if (r == SC_ERROR_INVALID_CARD) {
  ------------------
  |  |   60|    268|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  |  Branch (357:9): [True: 170, False: 98]
  ------------------
  358|    170|					card->driver = NULL;
  359|    170|					continue;
  360|    170|				}
  361|     98|				goto err;
  362|    268|			}
  363|  3.45k|			break;
  364|  3.72k|		}
  365|  3.69k|	}
  366|  3.59k|	if (card->driver == NULL) {
  ------------------
  |  Branch (366:6): [True: 142, False: 3.45k]
  ------------------
  367|    142|		sc_log(ctx, "unable to find driver for inserted card");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  368|    142|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|    142|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  369|    142|		goto err;
  370|    142|	}
  371|  3.45k|	if (card->name == NULL)
  ------------------
  |  Branch (371:6): [True: 622, False: 2.83k]
  ------------------
  372|    622|		card->name = card->driver->name;
  373|       |
  374|       |	/* initialize max_send_size/max_recv_size to a meaningful value */
  375|  3.45k|	card->max_recv_size = sc_get_max_recv_size(card);
  376|  3.45k|	card->max_send_size = sc_get_max_send_size(card);
  377|       |
  378|  3.45k|	sc_log(ctx,
  ------------------
  |  |   71|  3.45k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  379|  3.45k|	       "card info name:'%s', type:%i, flags:0x%lX, max_send/recv_size:%"SC_FORMAT_LEN_SIZE_T"u/%"SC_FORMAT_LEN_SIZE_T"u",
  380|  3.45k|	       card->name, card->type, card->flags, card->max_send_size,
  381|  3.45k|	       card->max_recv_size);
  382|       |
  383|  3.45k|#ifdef ENABLE_SM
  384|       |        /* Check, if secure messaging module present. */
  385|  3.45k|	r = sc_card_sm_check(card);
  386|  3.45k|	if (r)   {
  ------------------
  |  Branch (386:6): [True: 0, False: 3.45k]
  ------------------
  387|      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__
  |  |  ------------------
  ------------------
  388|      0|		goto err;
  389|      0|	}
  390|  3.45k|#endif
  391|  3.45k|	*card_out = card;
  392|       |
  393|  3.45k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.45k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.45k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.45k|	int _ret = r; \
  |  |  |  |  155|  3.45k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.45k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.45k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.45k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.45k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.45k|	} else { \
  |  |  |  |  159|      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.45k|	return _ret; \
  |  |  |  |  163|  3.45k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  394|    240|err:
  395|    240|	if (connected)
  ------------------
  |  Branch (395:6): [True: 240, False: 0]
  ------------------
  396|    240|		reader->ops->disconnect(reader);
  397|    240|	if (card != NULL)
  ------------------
  |  Branch (397:6): [True: 240, False: 0]
  ------------------
  398|    240|		sc_card_free(card);
  399|    240|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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: 240, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    240|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    240|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 240, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    240|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    240|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    240|	return _ret; \
  |  |  |  |  163|    240|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  400|    240|}
sc_disconnect_card:
  403|  3.45k|{
  404|  3.45k|	sc_context_t *ctx;
  405|       |
  406|  3.45k|	if (!card)
  ------------------
  |  Branch (406:6): [True: 0, False: 3.45k]
  ------------------
  407|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  408|       |
  409|  3.45k|	ctx = card->ctx;
  410|  3.45k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.45k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.45k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.45k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.45k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.45k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|       |
  412|  3.45k|	if (card->ops->finish) {
  ------------------
  |  Branch (412:6): [True: 3.25k, False: 200]
  ------------------
  413|  3.25k|		int r = card->ops->finish(card);
  414|  3.25k|		if (r)
  ------------------
  |  Branch (414:7): [True: 0, False: 3.25k]
  ------------------
  415|      0|			sc_log(ctx, "card driver finish() 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__
  |  |  ------------------
  ------------------
  416|  3.25k|	}
  417|       |
  418|  3.45k|	if (card->reader->ops->disconnect) {
  ------------------
  |  Branch (418:6): [True: 3.45k, False: 0]
  ------------------
  419|  3.45k|		int r = card->reader->ops->disconnect(card->reader);
  420|  3.45k|		if (r)
  ------------------
  |  Branch (420:7): [True: 0, False: 3.45k]
  ------------------
  421|      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__
  |  |  ------------------
  ------------------
  422|  3.45k|	}
  423|       |
  424|  3.45k|#ifdef ENABLE_SM
  425|       |	/* release SM related resources */
  426|  3.45k|	sc_card_sm_unload(card);
  427|  3.45k|#endif
  428|       |
  429|  3.45k|	sc_card_free(card);
  430|  3.45k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.45k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.45k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.45k|	int _ret = r; \
  |  |  |  |  155|  3.45k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.45k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.45k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.45k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.45k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.45k|	} else { \
  |  |  |  |  159|      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.45k|	return _ret; \
  |  |  |  |  163|  3.45k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  431|  3.45k|}
sc_lock:
  458|  1.10M|{
  459|  1.10M|	int r = 0, r2 = 0;
  460|  1.10M|	int was_reset = 0;
  461|  1.10M|	int reader_lock_obtained  = 0;
  462|       |
  463|  1.10M|	if (card == NULL)
  ------------------
  |  Branch (463:6): [True: 0, False: 1.10M]
  ------------------
  464|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  465|       |
  466|  1.10M|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.10M|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.10M|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.10M|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.10M|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.10M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|       |
  468|  1.10M|	r = sc_mutex_lock(card->ctx, card->mutex);
  469|  1.10M|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|  1.10M|#define SC_SUCCESS				0
  ------------------
  |  Branch (469:6): [True: 0, False: 1.10M]
  ------------------
  470|      0|		return r;
  471|  1.10M|	if (card->lock_count == 0) {
  ------------------
  |  Branch (471:6): [True: 712k, False: 397k]
  ------------------
  472|   712k|		if (card->reader->ops->lock != NULL) {
  ------------------
  |  Branch (472:7): [True: 712k, False: 0]
  ------------------
  473|   712k|			r = card->reader->ops->lock(card->reader);
  474|   712k|			while (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   37|  1.42M|#define SC_ERROR_CARD_RESET			-1106
  ------------------
              			while (r == SC_ERROR_CARD_RESET || r == SC_ERROR_READER_REATTACHED) {
  ------------------
  |  |   46|   712k|#define SC_ERROR_READER_REATTACHED		-1115
  ------------------
  |  Branch (474:11): [True: 0, False: 712k]
  |  Branch (474:39): [True: 0, False: 712k]
  ------------------
  475|      0|				if (was_reset++ > 4) /* TODO retry a few times */
  ------------------
  |  Branch (475:9): [True: 0, False: 0]
  ------------------
  476|      0|					break;
  477|      0|				r = card->reader->ops->lock(card->reader);
  478|      0|			}
  479|   712k|			if (r == 0)
  ------------------
  |  Branch (479:8): [True: 712k, False: 0]
  ------------------
  480|   712k|				reader_lock_obtained = 1;
  481|   712k|		}
  482|   712k|	}
  483|  1.10M|	if (r == 0)
  ------------------
  |  Branch (483:6): [True: 1.10M, False: 0]
  ------------------
  484|  1.10M|		card->lock_count++;
  485|       |
  486|  1.10M|	r2 = sc_mutex_unlock(card->ctx, card->mutex);
  487|  1.10M|	if (r2 != SC_SUCCESS) {
  ------------------
  |  |   28|  1.10M|#define SC_SUCCESS				0
  ------------------
  |  Branch (487:6): [True: 0, False: 1.10M]
  ------------------
  488|      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__
  |  |  ------------------
  ------------------
  489|      0|		r = r != SC_SUCCESS ? r : r2;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (489:7): [True: 0, False: 0]
  ------------------
  490|      0|	}
  491|       |
  492|  1.10M|	if (r == 0 && was_reset > 0) {
  ------------------
  |  Branch (492:6): [True: 1.10M, False: 0]
  |  Branch (492:16): [True: 0, False: 1.10M]
  ------------------
  493|      0|#ifdef ENABLE_SM
  494|      0|		if (card->sm_ctx.ops.open)
  ------------------
  |  Branch (494:7): [True: 0, False: 0]
  ------------------
  495|      0|			card->sm_ctx.ops.open(card);
  496|      0|#endif
  497|      0|	}
  498|       |
  499|       |	/* give card driver a chance to do something when reader lock first obtained */
  500|  1.10M|	if (r == 0 && reader_lock_obtained == 1  && card->ops->card_reader_lock_obtained) {
  ------------------
  |  Branch (500:6): [True: 1.10M, False: 0]
  |  Branch (500:16): [True: 712k, False: 397k]
  |  Branch (500:46): [True: 297k, False: 415k]
  ------------------
  501|   297k|		if (SC_SUCCESS != card->ops->card_reader_lock_obtained(card, was_reset))
  ------------------
  |  |   28|   297k|#define SC_SUCCESS				0
  ------------------
  |  Branch (501:7): [True: 0, False: 297k]
  ------------------
  502|      0|			sc_log(card->ctx, "card_reader_lock_obtained 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__
  |  |  ------------------
  ------------------
  503|   297k|	}
  504|       |
  505|  1.10M|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.10M|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.10M|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.10M|	int _ret = r; \
  |  |  |  |  155|  1.10M|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.10M, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.10M|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.10M]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.10M|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.10M|	} else { \
  |  |  |  |  159|      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.10M|	return _ret; \
  |  |  |  |  163|  1.10M|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|  1.10M|}
sc_unlock:
  509|  1.10M|{
  510|  1.10M|	int r, r2;
  511|       |
  512|  1.10M|	if (!card)
  ------------------
  |  Branch (512:6): [True: 0, False: 1.10M]
  ------------------
  513|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  514|       |
  515|  1.10M|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.10M|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.10M|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.10M|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.10M|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.10M]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  516|       |
  517|  1.10M|	r = sc_mutex_lock(card->ctx, card->mutex);
  518|  1.10M|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|  1.10M|#define SC_SUCCESS				0
  ------------------
  |  Branch (518:6): [True: 0, False: 1.10M]
  ------------------
  519|  1.10M|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  520|       |
  521|  1.10M|	if (card->lock_count < 1) {
  ------------------
  |  Branch (521:6): [True: 0, False: 1.10M]
  ------------------
  522|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  523|      0|	}
  524|  1.10M|	if (--card->lock_count == 0) {
  ------------------
  |  Branch (524:6): [True: 712k, False: 397k]
  ------------------
  525|       |		/* release reader lock */
  526|   712k|		if (card->reader->ops->unlock != NULL)
  ------------------
  |  Branch (526:7): [True: 712k, False: 0]
  ------------------
  527|   712k|			r = card->reader->ops->unlock(card->reader);
  528|   712k|	}
  529|  1.10M|	r2 = sc_mutex_unlock(card->ctx, card->mutex);
  530|  1.10M|	if (r2 != SC_SUCCESS) {
  ------------------
  |  |   28|  1.10M|#define SC_SUCCESS				0
  ------------------
  |  Branch (530:6): [True: 0, False: 1.10M]
  ------------------
  531|      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__
  |  |  ------------------
  ------------------
  532|      0|		r = (r == SC_SUCCESS) ? r2 : r;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (532:7): [True: 0, False: 0]
  ------------------
  533|      0|	}
  534|       |
  535|  1.10M|	return r;
  536|  1.10M|}
sc_list_files:
  539|    426|{
  540|    426|	int r;
  541|       |
  542|    426|	if (card == NULL) {
  ------------------
  |  Branch (542:6): [True: 0, False: 426]
  ------------------
  543|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  544|      0|	}
  545|    426|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    426|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    426|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    426|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    426|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 426]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  546|       |
  547|    426|	if (card->ops->list_files == NULL)
  ------------------
  |  Branch (547:6): [True: 0, False: 426]
  ------------------
  548|    426|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  549|    426|	r = card->ops->list_files(card, buf, buflen);
  550|       |
  551|    426|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    426|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    426|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    426|	int _ret = r; \
  |  |  |  |  155|    426|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 351, False: 75]
  |  |  |  |  ------------------
  |  |  |  |  156|    351|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 340]
  |  |  |  |  ------------------
  |  |  |  |  157|    351|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    351|	} else { \
  |  |  |  |  159|     75|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     75|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     75|	} \
  |  |  |  |  162|    426|	return _ret; \
  |  |  |  |  163|    426|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  552|    426|}
sc_create_file:
  555|  1.91k|{
  556|  1.91k|	int r;
  557|  1.91k|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  558|  1.91k|	const sc_path_t *in_path;
  559|       |
  560|  1.91k|	if (card == NULL || file == NULL) {
  ------------------
  |  Branch (560:6): [True: 0, False: 1.91k]
  |  Branch (560:22): [True: 0, False: 1.91k]
  ------------------
  561|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  562|      0|	}
  563|       |
  564|  1.91k|	in_path = &file->path;
  565|  1.91k|	r = sc_path_print(pbuf, sizeof(pbuf), in_path);
  566|  1.91k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|  1.91k|#define SC_SUCCESS				0
  ------------------
  |  Branch (566:6): [True: 0, False: 1.91k]
  ------------------
  567|      0|		pbuf[0] = '\0';
  568|       |
  569|  1.91k|	sc_log(card->ctx,
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
  570|  1.91k|	       "called; type=%d, path=%s, id=%04i, size=%"SC_FORMAT_LEN_SIZE_T"u",
  571|  1.91k|	       in_path->type, pbuf, file->id, file->size);
  572|       |	/* ISO 7816-4: "Number of data bytes in the file, including structural information if any"
  573|       |	 * can not be bigger than two bytes */
  574|  1.91k|	if (file->size > 0xFFFF)
  ------------------
  |  Branch (574:6): [True: 1, False: 1.91k]
  ------------------
  575|  1.91k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  576|       |
  577|  1.91k|	if (card->ops->create_file == NULL)
  ------------------
  |  Branch (577:6): [True: 0, False: 1.91k]
  ------------------
  578|  1.91k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  579|       |
  580|  1.91k|	r = card->ops->create_file(card, file);
  581|  1.91k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  1.91k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.91k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.91k|	int _ret = r; \
  |  |  |  |  155|  1.91k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.91k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.91k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    196|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 196, False: 1.71k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.91k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.91k|	} else { \
  |  |  |  |  159|      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.91k|	return _ret; \
  |  |  |  |  163|  1.91k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  582|  1.91k|}
sc_delete_file:
  585|    358|{
  586|    358|	int r;
  587|    358|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  588|       |
  589|    358|	if (card == NULL) {
  ------------------
  |  Branch (589:6): [True: 0, False: 358]
  ------------------
  590|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  591|      0|	}
  592|       |
  593|    358|	r = sc_path_print(pbuf, sizeof(pbuf), path);
  594|    358|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    358|#define SC_SUCCESS				0
  ------------------
  |  Branch (594:6): [True: 0, False: 358]
  ------------------
  595|      0|		pbuf[0] = '\0';
  596|       |
  597|    358|	sc_log(card->ctx, "called; type=%d, path=%s", path->type, pbuf);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  598|    358|	if (card->ops->delete_file == NULL)
  ------------------
  |  Branch (598:6): [True: 1, False: 357]
  ------------------
  599|    358|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  600|    357|	r = card->ops->delete_file(card, path);
  601|       |
  602|    357|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    357|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    357|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    357|	int _ret = r; \
  |  |  |  |  155|    357|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 357, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    357|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    170|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 170, False: 187]
  |  |  |  |  ------------------
  |  |  |  |  157|    357|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    357|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    357|	return _ret; \
  |  |  |  |  163|    357|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|    357|}
sc_read_binary:
  607|  36.3k|{
  608|  36.3k|	size_t max_le = sc_get_max_recv_size(card);
  609|  36.3k|	size_t todo = count;
  610|  36.3k|	int r;
  611|       |
  612|  36.3k|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (612:6): [True: 0, False: 36.3k]
  |  Branch (612:22): [True: 0, False: 36.3k]
  |  Branch (612:43): [True: 0, False: 36.3k]
  ------------------
  613|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  614|      0|	}
  615|  36.3k|	sc_log(card->ctx, "called; %"SC_FORMAT_LEN_SIZE_T"u bytes at index %d",
  ------------------
  |  |   71|  36.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__
  |  |  ------------------
  ------------------
  616|  36.3k|	       count, idx);
  617|  36.3k|	if (count == 0)
  ------------------
  |  Branch (617:6): [True: 260, False: 36.1k]
  ------------------
  618|  36.3k|		LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    260|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    260|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    260|	int _ret = r; \
  |  |  |  |  155|    260|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 260, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    260|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 260]
  |  |  |  |  ------------------
  |  |  |  |  157|    260|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    260|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    260|	return _ret; \
  |  |  |  |  163|    260|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  619|       |
  620|  36.1k|#ifdef ENABLE_SM
  621|  36.1k|	if (card->sm_ctx.ops.read_binary)   {
  ------------------
  |  Branch (621:6): [True: 21, False: 36.0k]
  ------------------
  622|     21|		r = card->sm_ctx.ops.read_binary(card, idx, buf, count);
  623|     21|		if (r)
  ------------------
  |  Branch (623:7): [True: 16, False: 5]
  ------------------
  624|     21|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|     21|	}
  626|  36.0k|#endif
  627|       |
  628|  36.0k|	if (card->ops->read_binary == NULL)
  ------------------
  |  Branch (628:6): [True: 0, False: 36.0k]
  ------------------
  629|  36.0k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|       |
  631|       |	/* lock the card now to avoid deselection of the file */
  632|  36.0k|	r = sc_lock(card);
  633|  36.0k|	LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|  36.0k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  36.0k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  36.0k|	int _ret = (r); \
  |  |  |  |  168|  36.0k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 36.0k]
  |  |  |  |  ------------------
  |  |  |  |  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|  36.0k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 36.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  634|       |
  635|  60.9k|	while (todo > 0) {
  ------------------
  |  Branch (635:9): [True: 58.8k, False: 2.13k]
  ------------------
  636|  58.8k|		size_t chunk = MIN(todo, max_le);
  ------------------
  |  |   70|  58.8k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 18.5k, False: 40.2k]
  |  |  ------------------
  ------------------
  637|       |
  638|  58.8k|		r = card->ops->read_binary(card, idx, buf, chunk, flags);
  639|  58.8k|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|  56.4k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (639:7): [True: 2.38k, False: 56.4k]
  |  Branch (639:17): [True: 30, False: 56.4k]
  ------------------
  640|  2.41k|			break;
  641|  56.4k|		if (r < 0 && todo != count) {
  ------------------
  |  Branch (641:7): [True: 31.5k, False: 24.8k]
  |  Branch (641:16): [True: 1.93k, False: 29.6k]
  ------------------
  642|       |			/* the last command failed, but previous ones succeeded.
  643|       |			 * Let's just return what we've successfully read. */
  644|  1.93k|			sc_log(card->ctx, "Subsequent read failed with %d, returning what was read successfully.", r);
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
  645|  1.93k|			break;
  646|  1.93k|		}
  647|  54.4k|		if (r < 0) {
  ------------------
  |  Branch (647:7): [True: 29.6k, False: 24.8k]
  ------------------
  648|  29.6k|			sc_unlock(card);
  649|  29.6k|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  29.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  29.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  29.6k|	int _ret = r; \
  |  |  |  |  155|  29.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 29.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|  29.6k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 29.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  29.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  29.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|  29.6k|	return _ret; \
  |  |  |  |  163|  29.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  650|  29.6k|		}
  651|  24.8k|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (651:7): [True: 0, False: 24.8k]
  |  Branch (651:40): [True: 0, False: 24.8k]
  ------------------
  652|       |			/* `idx + r` or `todo - r` would overflow */
  653|      0|			sc_unlock(card);
  654|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  655|      0|		}
  656|       |
  657|  24.8k|		todo -= (size_t) r;
  658|  24.8k|		buf  += (size_t) r;
  659|  24.8k|		idx  += (size_t) r;
  660|  24.8k|	}
  661|       |
  662|  6.48k|	sc_unlock(card);
  663|       |
  664|  6.48k|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  164|  6.48k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.48k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.48k|	int _ret = r; \
  |  |  |  |  155|  6.48k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.79k, False: 4.68k]
  |  |  |  |  ------------------
  |  |  |  |  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|  4.68k|	} else { \
  |  |  |  |  159|  4.68k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  4.68k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  4.68k|	} \
  |  |  |  |  162|  6.48k|	return _ret; \
  |  |  |  |  163|  6.48k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  665|  6.48k|}
sc_update_binary:
  717|  1.48k|{
  718|  1.48k|	size_t max_lc = sc_get_max_send_size(card);
  719|  1.48k|	size_t todo = count;
  720|  1.48k|	int r;
  721|       |
  722|  1.48k|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (722:6): [True: 0, False: 1.48k]
  |  Branch (722:22): [True: 0, False: 1.48k]
  |  Branch (722:43): [True: 0, False: 1.48k]
  ------------------
  723|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  724|      0|	}
  725|  1.48k|	sc_log(card->ctx, "called; %"SC_FORMAT_LEN_SIZE_T"u bytes at index %d",
  ------------------
  |  |   71|  1.48k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  726|  1.48k|	       count, idx);
  727|  1.48k|	if (count == 0)
  ------------------
  |  Branch (727:6): [True: 0, False: 1.48k]
  ------------------
  728|  1.48k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|       |
  730|  1.48k|#ifdef ENABLE_SM
  731|  1.48k|	if (card->sm_ctx.ops.update_binary)   {
  ------------------
  |  Branch (731:6): [True: 0, False: 1.48k]
  ------------------
  732|      0|		r = card->sm_ctx.ops.update_binary(card, idx, buf, count);
  733|      0|		if (r)
  ------------------
  |  Branch (733:7): [True: 0, False: 0]
  ------------------
  734|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  735|      0|	}
  736|  1.48k|#endif
  737|       |
  738|  1.48k|	if (card->ops->update_binary == NULL)
  ------------------
  |  Branch (738:6): [True: 4, False: 1.48k]
  ------------------
  739|  1.48k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|       |
  741|       |	/* lock the card now to avoid deselection of the file */
  742|  1.48k|	r = sc_lock(card);
  743|  1.48k|	LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|  1.48k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.48k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.48k|	int _ret = (r); \
  |  |  |  |  168|  1.48k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.48k]
  |  |  |  |  ------------------
  |  |  |  |  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.48k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  744|       |
  745|  6.16k|	while (todo > 0) {
  ------------------
  |  Branch (745:9): [True: 4.84k, False: 1.32k]
  ------------------
  746|  4.84k|		size_t chunk = MIN(todo, max_lc);
  ------------------
  |  |   70|  4.84k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 621, False: 4.22k]
  |  |  ------------------
  ------------------
  747|       |
  748|  4.84k|		r = card->ops->update_binary(card, idx, buf, chunk, flags);
  749|  4.84k|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|  4.84k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (749:7): [True: 0, False: 4.84k]
  |  Branch (749:17): [True: 3, False: 4.84k]
  ------------------
  750|      3|			break;
  751|  4.84k|		if (r < 0) {
  ------------------
  |  Branch (751:7): [True: 157, False: 4.68k]
  ------------------
  752|    157|			sc_unlock(card);
  753|    157|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    157|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    157|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    157|	int _ret = r; \
  |  |  |  |  155|    157|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 157, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    157|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    157|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 157, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    157|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    157|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    157|	return _ret; \
  |  |  |  |  163|    157|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|    157|		}
  755|  4.68k|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (755:7): [True: 0, False: 4.68k]
  |  Branch (755:40): [True: 0, False: 4.68k]
  ------------------
  756|       |			/* `idx + r` or `todo - r` would overflow */
  757|      0|			sc_unlock(card);
  758|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  759|      0|		}
  760|       |
  761|  4.68k|		todo -= (size_t) r;
  762|  4.68k|		buf  += (size_t) r;
  763|  4.68k|		idx  += (size_t) r;
  764|  4.68k|	}
  765|       |
  766|  1.32k|	sc_unlock(card);
  767|       |
  768|  1.32k|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  164|  1.32k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.32k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.32k|	int _ret = r; \
  |  |  |  |  155|  1.32k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3, False: 1.32k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.32k|	} else { \
  |  |  |  |  159|  1.32k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.32k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.32k|	} \
  |  |  |  |  162|  1.32k|	return _ret; \
  |  |  |  |  163|  1.32k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|  1.32k|}
sc_erase_binary:
  773|     10|{
  774|     10|	int r;
  775|     10|	size_t todo = count;
  776|       |
  777|     10|	if (card == NULL || card->ops == NULL) {
  ------------------
  |  Branch (777:6): [True: 0, False: 10]
  |  Branch (777:22): [True: 0, False: 10]
  ------------------
  778|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  779|      0|	}
  780|     10|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  781|     10|	       "called; erase %"SC_FORMAT_LEN_SIZE_T"u bytes from offset %d",
  782|     10|	       count, idx);
  783|     10|	if (count == 0)
  ------------------
  |  Branch (783:6): [True: 5, False: 5]
  ------------------
  784|     10|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  785|       |
  786|      5|	if (card->ops->erase_binary == NULL)
  ------------------
  |  Branch (786:6): [True: 0, False: 5]
  ------------------
  787|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  788|       |
  789|       |	/* lock the card now to avoid deselection of the file */
  790|      5|	r = sc_lock(card);
  791|      5|	LOG_TEST_RET(card->ctx, r, "sc_lock() 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: 0, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  792|       |
  793|      7|	while (todo > 0) {
  ------------------
  |  Branch (793:9): [True: 5, False: 2]
  ------------------
  794|      5|		r = card->ops->erase_binary(card, idx, todo, flags);
  795|      5|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|      5|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (795:7): [True: 0, False: 5]
  |  Branch (795:17): [True: 0, False: 5]
  ------------------
  796|      0|			break;
  797|      5|		if (r < 0) {
  ------------------
  |  Branch (797:7): [True: 3, False: 2]
  ------------------
  798|      3|			sc_unlock(card);
  799|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  800|      3|		}
  801|      2|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (801:7): [True: 0, False: 2]
  |  Branch (801:40): [True: 0, False: 2]
  ------------------
  802|       |			/* `idx + r` or `todo - r` would overflow */
  803|      0|			sc_unlock(card);
  804|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  805|      0|		}
  806|       |
  807|      2|		todo -= (size_t) r;
  808|      2|		idx  += (size_t) r;
  809|      2|	}
  810|       |
  811|      2|	sc_unlock(card);
  812|       |
  813|      2|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  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: 0, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"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|      2|	return _ret; \
  |  |  |  |  163|      2|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  814|      2|}
sc_select_file:
  818|   401k|{
  819|   401k|	int r;
  820|   401k|	char pbuf[SC_MAX_PATH_STRING_SIZE];
  821|       |
  822|   401k|	if (card == NULL || in_path == NULL) {
  ------------------
  |  Branch (822:6): [True: 0, False: 401k]
  |  Branch (822:22): [True: 0, False: 401k]
  ------------------
  823|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  824|      0|	}
  825|       |
  826|   401k|	r = sc_path_print(pbuf, sizeof(pbuf), in_path);
  827|   401k|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|   401k|#define SC_SUCCESS				0
  ------------------
  |  Branch (827:6): [True: 239, False: 401k]
  ------------------
  828|    239|		pbuf[0] = '\0';
  829|       |
  830|       |	/* FIXME We should be a bit less strict and let the upper layers do
  831|       |	 * the initialization (including reuse of existing file objects). We
  832|       |	 * implemented this here because we are lazy. */
  833|   401k|	if (file != NULL)
  ------------------
  |  Branch (833:6): [True: 383k, False: 17.8k]
  ------------------
  834|   383k|		*file = NULL;
  835|       |
  836|   401k|	sc_log(card->ctx, "called; type=%d, path=%s", in_path->type, pbuf);
  ------------------
  |  |   71|   401k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  837|   401k|	if (in_path->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|   401k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (837:6): [True: 0, False: 401k]
  ------------------
  838|   401k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  839|       |
  840|   401k|	if (in_path->type == SC_PATH_TYPE_PATH) {
  ------------------
  |  |  119|   401k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (840:6): [True: 377k, False: 23.4k]
  ------------------
  841|       |		/* Perform a sanity check */
  842|   377k|		size_t i;
  843|       |
  844|   377k|		if ((in_path->len & 1) != 0)
  ------------------
  |  Branch (844:7): [True: 41.6k, False: 336k]
  ------------------
  845|   377k|			LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|  41.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  41.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  41.6k|	int _ret = r; \
  |  |  |  |  155|  41.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 41.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  41.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|  41.6k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 41.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  41.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  41.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|  41.6k|	return _ret; \
  |  |  |  |  163|  41.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  846|       |
  847|  1.28M|		for (i = 0; i < in_path->len/2; i++) {
  ------------------
  |  Branch (847:15): [True: 952k, False: 333k]
  ------------------
  848|   952k|			u8 p1 = in_path->value[2*i],
  849|   952k|			   p2 = in_path->value[2*i+1];
  850|       |
  851|   952k|			if ((p1 == 0x3F && p2 == 0x00) && i != 0)
  ------------------
  |  Branch (851:9): [True: 309k, False: 642k]
  |  Branch (851:23): [True: 239k, False: 69.4k]
  |  Branch (851:38): [True: 2.96k, False: 236k]
  ------------------
  852|   952k|				LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|  2.96k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.96k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.96k|	int _ret = r; \
  |  |  |  |  155|  2.96k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.96k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.96k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.96k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.96k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.96k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.96k|	} else { \
  |  |  |  |  159|      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.96k|	return _ret; \
  |  |  |  |  163|  2.96k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  853|   952k|		}
  854|   336k|	}
  855|   356k|	if (card->ops->select_file == NULL)
  ------------------
  |  Branch (855:6): [True: 0, False: 356k]
  ------------------
  856|   356k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  857|   356k|	r = card->ops->select_file(card, in_path, file);
  858|   356k|	LOG_TEST_RET(card->ctx, r, "'SELECT' error");
  ------------------
  |  |  174|   356k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   356k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   356k|	int _ret = (r); \
  |  |  |  |  168|   356k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 303k, False: 53.3k]
  |  |  |  |  ------------------
  |  |  |  |  169|   303k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|   303k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|   303k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|   303k|		return _ret; \
  |  |  |  |  172|   303k|	} \
  |  |  |  |  173|   356k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 53.3k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  859|       |
  860|  53.3k|	if (file) {
  ------------------
  |  Branch (860:6): [True: 46.8k, False: 6.51k]
  ------------------
  861|  46.8k|		if (*file)
  ------------------
  |  Branch (861:7): [True: 44.7k, False: 2.07k]
  ------------------
  862|       |			/* Remember file path */
  863|  44.7k|			(*file)->path = *in_path;
  864|  2.07k|		else
  865|       |			/* FIXME We should be a bit less strict and let the upper layers do
  866|       |			 * the error checking. We implemented this here because we are
  867|       |			 * lazy.  */
  868|  2.07k|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|  2.07k|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  869|  46.8k|	}
  870|       |
  871|  53.3k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  53.3k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  53.3k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  53.3k|	int _ret = r; \
  |  |  |  |  155|  53.3k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 53.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  53.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|  2.07k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.07k, False: 51.2k]
  |  |  |  |  ------------------
  |  |  |  |  157|  53.3k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  53.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|  53.3k|	return _ret; \
  |  |  |  |  163|  53.3k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  872|  53.3k|}
sc_get_data:
  876|  3.98k|{
  877|  3.98k|	int	r;
  878|       |
  879|  3.98k|	sc_log(card->ctx, "called, tag=%04x", tag);
  ------------------
  |  |   71|  3.98k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  880|  3.98k|	if (card->ops->get_data == NULL)
  ------------------
  |  Branch (880:6): [True: 0, False: 3.98k]
  ------------------
  881|  3.98k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  882|  3.98k|	r = card->ops->get_data(card, tag, buf, len);
  883|       |
  884|  3.98k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  3.98k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.98k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.98k|	int _ret = r; \
  |  |  |  |  155|  3.98k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.79k, False: 1.19k]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|  2.17k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.17k, False: 611]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.79k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.79k|	} else { \
  |  |  |  |  159|  1.19k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.19k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.19k|	} \
  |  |  |  |  162|  3.98k|	return _ret; \
  |  |  |  |  163|  3.98k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  885|  3.98k|}
sc_get_challenge:
  901|      5|{
  902|      5|	int r;
  903|       |
  904|      5|	if (len == 0)
  ------------------
  |  Branch (904:6): [True: 0, False: 5]
  ------------------
  905|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  906|       |
  907|      5|	if (card == NULL || rnd == NULL) {
  ------------------
  |  Branch (907:6): [True: 0, False: 5]
  |  Branch (907:22): [True: 0, False: 5]
  ------------------
  908|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  909|      0|	}
  910|       |
  911|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  912|       |
  913|      5|	if (card->ops == NULL || card->ops->get_challenge == NULL)
  ------------------
  |  Branch (913:6): [True: 0, False: 5]
  |  Branch (913:27): [True: 0, False: 5]
  ------------------
  914|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  915|       |
  916|      5|	r = sc_lock(card);
  917|      5|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (917:6): [True: 0, False: 5]
  ------------------
  918|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  919|       |
  920|     15|	while (len > 0) {
  ------------------
  |  Branch (920:9): [True: 14, False: 1]
  ------------------
  921|     14|		r = card->ops->get_challenge(card, rnd, len);
  922|     14|		if (r == 0)
  ------------------
  |  Branch (922:7): [True: 1, False: 13]
  ------------------
  923|      1|			r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      1|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  924|     14|		if (r < 0) {
  ------------------
  |  Branch (924:7): [True: 4, False: 10]
  ------------------
  925|      4|			sc_unlock(card);
  926|      4|			LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  927|      4|		}
  928|       |
  929|     10|		rnd += (size_t) r;
  930|     10|		len -= (size_t) r;
  931|     10|	}
  932|       |
  933|      1|	sc_unlock(card);
  934|       |
  935|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  936|      1|}
sc_read_record:
  940|  2.86k|{
  941|  2.86k|	size_t max_le = sc_get_max_recv_size(card);
  942|  2.86k|	size_t todo = count;
  943|  2.86k|	int r;
  944|       |
  945|  2.86k|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (945:6): [True: 0, False: 2.86k]
  |  Branch (945:22): [True: 0, False: 2.86k]
  |  Branch (945:43): [True: 0, False: 2.86k]
  ------------------
  946|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  947|      0|	}
  948|  2.86k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.86k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.86k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.86k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.86k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.86k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  949|  2.86k|	if (count == 0)
  ------------------
  |  Branch (949:6): [True: 0, False: 2.86k]
  ------------------
  950|  2.86k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  951|       |
  952|  2.86k|	if (card->ops->read_record == NULL)
  ------------------
  |  Branch (952:6): [True: 360, False: 2.50k]
  ------------------
  953|  2.86k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    360|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    360|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    360|	int _ret = r; \
  |  |  |  |  155|    360|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 360, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    360|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    360|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 360, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    360|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    360|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    360|	return _ret; \
  |  |  |  |  163|    360|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  954|       |
  955|       |	/* lock the card now to avoid deselection of the file */
  956|  2.50k|	r = sc_lock(card);
  957|  2.50k|	LOG_TEST_RET(card->ctx, r, "sc_lock() failed");
  ------------------
  |  |  174|  2.50k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.50k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.50k|	int _ret = (r); \
  |  |  |  |  168|  2.50k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.50k]
  |  |  |  |  ------------------
  |  |  |  |  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.50k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.50k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  958|       |
  959|  4.31k|	while (todo > 0) {
  ------------------
  |  Branch (959:9): [True: 4.06k, False: 249]
  ------------------
  960|  4.06k|		size_t chunk = MIN(todo, max_le);
  ------------------
  |  |   70|  4.06k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 2.27k, False: 1.78k]
  |  |  ------------------
  ------------------
  961|       |
  962|  4.06k|		r = card->ops->read_record(card, rec_nr, idx, buf, chunk, flags);
  963|  4.06k|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|  3.74k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (963:7): [True: 317, False: 3.74k]
  |  Branch (963:17): [True: 84, False: 3.66k]
  ------------------
  964|    401|			break;
  965|  3.66k|		if (r < 0 && todo != count) {
  ------------------
  |  Branch (965:7): [True: 1.85k, False: 1.81k]
  |  Branch (965:16): [True: 1.38k, False: 470]
  ------------------
  966|       |			/* the last command failed, but previous ones succeeded.
  967|       |			 * Let's just return what we've successfully read. */
  968|  1.38k|			sc_log(card->ctx, "Subsequent read failed with %d, returning what was read successfully.", r);
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
  969|  1.38k|			break;
  970|  1.38k|		}
  971|  2.28k|		if (r < 0) {
  ------------------
  |  Branch (971:7): [True: 470, False: 1.81k]
  ------------------
  972|    470|			sc_unlock(card);
  973|    470|			LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    470|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    470|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    470|	int _ret = r; \
  |  |  |  |  155|    470|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 470, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    470|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    470|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 470, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    470|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    470|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    470|	return _ret; \
  |  |  |  |  163|    470|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  974|    470|		}
  975|  1.81k|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (975:7): [True: 0, False: 1.81k]
  |  Branch (975:40): [True: 0, False: 1.81k]
  ------------------
  976|       |			/* `idx + r` or `todo - r` would overflow */
  977|      0|			sc_unlock(card);
  978|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  979|      0|		}
  980|       |
  981|  1.81k|		todo -= (size_t) r;
  982|  1.81k|		buf  += (size_t) r;
  983|  1.81k|		idx  += (size_t) r;
  984|  1.81k|	}
  985|       |
  986|  2.03k|	sc_unlock(card);
  987|       |
  988|  2.03k|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  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: 367, False: 1.66k]
  |  |  |  |  ------------------
  |  |  |  |  156|    367|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 367]
  |  |  |  |  ------------------
  |  |  |  |  157|    367|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.66k|	} else { \
  |  |  |  |  159|  1.66k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.66k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.66k|	} \
  |  |  |  |  162|  2.03k|	return _ret; \
  |  |  |  |  163|  2.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  989|  2.03k|}
sc_append_record:
 1014|      2|{
 1015|      2|	int r;
 1016|       |
 1017|      2|	if (card == NULL) {
  ------------------
  |  Branch (1017:6): [True: 0, False: 2]
  ------------------
 1018|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1019|      0|	}
 1020|      2|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1021|       |
 1022|      2|	if (card->ops->append_record == NULL)
  ------------------
  |  Branch (1022:6): [True: 2, False: 0]
  ------------------
 1023|      2|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1024|       |
 1025|      0|	r = card->ops->append_record(card, buf, count, flags);
 1026|      0|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1026:6): [True: 0, False: 0]
  ------------------
 1027|      0|		r = (int)count;
 1028|      0|	}
 1029|       |
 1030|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1031|      0|}
sc_update_record:
 1035|      2|{
 1036|      2|	size_t max_lc = sc_get_max_send_size(card);
 1037|      2|	size_t todo = count;
 1038|      2|	int r;
 1039|       |
 1040|      2|	if (card == NULL || card->ops == NULL || buf == NULL) {
  ------------------
  |  Branch (1040:6): [True: 0, False: 2]
  |  Branch (1040:22): [True: 0, False: 2]
  |  Branch (1040:43): [True: 0, False: 2]
  ------------------
 1041|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1042|      0|	}
 1043|      2|	LOG_FUNC_CALLED(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1044|      2|	if (count == 0)
  ------------------
  |  Branch (1044:6): [True: 0, False: 2]
  ------------------
 1045|      2|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1046|       |
 1047|      2|	if (card->ops->update_record == NULL)
  ------------------
  |  Branch (1047:6): [True: 2, False: 0]
  ------------------
 1048|      2|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1049|       |
 1050|       |	/* lock the card now to avoid deselection of the file */
 1051|      0|	r = sc_lock(card);
 1052|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1053|       |
 1054|      0|	while (todo > 0) {
  ------------------
  |  Branch (1054:9): [True: 0, False: 0]
  ------------------
 1055|      0|		size_t chunk = MIN(todo, max_lc);
  ------------------
  |  |   70|      0|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 0]
  |  |  ------------------
  ------------------
 1056|       |
 1057|      0|		r = card->ops->update_record(card, rec_nr, idx, buf, chunk, flags);
 1058|      0|		if (r == 0 || r == SC_ERROR_FILE_END_REACHED)
  ------------------
  |  |   69|      0|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
  |  Branch (1058:7): [True: 0, False: 0]
  |  Branch (1058:17): [True: 0, False: 0]
  ------------------
 1059|      0|			break;
 1060|      0|		if (r < 0) {
  ------------------
  |  Branch (1060:7): [True: 0, False: 0]
  ------------------
 1061|      0|			sc_unlock(card);
 1062|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1063|      0|		}
 1064|      0|		if ((idx > SIZE_MAX - (size_t) r) || (size_t) r > todo) {
  ------------------
  |  Branch (1064:7): [True: 0, False: 0]
  |  Branch (1064:40): [True: 0, False: 0]
  ------------------
 1065|       |			/* `idx + r` or `todo - r` would overflow */
 1066|      0|			sc_unlock(card);
 1067|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1068|      0|		}
 1069|       |
 1070|      0|		todo -= (size_t) r;
 1071|      0|		buf  += (size_t) r;
 1072|      0|		idx  += (size_t) r;
 1073|      0|	}
 1074|       |
 1075|      0|	sc_unlock(card);
 1076|       |
 1077|      0|	LOG_FUNC_RETURN(card->ctx, (int)(count - todo));
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1078|      0|}
sc_card_ctl:
 1099|  69.8k|{
 1100|  69.8k|	int r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  69.8k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1101|       |
 1102|  69.8k|	if (card == NULL) {
  ------------------
  |  Branch (1102:6): [True: 0, False: 69.8k]
  ------------------
 1103|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1104|      0|	}
 1105|  69.8k|	sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "called with cmd=%lu\n", cmd);
  ------------------
  |  |   70|  69.8k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1106|       |
 1107|  69.8k|	if (card->ops->card_ctl != NULL)
  ------------------
  |  Branch (1107:6): [True: 69.8k, False: 11]
  ------------------
 1108|  69.8k|		r = card->ops->card_ctl(card, cmd, args);
 1109|       |
 1110|       |	/* suppress "not supported" error messages */
 1111|  69.8k|	if (r == SC_ERROR_NOT_SUPPORTED) {
  ------------------
  |  |   89|  69.8k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (1111:6): [True: 5.14k, False: 64.6k]
  ------------------
 1112|  5.14k|		sc_log(card->ctx, "card_ctl(%lu) not supported", cmd);
  ------------------
  |  |   71|  5.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__
  |  |  ------------------
  ------------------
 1113|  5.14k|		return r;
 1114|  5.14k|	}
 1115|  64.6k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  64.6k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  64.6k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  64.6k|	int _ret = r; \
  |  |  |  |  155|  64.6k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 64.6k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  64.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|  62.1k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 62.1k, False: 2.47k]
  |  |  |  |  ------------------
  |  |  |  |  157|  64.6k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  64.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|  64.6k|	return _ret; \
  |  |  |  |  163|  64.6k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1116|  64.6k|}
_sc_card_add_algorithm:
 1119|  19.9k|{
 1120|  19.9k|	sc_algorithm_info_t *p;
 1121|       |
 1122|  19.9k|	if (info == NULL) {
  ------------------
  |  Branch (1122:6): [True: 0, False: 19.9k]
  ------------------
 1123|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1124|      0|	}
 1125|  19.9k|	p = (sc_algorithm_info_t *) realloc(card->algorithms, (card->algorithm_count + 1) * sizeof(*info));
 1126|  19.9k|	if (!p) {
  ------------------
  |  Branch (1126:6): [True: 0, False: 19.9k]
  ------------------
 1127|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1128|      0|	}
 1129|  19.9k|	card->algorithms = p;
 1130|  19.9k|	p += card->algorithm_count;
 1131|  19.9k|	card->algorithm_count++;
 1132|  19.9k|	*p = *info;
 1133|  19.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  19.9k|#define SC_SUCCESS				0
  ------------------
 1134|  19.9k|}
_sc_card_add_symmetric_alg:
 1138|  1.33k|{
 1139|  1.33k|	sc_algorithm_info_t info;
 1140|       |
 1141|  1.33k|	memset(&info, 0, sizeof(info));
 1142|  1.33k|	info.algorithm = algorithm;
 1143|  1.33k|	info.key_length = key_length;
 1144|  1.33k|	info.flags = flags;
 1145|       |
 1146|  1.33k|	return _sc_card_add_algorithm(card, &info);
 1147|  1.33k|}
_sc_card_add_ec_alg:
 1184|  5.06k|{
 1185|  5.06k|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1186|  5.06k|		curve_oid, SC_ALGORITHM_EC);
  ------------------
  |  |   79|  5.06k|#define SC_ALGORITHM_EC		2
  ------------------
 1187|  5.06k|}
_sc_card_add_eddsa_alg:
 1192|     65|{
 1193|       |	/* For simplicity, share the ec union with the curve information */
 1194|     65|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1195|     65|		curve_oid, SC_ALGORITHM_EDDSA);
  ------------------
  |  |   81|     65|#define SC_ALGORITHM_EDDSA		4
  ------------------
 1196|     65|}
_sc_card_add_xeddsa_alg:
 1201|  1.56k|{
 1202|       |	/* For simplicity, share the ec union with the curve information */
 1203|  1.56k|	return _sc_card_add_ec_alg_int(card, key_length, flags, ext_flags,
 1204|  1.56k|		curve_oid, SC_ALGORITHM_XEDDSA);
  ------------------
  |  |   82|  1.56k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
 1205|  1.56k|}
sc_card_find_alg:
 1209|    199|{
 1210|    199|	int i;
 1211|       |
 1212|  1.04k|	for (i = 0; i < card->algorithm_count; i++) {
  ------------------
  |  Branch (1212:14): [True: 975, False: 67]
  ------------------
 1213|    975|		sc_algorithm_info_t *info = &card->algorithms[i];
 1214|       |
 1215|    975|		if (param && (info->algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1215:7): [True: 0, False: 975]
  |  Branch (1215:17): [True: 0, False: 0]
  ------------------
 1216|      0|			info->algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1216:4): [True: 0, False: 0]
  ------------------
 1217|      0|			info->algorithm == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1217:4): [True: 0, False: 0]
  ------------------
 1218|      0|			if (sc_compare_oid((struct sc_object_id *)param, &info->u._ec.params.id))
  ------------------
  |  Branch (1218:8): [True: 0, False: 0]
  ------------------
 1219|      0|				return info;
 1220|    975|		} else if (info->algorithm != algorithm) {
  ------------------
  |  Branch (1220:14): [True: 276, False: 699]
  ------------------
 1221|    276|			continue;
 1222|    699|		} else if (info->key_length == key_length)
  ------------------
  |  Branch (1222:14): [True: 132, False: 567]
  ------------------
 1223|    132|			return info;
 1224|    975|	}
 1225|     67|	return NULL;
 1226|    199|}
sc_card_find_ec_alg:
 1230|     42|{
 1231|     42|	return sc_card_find_alg(card, SC_ALGORITHM_EC, key_length, curve_name);
  ------------------
  |  |   79|     42|#define SC_ALGORITHM_EC		2
  ------------------
 1232|     42|}
_sc_card_add_rsa_alg:
 1248|  11.8k|{
 1249|  11.8k|	sc_algorithm_info_t info;
 1250|       |
 1251|  11.8k|	memset(&info, 0, sizeof(info));
 1252|  11.8k|	info.algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|  11.8k|#define SC_ALGORITHM_RSA		0
  ------------------
 1253|  11.8k|	info.key_length = key_length;
 1254|  11.8k|	info.flags = flags;
 1255|       |	/* disable particular PKCS1 v1.5 padding type if also RAW is supported on card */
 1256|  11.8k|	if ((info.flags & (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) == (SC_ALGORITHM_RSA_PAD_PKCS1 | SC_ALGORITHM_RSA_RAW)) {
  ------------------
  |  |  120|  11.8k|#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) */
  |  |  ------------------
  |  |  |  |  118|  11.8k|#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) */
  |  |  ------------------
  |  |  |  |  119|  11.8k|#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)) {
  ------------------
  |  |  111|  11.8k|#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)) {
  ------------------
  |  |  120|  11.8k|#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) */
  |  |  ------------------
  |  |  |  |  118|  11.8k|#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) */
  |  |  ------------------
  |  |  |  |  119|  11.8k|#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)) {
  ------------------
  |  |  111|  11.8k|#define SC_ALGORITHM_RSA_RAW		0x00000001
  ------------------
  |  Branch (1256:6): [True: 3.57k, False: 8.32k]
  ------------------
 1257|  3.57k|		if (card->ctx->disable_hw_pkcs1_padding & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01)
  ------------------
  |  |  118|  3.57k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  |  Branch (1257:7): [True: 0, False: 3.57k]
  ------------------
 1258|      0|			info.flags &= ~SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01;
  ------------------
  |  |  118|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
 1259|  3.57k|		if (card->ctx->disable_hw_pkcs1_padding & SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02)
  ------------------
  |  |  119|  3.57k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  |  Branch (1259:7): [True: 3.57k, False: 0]
  ------------------
 1260|  3.57k|			info.flags &= ~SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  119|  3.57k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
 1261|  3.57k|	}
 1262|  11.8k|	info.u._rsa.exponent = exponent;
 1263|       |
 1264|  11.8k|	return _sc_card_add_algorithm(card, &info);
 1265|  11.8k|}
sc_card_find_rsa_alg:
 1268|    157|{
 1269|    157|	return sc_card_find_alg(card, SC_ALGORITHM_RSA, key_length, NULL);
  ------------------
  |  |   78|    157|#define SC_ALGORITHM_RSA		0
  ------------------
 1270|    157|}
_sc_match_atr:
 1341|  74.0k|{
 1342|  74.0k|	int res;
 1343|       |
 1344|  74.0k|	if (card == NULL)
  ------------------
  |  Branch (1344:6): [True: 0, False: 74.0k]
  ------------------
 1345|      0|		return -1;
 1346|  74.0k|	res = match_atr_table(card->ctx, table, &card->atr);
 1347|  74.0k|	if (res < 0)
  ------------------
  |  Branch (1347:6): [True: 72.0k, False: 2.01k]
  ------------------
 1348|  72.0k|		return res;
 1349|  2.01k|	if (type_out != NULL)
  ------------------
  |  Branch (1349:6): [True: 1.94k, False: 72]
  ------------------
 1350|  1.94k|		*type_out = table[res].type;
 1351|  2.01k|	return res;
 1352|  74.0k|}
_sc_match_atr_block:
 1355|  3.45k|{
 1356|  3.45k|	struct sc_card_driver *drv;
 1357|  3.45k|	struct sc_atr_table *table;
 1358|  3.45k|	int res;
 1359|       |
 1360|  3.45k|	if (ctx == NULL)
  ------------------
  |  Branch (1360:6): [True: 0, False: 3.45k]
  ------------------
 1361|      0|		return NULL;
 1362|  3.45k|	if (driver) {
  ------------------
  |  Branch (1362:6): [True: 3.45k, False: 0]
  ------------------
 1363|  3.45k|		drv = driver;
 1364|  3.45k|		table = drv->atr_map;
 1365|  3.45k|		res = match_atr_table(ctx, table, atr);
 1366|  3.45k|		if (res < 0)
  ------------------
  |  Branch (1366:7): [True: 3.45k, False: 0]
  ------------------
 1367|  3.45k|			return NULL;
 1368|      0|		return table[res].card_atr;
 1369|  3.45k|	} else {
 1370|      0|		unsigned int i;
 1371|       |
 1372|      0|		for (i = 0; ctx->card_drivers[i] != NULL; i++) {
  ------------------
  |  Branch (1372:15): [True: 0, False: 0]
  ------------------
 1373|      0|			drv = ctx->card_drivers[i];
 1374|      0|			table = drv->atr_map;
 1375|      0|			res = match_atr_table(ctx, table, atr);
 1376|      0|			if (res < 0)
  ------------------
  |  Branch (1376:8): [True: 0, False: 0]
  ------------------
 1377|      0|				continue;
 1378|      0|			return table[res].card_atr;
 1379|      0|		}
 1380|      0|	}
 1381|      0|	return NULL;
 1382|  3.45k|}
sc_get_conf_block:
 1453|  72.6k|{
 1454|  72.6k|	int i;
 1455|  72.6k|	scconf_block *conf_block = NULL;
 1456|       |
 1457|   145k|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (1457:14): [True: 72.6k, False: 72.6k]
  ------------------
 1458|  72.6k|		scconf_block **blocks;
 1459|       |
 1460|  72.6k|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], name1, name2);
 1461|  72.6k|		if (blocks != NULL) {
  ------------------
  |  Branch (1461:7): [True: 72.6k, False: 0]
  ------------------
 1462|  72.6k|			conf_block = blocks[0];
 1463|  72.6k|			free(blocks);
 1464|  72.6k|		}
 1465|  72.6k|		if (conf_block != NULL && priority)
  ------------------
  |  Branch (1465:7): [True: 0, False: 72.6k]
  |  Branch (1465:29): [True: 0, False: 0]
  ------------------
 1466|      0|			break;
 1467|  72.6k|	}
 1468|  72.6k|	return conf_block;
 1469|  72.6k|}
sc_clear_ec_params:
 1473|  9.62k|{
 1474|  9.62k|	if (ecp) {
  ------------------
  |  Branch (1474:6): [True: 9.62k, False: 0]
  ------------------
 1475|  9.62k|		free(ecp->named_curve);
 1476|  9.62k|		free(ecp->der.value);
 1477|  9.62k|		memset(ecp, 0, sizeof(struct sc_ec_parameters));
 1478|  9.62k|	}
 1479|  9.62k|	return;
 1480|  9.62k|}
sc_copy_ec_params:
 1483|  1.39k|{
 1484|  1.39k|	if (!dst || !src)
  ------------------
  |  Branch (1484:6): [True: 0, False: 1.39k]
  |  Branch (1484:14): [True: 0, False: 1.39k]
  ------------------
 1485|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1486|       |
 1487|  1.39k|	memset(dst, 0, sizeof(*dst));
 1488|  1.39k|	if (src->named_curve)   {
  ------------------
  |  Branch (1488:6): [True: 1.39k, False: 0]
  ------------------
 1489|  1.39k|		dst->named_curve = strdup(src->named_curve);
 1490|  1.39k|		if (!dst->named_curve)
  ------------------
  |  Branch (1490:7): [True: 0, False: 1.39k]
  ------------------
 1491|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1492|  1.39k|	}
 1493|  1.39k|	dst->id = src->id;
 1494|  1.39k|	if (src->der.value && src->der.len)   {
  ------------------
  |  Branch (1494:6): [True: 1.39k, False: 0]
  |  Branch (1494:24): [True: 1.39k, False: 0]
  ------------------
 1495|  1.39k|		dst->der.value = malloc(src->der.len);
 1496|  1.39k|		if (!dst->der.value) {
  ------------------
  |  Branch (1496:7): [True: 0, False: 1.39k]
  ------------------
 1497|      0|			free(dst->named_curve);
 1498|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1499|      0|		}
 1500|  1.39k|		memcpy(dst->der.value, src->der.value, src->der.len);
 1501|  1.39k|		dst->der.len = src->der.len;
 1502|  1.39k|	}
 1503|  1.39k|	dst->type = src->type;
 1504|  1.39k|	dst->field_length = src->field_length;
 1505|  1.39k|	dst->key_type = src->key_type;
 1506|       |
 1507|  1.39k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.39k|#define SC_SUCCESS				0
  ------------------
 1508|  1.39k|}
card.c:sc_card_new:
  127|  3.69k|{
  128|  3.69k|	sc_card_t *card;
  129|       |
  130|  3.69k|	if (ctx == NULL)
  ------------------
  |  Branch (130:6): [True: 0, False: 3.69k]
  ------------------
  131|      0|		return NULL;
  132|       |
  133|  3.69k|	card = calloc(1, sizeof(struct sc_card));
  134|  3.69k|	if (card == NULL)
  ------------------
  |  Branch (134:6): [True: 0, False: 3.69k]
  ------------------
  135|      0|		return NULL;
  136|  3.69k|	card->ops = malloc(sizeof(struct sc_card_operations));
  137|  3.69k|	if (card->ops == NULL) {
  ------------------
  |  Branch (137:6): [True: 0, False: 3.69k]
  ------------------
  138|      0|		free(card);
  139|      0|		return NULL;
  140|      0|	}
  141|       |
  142|  3.69k|	card->ctx = ctx;
  143|  3.69k|	if (sc_mutex_create(ctx, &card->mutex) != SC_SUCCESS) {
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
  |  Branch (143:6): [True: 0, False: 3.69k]
  ------------------
  144|      0|		free(card->ops);
  145|      0|		free(card);
  146|      0|		return NULL;
  147|      0|	}
  148|       |
  149|  3.69k|	card->type = -1;
  150|  3.69k|	card->app_count = -1;
  151|       |
  152|  3.69k|	return card;
  153|  3.69k|}
card.c:sc_card_free:
  156|  3.69k|{
  157|  3.69k|	sc_free_apps(card);
  158|  3.69k|	sc_free_ef_atr(card);
  159|       |
  160|  3.69k|	free(card->ops);
  161|       |
  162|  3.69k|	if (card->algorithms != NULL)   {
  ------------------
  |  Branch (162:6): [True: 2.96k, False: 729]
  ------------------
  163|  2.96k|		int i;
  164|  22.9k|		for (i=0; i<card->algorithm_count; i++)   {
  ------------------
  |  Branch (164:13): [True: 19.9k, False: 2.96k]
  ------------------
  165|  19.9k|			struct sc_algorithm_info *info = (card->algorithms + i);
  166|  19.9k|			if (info->algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   79|  39.8k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (166:8): [True: 5.06k, False: 14.8k]
  ------------------
  167|  14.8k|					info->algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   81|  34.8k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (167:6): [True: 65, False: 14.8k]
  ------------------
  168|  14.8k|					info->algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   82|  14.8k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (168:6): [True: 1.56k, False: 13.2k]
  ------------------
  169|  6.69k|				sc_clear_ec_params(&info->u._ec.params);
  170|  6.69k|			}
  171|  19.9k|		}
  172|  2.96k|		free(card->algorithms);
  173|       |
  174|  2.96k|		card->algorithms = NULL;
  175|  2.96k|		card->algorithm_count = 0;
  176|  2.96k|	}
  177|       |
  178|  3.69k|	if (card->mutex != NULL) {
  ------------------
  |  Branch (178:6): [True: 0, False: 3.69k]
  ------------------
  179|      0|		int r = sc_mutex_destroy(card->ctx, card->mutex);
  180|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (180:7): [True: 0, False: 0]
  ------------------
  181|      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__
  |  |  ------------------
  ------------------
  182|      0|	}
  183|  3.69k|	sc_mem_clear(card, sizeof(*card));
  184|  3.69k|	free(card);
  185|  3.69k|}
card.c:_sc_card_add_ec_alg_int:
 1154|  6.69k|{
 1155|  6.69k|	sc_algorithm_info_t info;
 1156|  6.69k|	int r;
 1157|       |
 1158|  6.69k|	memset(&info, 0, sizeof(info));
 1159|  6.69k|	sc_init_oid(&info.u._ec.params.id);
 1160|       |
 1161|  6.69k|	info.algorithm = algorithm;
 1162|  6.69k|	info.key_length = key_length;
 1163|  6.69k|	info.flags = flags;
 1164|       |
 1165|  6.69k|	info.u._ec.ext_flags = ext_flags;
 1166|  6.69k|	if (curve_oid) {
  ------------------
  |  Branch (1166:6): [True: 5.14k, False: 1.55k]
  ------------------
 1167|  5.14k|		info.u._ec.params.id = *curve_oid;
 1168|  5.14k|		r = sc_encode_oid(card->ctx, &info.u._ec.params.id, &info.u._ec.params.der.value, &info.u._ec.params.der.len);
 1169|  5.14k|		LOG_TEST_GOTO_ERR(card->ctx, r, "sc_encode_oid failed");
  ------------------
  |  |  184|  5.14k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  5.14k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  5.14k|	int _ret = (r); \
  |  |  |  |  178|  5.14k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 5.14k]
  |  |  |  |  ------------------
  |  |  |  |  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.14k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 5.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1170|  5.14k|		r = sc_pkcs15_fix_ec_parameters(card->ctx, &info.u._ec.params);
 1171|  5.14k|		LOG_TEST_GOTO_ERR(card->ctx, r, "sc_pkcs15_fix_ec_parameters failed");
  ------------------
  |  |  184|  5.14k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  5.14k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  5.14k|	int _ret = (r); \
  |  |  |  |  178|  5.14k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 5.14k]
  |  |  |  |  ------------------
  |  |  |  |  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.14k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 5.14k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1172|  5.14k|	}
 1173|       |
 1174|  6.69k|	r = _sc_card_add_algorithm(card, &info);
 1175|  6.69k|	return r;
 1176|      0|err:
 1177|      0|	sc_clear_ec_params(&info.u._ec.params);
 1178|      0|	return r;
 1179|  6.69k|}
card.c:match_atr_table:
 1278|  77.5k|{
 1279|  77.5k|	u8 *card_atr_bin;
 1280|  77.5k|	size_t card_atr_bin_len;
 1281|  77.5k|	char card_atr_hex[3 * SC_MAX_ATR_SIZE];
 1282|  77.5k|	size_t card_atr_hex_len;
 1283|  77.5k|	unsigned int i = 0;
 1284|       |
 1285|  77.5k|	if (ctx == NULL || table == NULL || atr == NULL)
  ------------------
  |  Branch (1285:6): [True: 0, False: 77.5k]
  |  Branch (1285:21): [True: 3.45k, False: 74.0k]
  |  Branch (1285:38): [True: 0, False: 74.0k]
  ------------------
 1286|  3.45k|		return -1;
 1287|  74.0k|	card_atr_bin = atr->value;
 1288|  74.0k|	card_atr_bin_len = atr->len;
 1289|  74.0k|	sc_bin_to_hex(card_atr_bin, card_atr_bin_len, card_atr_hex, sizeof(card_atr_hex), ':');
 1290|  74.0k|	card_atr_hex_len = strlen(card_atr_hex);
 1291|       |
 1292|  74.0k|	sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR     : %s", card_atr_hex);
  ------------------
  |  |   70|  74.0k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1293|       |
 1294|   636k|	for (i = 0; table[i].atr != NULL; i++) {
  ------------------
  |  Branch (1294:14): [True: 564k, False: 72.0k]
  ------------------
 1295|   564k|		const char *tatr = table[i].atr;
 1296|   564k|		const char *matr = table[i].atrmask;
 1297|   564k|		size_t tatr_len = strlen(tatr);
 1298|   564k|		u8 mbin[SC_MAX_ATR_SIZE], tbin[SC_MAX_ATR_SIZE];
 1299|   564k|		size_t mbin_len, tbin_len, s, matr_len;
 1300|   564k|		size_t fix_hex_len = card_atr_hex_len;
 1301|   564k|		size_t fix_bin_len = card_atr_bin_len;
 1302|       |
 1303|   564k|		sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR try : %s", tatr);
  ------------------
  |  |   70|   564k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1304|       |
 1305|   564k|		if (tatr_len != fix_hex_len) {
  ------------------
  |  Branch (1305:7): [True: 540k, False: 24.3k]
  ------------------
 1306|   540k|			sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ignored - wrong length");
  ------------------
  |  |   70|   540k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1307|   540k|			continue;
 1308|   540k|		}
 1309|  24.3k|		if (matr != NULL) {
  ------------------
  |  Branch (1309:7): [True: 6.10k, False: 18.2k]
  ------------------
 1310|  6.10k|			sc_debug(ctx, SC_LOG_DEBUG_MATCH, "ATR mask: %s", matr);
  ------------------
  |  |   70|  6.10k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1311|       |
 1312|  6.10k|			matr_len = strlen(matr);
 1313|  6.10k|			if (tatr_len != matr_len)
  ------------------
  |  Branch (1313:8): [True: 0, False: 6.10k]
  ------------------
 1314|      0|				continue;
 1315|  6.10k|			tbin_len = sizeof(tbin);
 1316|  6.10k|			sc_hex_to_bin(tatr, tbin, &tbin_len);
 1317|  6.10k|			mbin_len = sizeof(mbin);
 1318|  6.10k|			sc_hex_to_bin(matr, mbin, &mbin_len);
 1319|  6.10k|			if (mbin_len != fix_bin_len) {
  ------------------
  |  Branch (1319:8): [True: 0, False: 6.10k]
  ------------------
 1320|      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__
  |  |  ------------------
  ------------------
 1321|      0|				continue;
 1322|      0|			}
 1323|   125k|			for (s = 0; s < tbin_len; s++) {
  ------------------
  |  Branch (1323:16): [True: 119k, False: 6.10k]
  ------------------
 1324|       |				/* reduce tatr with mask */
 1325|   119k|				tbin[s] = (tbin[s] & mbin[s]);
 1326|       |				/* create copy of card_atr_bin masked) */
 1327|   119k|				mbin[s] = (card_atr_bin[s] & mbin[s]);
 1328|   119k|			}
 1329|  6.10k|			if (memcmp(tbin, mbin, tbin_len) != 0)
  ------------------
  |  Branch (1329:8): [True: 5.30k, False: 805]
  ------------------
 1330|  5.30k|				continue;
 1331|  18.2k|		} else {
 1332|  18.2k|			if (strncasecmp(tatr, card_atr_hex, tatr_len) != 0)
  ------------------
  |  Branch (1332:8): [True: 17.0k, False: 1.21k]
  ------------------
 1333|  17.0k|				continue;
 1334|  18.2k|		}
 1335|  2.01k|		return i;
 1336|  24.3k|	}
 1337|  72.0k|	return -1;
 1338|  74.0k|}
card.c:sc_card_sm_unload:
 1519|  3.45k|{
 1520|  3.45k|	if (card->sm_ctx.module.ops.module_cleanup)
  ------------------
  |  Branch (1520:6): [True: 0, False: 3.45k]
  ------------------
 1521|      0|		card->sm_ctx.module.ops.module_cleanup(card->ctx);
 1522|       |
 1523|  3.45k|	if (card->sm_ctx.module.handle)
  ------------------
  |  Branch (1523:6): [True: 0, False: 3.45k]
  ------------------
 1524|      0|		sc_dlclose(card->sm_ctx.module.handle);
 1525|       |	card->sm_ctx.module.handle = NULL;
 1526|  3.45k|	return 0;
 1527|  3.45k|}
card.c:sc_card_sm_check:
 1622|  3.45k|{
 1623|  3.45k|	const char *sm = NULL, *module_name = NULL, *module_path = NULL, *module_data = NULL, *sm_mode = NULL;
 1624|  3.45k|	struct sc_context *ctx = card->ctx;
 1625|  3.45k|	scconf_block *atrblock = NULL, *sm_conf_block = NULL;
 1626|  3.45k|	int rv, ii;
 1627|       |#ifdef _WIN32
 1628|       |	char temp_path[PATH_MAX];
 1629|       |	size_t temp_len = PATH_MAX - 1;
 1630|       |	char expanded_val[PATH_MAX];
 1631|       |	DWORD expanded_len = PATH_MAX;
 1632|       |#endif
 1633|       |
 1634|  3.45k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.45k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.45k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.45k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.45k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.45k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1635|       |
 1636|       |	/* get the name of card specific SM configuration section */
 1637|  3.45k|	atrblock = _sc_match_atr_block(ctx, card->driver, &card->atr);
 1638|  3.45k|	if (atrblock == NULL)
  ------------------
  |  Branch (1638:6): [True: 3.45k, False: 0]
  ------------------
 1639|  3.45k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.45k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.45k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.45k|	int _ret = r; \
  |  |  |  |  155|  3.45k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.45k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.45k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.45k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.45k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.45k|	} else { \
  |  |  |  |  159|      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.45k|	return _ret; \
  |  |  |  |  163|  3.45k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1640|      0|	sm = scconf_get_str(atrblock, "secure_messaging", NULL);
 1641|      0|	if (!sm)
  ------------------
  |  Branch (1641:6): [True: 0, False: 0]
  ------------------
 1642|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1643|       |
 1644|       |	/* get SM configuration section by the name */
 1645|      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__
  |  |  ------------------
  ------------------
 1646|      0|        for (ii = 0; ctx->conf_blocks[ii]; ii++) {
  ------------------
  |  Branch (1646:22): [True: 0, False: 0]
  ------------------
 1647|      0|		scconf_block **blocks;
 1648|       |
 1649|      0|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[ii], "secure_messaging", sm);
 1650|      0|		if (blocks) {
  ------------------
  |  Branch (1650:7): [True: 0, False: 0]
  ------------------
 1651|      0|			sm_conf_block = blocks[0];
 1652|      0|			free(blocks);
 1653|      0|		}
 1654|      0|		if (sm_conf_block != NULL)
  ------------------
  |  Branch (1654:7): [True: 0, False: 0]
  ------------------
 1655|      0|			break;
 1656|      0|	}
 1657|       |
 1658|      0|	if (!sm_conf_block)
  ------------------
  |  Branch (1658:6): [True: 0, False: 0]
  ------------------
 1659|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1660|       |
 1661|       |	/* check if an external SM module has to be used */
 1662|       |#ifdef _WIN32
 1663|       |	rv = sc_ctx_win32_get_config_value(NULL, "SmDir", "Software\\" OPENSC_VS_FF_COMPANY_NAME "\\OpenSC" OPENSC_ARCH_SUFFIX,
 1664|       |			temp_path, &temp_len);
 1665|       |	if (rv == SC_SUCCESS) {
 1666|       |		temp_path[temp_len] = '\0';
 1667|       |		module_path = temp_path;
 1668|       |	}
 1669|       |	expanded_len = ExpandEnvironmentStringsA(module_path, expanded_val, expanded_len);
 1670|       |	if (0 < expanded_len && expanded_len < sizeof expanded_val)
 1671|       |		module_path = expanded_val;
 1672|       |#else
 1673|      0|	module_path = scconf_get_str(sm_conf_block, "module_path", DEFAULT_SM_MODULE_PATH);
 1674|      0|#endif
 1675|      0|	module_name = scconf_get_str(sm_conf_block, "module_name", DEFAULT_SM_MODULE);
 1676|      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__
  |  |  ------------------
  ------------------
 1677|      0|	if (!module_name)
  ------------------
  |  Branch (1677:6): [True: 0, False: 0]
  ------------------
 1678|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1679|       |
 1680|      0|	rv = sc_card_sm_load(card, module_path, module_name);
 1681|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1682|       |
 1683|      0|	strlcpy(card->sm_ctx.module.filename, module_name, sizeof(card->sm_ctx.module.filename));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1684|      0|	strlcpy(card->sm_ctx.config_section, sm, sizeof(card->sm_ctx.config_section));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1685|       |
 1686|       |	/* allocate resources for the external SM module */
 1687|      0|	if (card->sm_ctx.module.ops.module_init)   {
  ------------------
  |  Branch (1687:6): [True: 0, False: 0]
  ------------------
 1688|      0|		module_data = scconf_get_str(sm_conf_block, "module_data", NULL);
 1689|       |
 1690|      0|		rv = card->sm_ctx.module.ops.module_init(ctx, module_data);
 1691|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1692|      0|	}
 1693|       |
 1694|       |	/* initialize SM session in the case of 'APDU TRANSMIT' SM mode */
 1695|      0|	sm_mode = scconf_get_str(sm_conf_block, "mode", NULL);
 1696|      0|	if (sm_mode && !strcasecmp("Transmit", sm_mode))   {
  ------------------
  |  Branch (1696:6): [True: 0, False: 0]
  |  Branch (1696:17): [True: 0, False: 0]
  ------------------
 1697|      0|		if (!card->sm_ctx.ops.open || !card->sm_ctx.ops.get_sm_apdu || !card->sm_ctx.ops.free_sm_apdu)
  ------------------
  |  Branch (1697:7): [True: 0, False: 0]
  |  Branch (1697:33): [True: 0, False: 0]
  |  Branch (1697:66): [True: 0, False: 0]
  ------------------
 1698|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1699|       |
 1700|      0|		card->sm_ctx.sm_mode = SM_MODE_TRANSMIT;
  ------------------
  |  |   47|      0|#define SM_MODE_TRANSMIT	0x200
  ------------------
 1701|      0|		rv = card->sm_ctx.ops.open(card);
 1702|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1703|      0|	}
 1704|       |
 1705|      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__
  |  |  ------------------
  ------------------
 1706|      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]
  |  |  ------------------
  ------------------
 1707|      0|}

sc_decompress_alloc:
  254|      5|{
  255|      5|	if (in == NULL || out == NULL) {
  ------------------
  |  Branch (255:6): [True: 0, False: 5]
  |  Branch (255:20): [True: 0, False: 5]
  ------------------
  256|      0|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      0|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  257|      0|	}
  258|       |
  259|      5|	if (method == COMPRESSION_AUTO) {
  ------------------
  |  |   26|      5|#define COMPRESSION_AUTO	0
  ------------------
  |  Branch (259:6): [True: 5, False: 0]
  ------------------
  260|      5|		method = detect_method(in, inLen);
  261|      5|		if (method == COMPRESSION_UNKNOWN) {
  ------------------
  |  |   29|      5|#define COMPRESSION_UNKNOWN (-1)
  ------------------
  |  Branch (261:7): [True: 0, False: 5]
  ------------------
  262|      0|			return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      0|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
  263|      0|		}
  264|      5|	}
  265|       |
  266|      5|	switch (method) {
  267|      4|	case COMPRESSION_ZLIB:
  ------------------
  |  |   27|      4|#define COMPRESSION_ZLIB	1
  ------------------
  |  Branch (267:2): [True: 4, False: 1]
  ------------------
  268|      4|		return sc_decompress_zlib_alloc(out, outLen, in, inLen, 0);
  269|      1|	case COMPRESSION_GZIP:
  ------------------
  |  |   28|      1|#define COMPRESSION_GZIP	2
  ------------------
  |  Branch (269:2): [True: 1, False: 4]
  ------------------
  270|      1|		return sc_decompress_zlib_alloc(out, outLen, in, inLen, 1);
  271|      0|	default:
  ------------------
  |  Branch (271:2): [True: 0, False: 5]
  ------------------
  272|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  273|      5|	}
  274|      5|}
compression.c:zerr_to_opensc:
   34|      5|static int zerr_to_opensc(int err) {
   35|      5|	switch(err) {
   36|      0|	case Z_OK:
  ------------------
  |  Branch (36:2): [True: 0, False: 5]
  ------------------
   37|      0|	case Z_STREAM_END:
  ------------------
  |  Branch (37:2): [True: 0, False: 5]
  ------------------
   38|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
   39|      1|	case Z_UNKNOWN:
  ------------------
  |  Branch (39:2): [True: 1, False: 4]
  ------------------
   40|      1|		return SC_ERROR_UNKNOWN;
  ------------------
  |  |  130|      1|#define SC_ERROR_UNKNOWN			-1900
  ------------------
   41|      3|	case Z_DATA_ERROR:
  ------------------
  |  Branch (41:2): [True: 3, False: 2]
  ------------------
   42|      4|	case Z_BUF_ERROR:
  ------------------
  |  Branch (42:2): [True: 1, False: 4]
  ------------------
   43|      4|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|      4|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
   44|      0|	case Z_MEM_ERROR:
  ------------------
  |  Branch (44:2): [True: 0, False: 5]
  ------------------
   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: 5]
  ------------------
   47|      0|	case Z_STREAM_ERROR:
  ------------------
  |  Branch (47:2): [True: 0, False: 5]
  ------------------
   48|       |	/* case Z_NEED_DICT: */
   49|      0|	default:
  ------------------
  |  Branch (49:2): [True: 0, False: 5]
  ------------------
   50|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   51|      5|	}
   52|      5|}
compression.c:detect_method:
   53|      5|static int detect_method(const u8* in, size_t inLen) {
   54|      5|	if (in != NULL && inLen > 1) {
  ------------------
  |  Branch (54:6): [True: 5, False: 0]
  |  Branch (54:20): [True: 5, False: 0]
  ------------------
   55|      5|		if (in[0] == 0x1f && in[1] == 0x8b)
  ------------------
  |  Branch (55:7): [True: 2, False: 3]
  |  Branch (55:24): [True: 1, False: 1]
  ------------------
   56|      1|			return COMPRESSION_GZIP;
  ------------------
  |  |   28|      1|#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|      4|		if ((((uint16_t) in[0])*256 + in[1]) % 31 == 0)
  ------------------
  |  Branch (75:7): [True: 4, False: 0]
  ------------------
   76|      4|			return COMPRESSION_ZLIB;
  ------------------
  |  |   27|      4|#define COMPRESSION_ZLIB	1
  ------------------
   77|      4|	}
   78|      0|	return COMPRESSION_UNKNOWN;
  ------------------
  |  |   29|      0|#define COMPRESSION_UNKNOWN (-1)
  ------------------
   79|      5|}
compression.c:sc_decompress_zlib_alloc:
  185|      5|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|      5|	z_stream gz;
  188|      5|	int err;
  189|      5|	int window_size = 15;
  190|      5|	const size_t startSize = inLen < 1024 ? 2048 : inLen * 2;
  ------------------
  |  Branch (190:27): [True: 4, False: 1]
  ------------------
  191|      5|	const size_t blockSize = inLen < 1024 ? 512 : inLen / 2;
  ------------------
  |  Branch (191:27): [True: 4, False: 1]
  ------------------
  192|      5|	size_t bufferSize = startSize;
  193|      5|	if (gzip)
  ------------------
  |  Branch (193:6): [True: 1, False: 4]
  ------------------
  194|      1|		window_size += 0x20;
  195|      5|	memset(&gz, 0, sizeof(gz));
  196|       |
  197|      5|	if (!out || !outLen)
  ------------------
  |  Branch (197:6): [True: 0, False: 5]
  |  Branch (197:14): [True: 0, False: 5]
  ------------------
  198|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  199|       |
  200|      5|	gz.next_in = (u8*)in;
  201|      5|	gz.avail_in = (unsigned)inLen;
  202|       |
  203|      5|	err = inflateInit2(&gz, window_size);
  204|      5|	if (err != Z_OK)
  ------------------
  |  Branch (204:6): [True: 0, False: 5]
  ------------------
  205|      0|		return zerr_to_opensc(err);
  206|       |
  207|      5|	*outLen = 0;
  208|       |
  209|      6|	while (1) {
  ------------------
  |  Branch (209:9): [True: 6, Folded]
  ------------------
  210|       |		/* Setup buffer... */
  211|      6|		size_t num;
  212|      6|		u8* buf = realloc(*out, bufferSize);
  213|      6|		if (!buf) {
  ------------------
  |  Branch (213:7): [True: 0, False: 6]
  ------------------
  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|      6|		*out = buf;
  220|      6|		gz.next_out = buf + *outLen;
  221|      6|		gz.avail_out = (unsigned)(bufferSize - *outLen);
  222|       |
  223|      6|		err = inflate(&gz, Z_FULL_FLUSH);
  224|      6|		if (err != Z_STREAM_END && err != Z_OK) {
  ------------------
  |  Branch (224:7): [True: 6, False: 0]
  |  Branch (224:30): [True: 5, False: 1]
  ------------------
  225|      5|			free(*out);
  226|      5|			*out = NULL;
  227|      5|			break;
  228|      5|		}
  229|      1|		num = *outLen + gz.avail_out;
  230|      1|		if (bufferSize > num) {
  ------------------
  |  Branch (230:7): [True: 0, False: 1]
  ------------------
  231|      0|			*outLen += bufferSize - num;
  232|      0|			bufferSize += bufferSize - num + blockSize;
  233|      0|		}
  234|      1|		if (err == Z_STREAM_END) {
  ------------------
  |  Branch (234:7): [True: 0, False: 1]
  ------------------
  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|      1|	}
  249|      5|	inflateEnd(&gz);
  250|      5|	return zerr_to_opensc(err);
  251|      5|}

_sc_delete_reader:
   86|  3.69k|{
   87|  3.69k|	if (reader == NULL) {
  ------------------
  |  Branch (87:6): [True: 0, False: 3.69k]
  ------------------
   88|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   89|      0|	}
   90|  3.69k|	if (reader->ops->release)
  ------------------
  |  Branch (90:6): [True: 3.69k, False: 0]
  ------------------
   91|  3.69k|			reader->ops->release(reader);
   92|  3.69k|	free(reader->name);
   93|  3.69k|	free(reader->vendor);
   94|  3.69k|	list_delete(&ctx->readers, reader);
   95|  3.69k|	free(reader);
   96|  3.69k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
   97|  3.69k|}
sc_ctx_detect_readers:
  781|  3.69k|{
  782|  3.69k|	int r = 0;
  783|  3.69k|	const struct sc_reader_driver *drv = ctx->reader_driver;
  784|       |
  785|  3.69k|	sc_mutex_lock(ctx, ctx->mutex);
  786|       |
  787|  3.69k|	if (drv->ops->detect_readers != NULL)
  ------------------
  |  Branch (787:6): [True: 0, False: 3.69k]
  ------------------
  788|      0|		r = drv->ops->detect_readers(ctx);
  789|       |
  790|  3.69k|	sc_mutex_unlock(ctx, ctx->mutex);
  791|       |
  792|  3.69k|	return r;
  793|  3.69k|}
sc_ctx_get_reader:
  796|  3.69k|{
  797|  3.69k|	return list_get_at(&ctx->readers, i);
  798|  3.69k|}
sc_establish_context:
  816|  3.69k|{
  817|  3.69k|	sc_context_param_t ctx_param;
  818|       |
  819|  3.69k|	memset(&ctx_param, 0, sizeof(sc_context_param_t));
  820|  3.69k|	ctx_param.ver      = 0;
  821|  3.69k|	ctx_param.app_name = app_name;
  822|  3.69k|	return sc_context_create(ctx_out, &ctx_param);
  823|  3.69k|}
sc_context_create:
  945|  3.69k|{
  946|  3.69k|	sc_context_t		*ctx;
  947|  3.69k|	struct _sc_ctx_options	opts;
  948|  3.69k|	int			r;
  949|  3.69k|	char			*driver;
  950|       |
  951|  3.69k|	if (ctx_out == NULL || parm == NULL)
  ------------------
  |  Branch (951:6): [True: 0, False: 3.69k]
  |  Branch (951:25): [True: 0, False: 3.69k]
  ------------------
  952|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  953|       |
  954|  3.69k|	ctx = calloc(1, sizeof(sc_context_t));
  955|  3.69k|	if (ctx == NULL)
  ------------------
  |  Branch (955:6): [True: 0, False: 3.69k]
  ------------------
  956|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  957|  3.69k|	memset(&opts, 0, sizeof(opts));
  958|       |
  959|       |	/* set the application name if set in the parameter options */
  960|  3.69k|	if (parm->app_name != NULL)
  ------------------
  |  Branch (960:6): [True: 3.69k, False: 0]
  ------------------
  961|  3.69k|		ctx->app_name = strdup(parm->app_name);
  962|      0|	else
  963|      0|		ctx->app_name = strdup("default");
  964|  3.69k|	if (ctx->app_name == NULL) {
  ------------------
  |  Branch (964:6): [True: 0, False: 3.69k]
  ------------------
  965|      0|		sc_release_context(ctx);
  966|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  967|      0|	}
  968|       |
  969|  3.69k|	ctx->exe_path = get_exe_path();
  970|  3.69k|	if (ctx->exe_path == NULL) {
  ------------------
  |  Branch (970:6): [True: 0, False: 3.69k]
  ------------------
  971|      0|		sc_release_context(ctx);
  972|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  973|      0|	}
  974|       |
  975|  3.69k|	ctx->flags = parm->flags;
  976|  3.69k|	set_defaults(ctx, &opts);
  977|       |
  978|  3.69k|	if (0 != list_init(&ctx->readers)) {
  ------------------
  |  Branch (978:6): [True: 0, False: 3.69k]
  ------------------
  979|      0|		del_drvs(&opts);
  980|      0|		sc_release_context(ctx);
  981|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  982|      0|	}
  983|  3.69k|	list_attributes_seeker(&ctx->readers, reader_list_seeker);
  984|       |	/* set thread context and create mutex object (if specified) */
  985|  3.69k|	if (parm->thread_ctx != NULL)
  ------------------
  |  Branch (985:6): [True: 0, False: 3.69k]
  ------------------
  986|      0|		ctx->thread_ctx = parm->thread_ctx;
  987|  3.69k|	r = sc_mutex_create(ctx, &ctx->mutex);
  988|  3.69k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
  |  Branch (988:6): [True: 0, False: 3.69k]
  ------------------
  989|      0|		del_drvs(&opts);
  990|      0|		sc_release_context(ctx);
  991|      0|		return r;
  992|      0|	}
  993|       |
  994|       |#if defined(ENABLE_OPENSSL) && defined(OPENSSL_SECURE_MALLOC_SIZE) && !defined(LIBRESSL_VERSION_NUMBER)
  995|       |	if (!CRYPTO_secure_malloc_initialized()) {
  996|       |		CRYPTO_secure_malloc_init(OPENSSL_SECURE_MALLOC_SIZE, OPENSSL_SECURE_MALLOC_SIZE/8);
  997|       |	}
  998|       |#endif
  999|       |
 1000|  3.69k|	process_config_file(ctx, &opts);
 1001|       |
 1002|       |	/* overwrite with caller's parameters if explicitly given */
 1003|  3.69k|	if (parm->debug) {
  ------------------
  |  Branch (1003:6): [True: 0, False: 3.69k]
  ------------------
 1004|      0|		ctx->debug = parm->debug;
 1005|      0|	}
 1006|  3.69k|	if (parm->debug_file) {
  ------------------
  |  Branch (1006:6): [True: 0, False: 3.69k]
  ------------------
 1007|      0|		if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  ------------------
  |  Branch (1007:7): [True: 0, False: 0]
  |  Branch (1007:27): [True: 0, False: 0]
  |  Branch (1007:56): [True: 0, False: 0]
  ------------------
 1008|      0|			fclose(ctx->debug_file);
 1009|      0|		ctx->debug_file = parm->debug_file;
 1010|      0|	}
 1011|       |
 1012|  3.69k|	sc_log(ctx, "==================================="); /* first thing in the log */
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
 1013|  3.69k|	sc_log(ctx, "OpenSC version: %s", sc_get_version());
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
 1014|  3.69k|	sc_log(ctx, "Configured for %s (%s)", ctx->app_name, ctx->exe_path);
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
 1015|       |
 1016|       |#ifdef USE_OPENSSL3_LIBCTX
 1017|       |	r = sc_openssl3_init(ctx);
 1018|       |	if (r != SC_SUCCESS) {
 1019|       |		del_drvs(&opts);
 1020|       |		sc_release_context(ctx);
 1021|       |		return r;
 1022|       |	}
 1023|       |#endif
 1024|       |
 1025|       |#ifdef ENABLE_PCSC
 1026|       |	ctx->reader_driver = sc_get_pcsc_driver();
 1027|       |#elif defined(ENABLE_CRYPTOTOKENKIT)
 1028|       |	ctx->reader_driver = sc_get_cryptotokenkit_driver();
 1029|       |#elif defined(ENABLE_CTAPI)
 1030|       |	ctx->reader_driver = sc_get_ctapi_driver();
 1031|       |#elif defined(ENABLE_OPENCT)
 1032|       |	ctx->reader_driver = sc_get_openct_driver();
 1033|       |#endif
 1034|       |
 1035|  3.69k|	r = ctx->reader_driver->ops->init(ctx);
 1036|  3.69k|	if (r != SC_SUCCESS)   {
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1036:6): [True: 0, False: 3.69k]
  ------------------
 1037|      0|		del_drvs(&opts);
 1038|      0|		sc_release_context(ctx);
 1039|      0|		return r;
 1040|      0|	}
 1041|       |
 1042|  3.69k|	driver = getenv("OPENSC_DRIVER");
 1043|  3.69k|	if (driver) {
  ------------------
  |  Branch (1043:6): [True: 0, False: 3.69k]
  ------------------
 1044|      0|		scconf_list *list = NULL;
 1045|      0|		scconf_list_add(&list, driver);
 1046|      0|		set_drivers(&opts, list);
 1047|      0|		scconf_list_destroy(list);
 1048|      0|	}
 1049|       |
 1050|  3.69k|	load_card_drivers(ctx, &opts);
 1051|  3.69k|	load_card_atrs(ctx);
 1052|       |
 1053|  3.69k|	del_drvs(&opts);
 1054|  3.69k|	sc_ctx_detect_readers(ctx);
 1055|  3.69k|	*ctx_out = ctx;
 1056|       |
 1057|  3.69k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
 1058|  3.69k|}
sc_release_context:
 1091|  3.69k|{
 1092|  3.69k|	unsigned int i;
 1093|       |
 1094|  3.69k|	if (ctx == NULL) {
  ------------------
  |  Branch (1094:6): [True: 0, False: 3.69k]
  ------------------
 1095|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1096|      0|	}
 1097|  3.69k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.69k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.69k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.69k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.69k]
  |  |  ------------------
  ------------------
 1098|  7.38k|	while (list_size(&ctx->readers)) {
  ------------------
  |  Branch (1098:9): [True: 3.69k, False: 3.69k]
  ------------------
 1099|  3.69k|		sc_reader_t *rdr = (sc_reader_t *) list_get_at(&ctx->readers, 0);
 1100|  3.69k|		_sc_delete_reader(ctx, rdr);
 1101|  3.69k|	}
 1102|       |
 1103|  3.69k|	if (ctx->reader_driver != NULL && ctx->reader_driver->ops->finish != NULL)
  ------------------
  |  Branch (1103:6): [True: 3.69k, False: 0]
  |  Branch (1103:36): [True: 0, False: 3.69k]
  ------------------
 1104|      0|		ctx->reader_driver->ops->finish(ctx);
 1105|       |
 1106|   166k|	for (i = 0; ctx->card_drivers[i]; i++) {
  ------------------
  |  Branch (1106:14): [True: 162k, False: 3.69k]
  ------------------
 1107|   162k|		struct sc_card_driver *drv = ctx->card_drivers[i];
 1108|       |
 1109|   162k|		if (drv->atr_map)
  ------------------
  |  Branch (1109:7): [True: 0, False: 162k]
  ------------------
 1110|      0|			_sc_free_atr(ctx, drv);
 1111|   162k|		if (drv->dll)
  ------------------
  |  Branch (1111:7): [True: 0, False: 162k]
  ------------------
 1112|      0|			sc_dlclose(drv->dll);
 1113|   162k|	}
 1114|       |#ifdef USE_OPENSSL3_LIBCTX
 1115|       |	sc_openssl3_deinit(ctx);
 1116|       |#endif
 1117|  3.69k|	if (ctx->preferred_language != NULL)
  ------------------
  |  Branch (1117:6): [True: 0, False: 3.69k]
  ------------------
 1118|      0|		free(ctx->preferred_language);
 1119|  3.69k|	if (ctx->mutex != NULL) {
  ------------------
  |  Branch (1119:6): [True: 0, False: 3.69k]
  ------------------
 1120|      0|		int r = sc_mutex_destroy(ctx, ctx->mutex);
 1121|      0|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1121:7): [True: 0, False: 0]
  ------------------
 1122|      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__
  |  |  ------------------
  ------------------
 1123|      0|			return r;
 1124|      0|		}
 1125|      0|	}
 1126|  3.69k|	if (ctx->conf != NULL)
  ------------------
  |  Branch (1126:6): [True: 3.69k, False: 0]
  ------------------
 1127|  3.69k|		scconf_free(ctx->conf);
 1128|  3.69k|	if (ctx->debug_file && (ctx->debug_file != stdout && ctx->debug_file != stderr))
  ------------------
  |  Branch (1128:6): [True: 3.69k, False: 0]
  |  Branch (1128:26): [True: 3.69k, False: 0]
  |  Branch (1128:55): [True: 0, False: 3.69k]
  ------------------
 1129|      0|		fclose(ctx->debug_file);
 1130|  3.69k|	free(ctx->debug_filename);
 1131|  3.69k|	free(ctx->app_name);
 1132|  3.69k|	free(ctx->exe_path);
 1133|  3.69k|	list_destroy(&ctx->readers);
 1134|  3.69k|	sc_mem_clear(ctx, sizeof(*ctx));
 1135|  3.69k|	free(ctx);
 1136|  3.69k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
 1137|  3.69k|}
sc_get_cache_dir:
 1164|  60.5k|{
 1165|  60.5k|	char *homedir;
 1166|  60.5k|	const char *cache_dir;
 1167|  60.5k|        scconf_block *conf_block = NULL;
 1168|       |#ifdef _WIN32
 1169|       |	char temp_path[PATH_MAX];
 1170|       |#endif
 1171|  60.5k|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
 1172|  60.5k|	cache_dir = scconf_get_str(conf_block, "file_cache_dir", NULL);
 1173|  60.5k|	if (cache_dir != NULL) {
  ------------------
  |  Branch (1173:6): [True: 0, False: 60.5k]
  ------------------
 1174|      0|		strlcpy(buf, cache_dir, bufsize);
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1175|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1176|      0|	}
 1177|       |
 1178|  60.5k|#ifndef _WIN32
 1179|       |#ifdef __APPLE__
 1180|       |	cache_dir = getenv("Caches");
 1181|       |#else
 1182|  60.5k|	cache_dir = getenv("XDG_CACHE_HOME");
 1183|  60.5k|#endif
 1184|  60.5k|	if (cache_dir != NULL && cache_dir[0] != '\0') {
  ------------------
  |  Branch (1184:6): [True: 0, False: 60.5k]
  |  Branch (1184:27): [True: 0, False: 0]
  ------------------
 1185|      0|		snprintf(buf, bufsize, "%s/%s", cache_dir, "opensc");
 1186|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1187|      0|	}
 1188|  60.5k|	cache_dir = ".cache/opensc";
 1189|  60.5k|	homedir = getenv("HOME");
 1190|       |#else
 1191|       |	cache_dir = "eid-cache";
 1192|       |	homedir = getenv("USERPROFILE");
 1193|       |	/* If USERPROFILE isn't defined, assume it's a single-user OS
 1194|       |	 * and put the cache dir in the Windows dir (usually C:\\WINDOWS) */
 1195|       |	if (homedir == NULL || homedir[0] == '\0') {
 1196|       |		GetWindowsDirectoryA(temp_path, sizeof(temp_path));
 1197|       |		homedir = temp_path;
 1198|       |	}
 1199|       |#endif
 1200|  60.5k|	if (homedir == NULL || homedir[0] == '\0')
  ------------------
  |  Branch (1200:6): [True: 0, False: 60.5k]
  |  Branch (1200:25): [True: 0, False: 60.5k]
  ------------------
 1201|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1202|  60.5k|	if (snprintf(buf, bufsize, "%s/%s", homedir, cache_dir) < 0)
  ------------------
  |  Branch (1202:6): [True: 0, False: 60.5k]
  ------------------
 1203|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 1204|  60.5k|	return SC_SUCCESS;
  ------------------
  |  |   28|  60.5k|#define SC_SUCCESS				0
  ------------------
 1205|  60.5k|}
sc_make_cache_dir:
 1208|     26|{
 1209|     26|	char dirname[PATH_MAX], *sp;
 1210|     26|	int    r, mkdir_checker;
 1211|     26|	size_t j, namelen;
 1212|       |
 1213|     26|	if ((r = sc_get_cache_dir(ctx, dirname, sizeof(dirname))) < 0)
  ------------------
  |  Branch (1213:6): [True: 0, False: 26]
  ------------------
 1214|      0|		return r;
 1215|     26|	namelen = strlen(dirname);
 1216|       |
 1217|     26|	while (1) {
  ------------------
  |  Branch (1217:9): [True: 26, Folded]
  ------------------
 1218|       |#ifdef _WIN32
 1219|       |		mkdir_checker = mkdir(dirname) >= 0;
 1220|       |#else
 1221|     26|		mkdir_checker = mkdir(dirname, 0700) >= 0;
 1222|     26|#endif
 1223|     26|		if (mkdir_checker)
  ------------------
  |  Branch (1223:7): [True: 0, False: 26]
  ------------------
 1224|      0|			break;
 1225|       |
 1226|     26|		if (errno != ENOENT || (sp = strrchr(dirname, '/')) == NULL
  ------------------
  |  Branch (1226:7): [True: 26, False: 0]
  |  Branch (1226:26): [True: 0, False: 0]
  ------------------
 1227|      0|				|| sp == dirname)
  ------------------
  |  Branch (1227:8): [True: 0, False: 0]
  ------------------
 1228|     26|			goto failed;
 1229|      0|		*sp = '\0';
 1230|      0|	}
 1231|       |
 1232|       |	/* We may have stripped one or more path components from
 1233|       |	 * the directory name. Restore them */
 1234|      0|	while (1) {
  ------------------
  |  Branch (1234:9): [True: 0, Folded]
  ------------------
 1235|      0|		j = strlen(dirname);
 1236|      0|		if (j >= namelen)
  ------------------
  |  Branch (1236:7): [True: 0, False: 0]
  ------------------
 1237|      0|			break;
 1238|      0|		dirname[j] = '/';
 1239|       |#ifdef _WIN32
 1240|       |		mkdir_checker = mkdir(dirname) < 0;
 1241|       |#else
 1242|      0|		mkdir_checker = mkdir(dirname, 0700) < 0;
 1243|      0|#endif
 1244|      0|		if (mkdir_checker)
  ------------------
  |  Branch (1244:7): [True: 0, False: 0]
  ------------------
 1245|      0|			goto failed;
 1246|      0|	}
 1247|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1248|       |
 1249|       |	/* for lack of a better return code */
 1250|     26|failed:
 1251|     26|	sc_log(ctx, "failed to create cache directory");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1252|     26|	return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     26|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1253|      0|}
ctx.c:load_card_atrs:
  629|  3.69k|{
  630|  3.69k|	struct sc_card_driver *driver;
  631|  3.69k|	scconf_block **blocks;
  632|  3.69k|	int i, j, k;
  633|       |
  634|  7.38k|	for (i = 0; ctx->conf_blocks[i] != NULL; i++) {
  ------------------
  |  Branch (634:14): [True: 3.69k, False: 3.69k]
  ------------------
  635|  3.69k|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i], "card_atr", NULL);
  636|  3.69k|		if (!blocks)
  ------------------
  |  Branch (636:7): [True: 0, False: 3.69k]
  ------------------
  637|      0|			continue;
  638|  3.69k|		for (j = 0; blocks[j] != NULL; j++) {
  ------------------
  |  Branch (638:15): [True: 0, False: 3.69k]
  ------------------
  639|      0|			scconf_block *b = blocks[j];
  640|      0|			char *atr = b->name->data;
  641|      0|			const scconf_list *list;
  642|      0|			struct sc_atr_table t;
  643|      0|			const char *dname;
  644|       |
  645|      0|			driver = NULL;
  646|       |
  647|      0|			if (strlen(atr) < 4)
  ------------------
  |  Branch (647:8): [True: 0, False: 0]
  ------------------
  648|      0|				continue;
  649|       |
  650|       |			/* The interesting part. If there's no card
  651|       |			 * driver assigned for the ATR, add it to
  652|       |			 * the default driver. This will reduce the
  653|       |			 * amount of code required to process things
  654|       |			 * related to card_atr blocks in situations,
  655|       |			 * where the code is not exactly related to
  656|       |			 * card driver settings, but for example
  657|       |			 * forcing a protocol at the reader driver.
  658|       |			 */
  659|      0|			dname = scconf_get_str(b, "driver", "default");
  660|       |
  661|       |			/* Find the card driver structure according to dname */
  662|      0|			for (k = 0; ctx->card_drivers[k] != NULL; k++) {
  ------------------
  |  Branch (662:16): [True: 0, False: 0]
  ------------------
  663|      0|				driver = ctx->card_drivers[k];
  664|      0|				if (!strcmp(dname, driver->short_name))
  ------------------
  |  Branch (664:9): [True: 0, False: 0]
  ------------------
  665|      0|					break;
  666|      0|				driver = NULL;
  667|      0|			}
  668|       |
  669|      0|			if (!driver)
  ------------------
  |  Branch (669:8): [True: 0, False: 0]
  ------------------
  670|      0|				continue;
  671|       |
  672|      0|			memset(&t, 0, sizeof(struct sc_atr_table));
  673|      0|			t.atr = atr;
  674|      0|			t.atrmask = (char *) scconf_get_str(b, "atrmask", NULL);
  675|      0|			t.name = (char *) scconf_get_str(b, "name", NULL);
  676|      0|			t.type = scconf_get_int(b, "type", SC_CARD_TYPE_UNKNOWN);
  677|      0|			list = scconf_find_list(b, "flags");
  678|      0|			while (list != NULL) {
  ------------------
  |  Branch (678:11): [True: 0, False: 0]
  ------------------
  679|      0|				unsigned int flags = 0;
  680|       |
  681|      0|				if (!list->data) {
  ------------------
  |  Branch (681:9): [True: 0, False: 0]
  ------------------
  682|      0|					list = list->next;
  683|      0|					continue;
  684|      0|				}
  685|       |
  686|      0|				if (!strcmp(list->data, "rng"))
  ------------------
  |  Branch (686:9): [True: 0, False: 0]
  ------------------
  687|      0|					flags = SC_CARD_FLAG_RNG;
  ------------------
  |  |  543|      0|#define SC_CARD_FLAG_RNG		0x00000002
  ------------------
  688|      0|				else if (!strcmp(list->data, "keep_alive"))
  ------------------
  |  Branch (688:14): [True: 0, False: 0]
  ------------------
  689|      0|					flags = SC_CARD_FLAG_KEEP_ALIVE;
  ------------------
  |  |  544|      0|#define SC_CARD_FLAG_KEEP_ALIVE	0x00000004
  ------------------
  690|      0|				else if (sscanf(list->data, "%x", &flags) != 1)
  ------------------
  |  Branch (690:14): [True: 0, False: 0]
  ------------------
  691|      0|					flags = 0;
  692|       |
  693|      0|				t.flags |= flags;
  694|      0|				list = list->next;
  695|      0|			}
  696|      0|			t.card_atr = b;
  697|      0|			_sc_add_atr(ctx, driver, &t);
  698|      0|		}
  699|  3.69k|		free(blocks);
  700|  3.69k|	}
  701|  3.69k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
  702|  3.69k|}
ctx.c:get_exe_path:
  910|  3.69k|{
  911|       |	/* Find the executable's path which runs this code.
  912|       |	 * See https://github.com/gpakosz/whereami/ for
  913|       |	 * potentially more platforms */
  914|  3.69k|	char exe_path[PATH_MAX] = "unknown executable path";
  915|  3.69k|	int path_found = 0;
  916|       |
  917|       |#if   defined(_WIN32)
  918|       |	if (0 < GetModuleFileNameA(NULL, exe_path, sizeof exe_path))
  919|       |		path_found = 1;
  920|       |#elif defined(__APPLE__)
  921|       |	if (0 < proc_pidpath(getpid(), exe_path, sizeof exe_path))
  922|       |		path_found = 1;
  923|       |#elif defined(__linux__) || defined(__CYGWIN__)
  924|  3.69k|	if (NULL != realpath("/proc/self/exe", exe_path))
  ------------------
  |  Branch (924:6): [True: 3.69k, False: 0]
  ------------------
  925|  3.69k|		path_found = 1;
  926|  3.69k|#endif
  927|       |
  928|       |#if defined(HAVE_GETPROGNAME)
  929|       |	if (!path_found) {
  930|       |		/* getprogname is unreliable and typically only returns the basename.
  931|       |		 * However, this should be enough for our purposes */
  932|       |		const char *prog = getprogname();
  933|       |		if (prog)
  934|       |			strlcpy(exe_path, prog, sizeof exe_path);
  935|       |	}
  936|       |#else
  937|       |	/* avoid warning "set but not used" */
  938|  3.69k|	(void) path_found;
  939|  3.69k|#endif
  940|       |
  941|  3.69k|	return strdup(exe_path);
  942|  3.69k|}
ctx.c:set_defaults:
  321|  3.69k|{
  322|  3.69k|	ctx->debug = 0;
  323|  3.69k|	if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  ------------------
  |  Branch (323:6): [True: 0, False: 3.69k]
  |  Branch (323:26): [True: 0, False: 0]
  |  Branch (323:55): [True: 0, False: 0]
  ------------------
  324|      0|		fclose(ctx->debug_file);
  325|  3.69k|	ctx->debug_file = stderr;
  326|  3.69k|	ctx->flags = 0;
  327|       |	ctx->forced_driver = NULL;
  328|  3.69k|	add_internal_drvs(opts);
  329|  3.69k|}
ctx.c:add_internal_drvs:
  295|  7.38k|{
  296|  7.38k|	const struct _sc_driver_entry *lst;
  297|  7.38k|	int i;
  298|       |
  299|  7.38k|	lst = internal_card_drivers;
  300|  7.38k|	i = 0;
  301|   295k|	while (lst[i].name != NULL) {
  ------------------
  |  Branch (301:9): [True: 288k, False: 7.38k]
  ------------------
  302|   288k|		add_drv(opts, lst[i].name);
  303|   288k|		i++;
  304|   288k|	}
  305|  7.38k|}
ctx.c:add_drv:
  277|   306k|{
  278|   306k|	struct _sc_driver_entry *lst;
  279|   306k|	int *cp, max, i;
  280|       |
  281|   306k|	lst = opts->cdrv;
  282|   306k|	cp = &opts->ccount;
  283|   306k|	max = SC_MAX_CARD_DRIVERS;
  ------------------
  |  |   31|   306k|#define SC_MAX_CARD_DRIVERS		48
  ------------------
  284|   306k|	if (*cp == max) /* No space for more drivers... */
  ------------------
  |  Branch (284:6): [True: 0, False: 306k]
  ------------------
  285|      0|		return;
  286|  6.53M|	for (i = 0; i < *cp; i++)
  ------------------
  |  Branch (286:14): [True: 6.23M, False: 306k]
  ------------------
  287|  6.23M|		if (strcmp(name, lst[i].name) == 0)
  ------------------
  |  Branch (287:7): [True: 0, False: 6.23M]
  ------------------
  288|      0|			return;
  289|   306k|	lst[*cp].name = strdup(name);
  290|       |
  291|   306k|	*cp = *cp + 1;
  292|   306k|}
ctx.c:del_drvs:
  263|  7.38k|{
  264|  7.38k|	struct _sc_driver_entry *lst;
  265|  7.38k|	int *cp, i;
  266|       |
  267|  7.38k|	lst = opts->cdrv;
  268|  7.38k|	cp = &opts->ccount;
  269|       |
  270|   313k|	for (i = 0; i < *cp; i++) {
  ------------------
  |  Branch (270:14): [True: 306k, False: 7.38k]
  ------------------
  271|   306k|		free((void *)lst[i].name);
  272|   306k|	}
  273|  7.38k|	*cp = 0;
  274|  7.38k|}
ctx.c:process_config_file:
  705|  3.69k|{
  706|  3.69k|	int i, r, count = 0;
  707|  3.69k|	scconf_block **blocks;
  708|  3.69k|	const char *conf_path = NULL;
  709|  3.69k|	const char *debug = NULL;
  710|       |#ifdef _WIN32
  711|       |	char temp_path[PATH_MAX];
  712|       |	size_t temp_len;
  713|       |#endif
  714|       |
  715|       |	/* Takes effect even when no config around */
  716|  3.69k|	debug = getenv("OPENSC_DEBUG");
  717|  3.69k|	if (debug)
  ------------------
  |  Branch (717:6): [True: 0, False: 3.69k]
  ------------------
  718|      0|		ctx->debug = atoi(debug);
  719|       |
  720|  3.69k|	memset(ctx->conf_blocks, 0, sizeof(ctx->conf_blocks));
  721|       |#ifdef _WIN32
  722|       |	temp_len = PATH_MAX-1;
  723|       |	r = sc_ctx_win32_get_config_value("OPENSC_CONF", "ConfigFile", "Software\\" OPENSC_VS_FF_COMPANY_NAME "\\OpenSC" OPENSC_ARCH_SUFFIX,
  724|       |			temp_path, &temp_len);
  725|       |	if (r)   {
  726|       |		sc_log(ctx, "process_config_file doesn't find opensc config file. Please set the registry key.");
  727|       |		return;
  728|       |	}
  729|       |	temp_path[temp_len] = '\0';
  730|       |	conf_path = temp_path;
  731|       |#else
  732|  3.69k|	conf_path = getenv("OPENSC_CONF");
  733|  3.69k|	if (!conf_path)
  ------------------
  |  Branch (733:6): [True: 3.69k, False: 0]
  ------------------
  734|  3.69k|		conf_path = OPENSC_CONF_PATH;
  735|  3.69k|#endif
  736|  3.69k|	ctx->conf = scconf_new(conf_path);
  737|  3.69k|	if (ctx->conf == NULL)
  ------------------
  |  Branch (737:6): [True: 0, False: 3.69k]
  ------------------
  738|      0|		return;
  739|  3.69k|	r = scconf_parse(ctx->conf);
  740|  3.69k|#define OPENSC_CONFIG_STRING "app default { card_drivers = old, internal; }"
  741|  3.69k|#ifdef OPENSC_CONFIG_STRING
  742|       |	/* Parse the string if config file didn't exist */
  743|  3.69k|	if (r < 0)
  ------------------
  |  Branch (743:6): [True: 3.69k, False: 0]
  ------------------
  744|  3.69k|		r = scconf_parse_string(ctx->conf, OPENSC_CONFIG_STRING);
  ------------------
  |  |  740|  3.69k|#define OPENSC_CONFIG_STRING "app default { card_drivers = old, internal; }"
  ------------------
  745|  3.69k|#endif
  746|  3.69k|	if (r < 1) {
  ------------------
  |  Branch (746:6): [True: 0, False: 3.69k]
  ------------------
  747|       |		/* A negative return value means the config file isn't
  748|       |		 * there, which is not an error. Nevertheless log this
  749|       |		 * fact. */
  750|      0|		if (r < 0)
  ------------------
  |  Branch (750:7): [True: 0, False: 0]
  ------------------
  751|      0|			sc_log(ctx, "scconf_parse failed: %s", ctx->conf->errmsg);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  752|      0|		else
  753|      0|			sc_log(ctx, "scconf_parse failed: %s", ctx->conf->errmsg);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  754|      0|		scconf_free(ctx->conf);
  755|      0|		ctx->conf = NULL;
  756|      0|		return;
  757|      0|	}
  758|       |	/* needs to be after the log file is known */
  759|  3.69k|	sc_log(ctx, "Used configuration file '%s'", conf_path);
  ------------------
  |  |   71|  3.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__
  |  |  ------------------
  ------------------
  760|  3.69k|	blocks = scconf_find_blocks(ctx->conf, NULL, "app", ctx->exe_path);
  761|  3.69k|	if (blocks && blocks[0])
  ------------------
  |  Branch (761:6): [True: 3.69k, False: 0]
  |  Branch (761:16): [True: 0, False: 3.69k]
  ------------------
  762|      0|		ctx->conf_blocks[count++] = blocks[0];
  763|  3.69k|	free(blocks);
  764|  3.69k|	blocks = scconf_find_blocks(ctx->conf, NULL, "app", ctx->app_name);
  765|  3.69k|	if (blocks && blocks[0])
  ------------------
  |  Branch (765:6): [True: 3.69k, False: 0]
  |  Branch (765:16): [True: 0, False: 3.69k]
  ------------------
  766|      0|		ctx->conf_blocks[count++] = blocks[0];
  767|  3.69k|	free(blocks);
  768|  3.69k|	if (strcmp(ctx->app_name, "default") != 0) {
  ------------------
  |  Branch (768:6): [True: 3.69k, False: 0]
  ------------------
  769|  3.69k|		blocks = scconf_find_blocks(ctx->conf, NULL, "app", "default");
  770|  3.69k|		if (blocks && blocks[0])
  ------------------
  |  Branch (770:7): [True: 3.69k, False: 0]
  |  Branch (770:17): [True: 3.69k, False: 0]
  ------------------
  771|  3.69k|			ctx->conf_blocks[count] = blocks[0];
  772|  3.69k|		free(blocks);
  773|  3.69k|	}
  774|       |	/* Above we add 3 blocks at most, but conf_blocks has 4 elements,
  775|       |	 * so at least one is NULL */
  776|  7.38k|	for (i = 0; ctx->conf_blocks[i]; i++)
  ------------------
  |  Branch (776:14): [True: 3.69k, False: 3.69k]
  ------------------
  777|  3.69k|		load_parameters(ctx, ctx->conf_blocks[i], opts);
  778|  3.69k|}
ctx.c:load_parameters:
  384|  3.69k|{
  385|  3.69k|	int err = 0;
  386|  3.69k|	const scconf_list *list;
  387|  3.69k|	const char *val;
  388|  3.69k|	int debug;
  389|  3.69k|	const char *disable_hw_pkcs1_padding;
  390|       |#ifdef _WIN32
  391|       |	char expanded_val[PATH_MAX];
  392|       |	DWORD expanded_len;
  393|       |#endif
  394|       |
  395|  3.69k|	debug = scconf_get_int(block, "debug", ctx->debug);
  396|  3.69k|	if (debug > ctx->debug)
  ------------------
  |  Branch (396:6): [True: 0, False: 3.69k]
  ------------------
  397|      0|		ctx->debug = debug;
  398|       |
  399|  3.69k|	val = scconf_get_str(block, "debug_file", NULL);
  400|  3.69k|	if (val)   {
  ------------------
  |  Branch (400:6): [True: 0, False: 3.69k]
  ------------------
  401|       |#ifdef _WIN32
  402|       |		expanded_len = PATH_MAX;
  403|       |		expanded_len = ExpandEnvironmentStringsA(val, expanded_val, expanded_len);
  404|       |		if (0 < expanded_len && expanded_len < sizeof expanded_val)
  405|       |			val = expanded_val;
  406|       |#endif
  407|      0|		sc_ctx_log_to_file(ctx, val);
  408|      0|	}
  409|  3.69k|	else if (ctx->debug)   {
  ------------------
  |  Branch (409:11): [True: 0, False: 3.69k]
  ------------------
  410|      0|		sc_ctx_log_to_file(ctx, NULL);
  411|      0|	}
  412|       |
  413|  3.69k|	if (scconf_get_bool (block, "disable_popups",
  ------------------
  |  Branch (413:6): [True: 0, False: 3.69k]
  ------------------
  414|  3.69k|				ctx->flags & SC_CTX_FLAG_DISABLE_POPUPS))
  ------------------
  |  |  868|  3.69k|#define SC_CTX_FLAG_DISABLE_POPUPS			0x00000010
  ------------------
  415|      0|		ctx->flags |= SC_CTX_FLAG_DISABLE_POPUPS;
  ------------------
  |  |  868|      0|#define SC_CTX_FLAG_DISABLE_POPUPS			0x00000010
  ------------------
  416|       |
  417|  3.69k|	if (scconf_get_bool (block, "disable_colors",
  ------------------
  |  Branch (417:6): [True: 0, False: 3.69k]
  ------------------
  418|  3.69k|				ctx->flags & SC_CTX_FLAG_DISABLE_COLORS))
  ------------------
  |  |  869|  3.69k|#define SC_CTX_FLAG_DISABLE_COLORS			0x00000020
  ------------------
  419|      0|		ctx->flags |= SC_CTX_FLAG_DISABLE_COLORS;
  ------------------
  |  |  869|      0|#define SC_CTX_FLAG_DISABLE_COLORS			0x00000020
  ------------------
  420|       |
  421|  3.69k|	if (scconf_get_bool (block, "enable_default_driver",
  ------------------
  |  Branch (421:6): [True: 0, False: 3.69k]
  ------------------
  422|  3.69k|				ctx->flags & SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER))
  ------------------
  |  |  867|  3.69k|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  423|      0|		ctx->flags |= SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER;
  ------------------
  |  |  867|      0|#define SC_CTX_FLAG_ENABLE_DEFAULT_DRIVER	0x00000008
  ------------------
  424|       |
  425|  3.69k|	list = scconf_find_list(block, "card_drivers");
  426|  3.69k|	set_drivers(opts, list);
  427|       |
  428|       |	/* Disable PKCS#1 v1.5 type 2 (for decryption) depadding on card by default */
  429|  3.69k|	disable_hw_pkcs1_padding = "decipher";
  430|  3.69k|	ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  119|  3.69k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  431|  3.69k|	disable_hw_pkcs1_padding = scconf_get_str(block, "disable_hw_pkcs1_padding", disable_hw_pkcs1_padding);
  432|  3.69k|	if (0 == strcmp(disable_hw_pkcs1_padding, "no")) {
  ------------------
  |  Branch (432:6): [True: 0, False: 3.69k]
  ------------------
  433|      0|		ctx->disable_hw_pkcs1_padding = 0;
  434|  3.69k|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "sign")) {
  ------------------
  |  Branch (434:13): [True: 0, False: 3.69k]
  ------------------
  435|      0|		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01;
  ------------------
  |  |  118|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
  436|  3.69k|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "decipher")) {
  ------------------
  |  Branch (436:13): [True: 3.69k, False: 0]
  ------------------
  437|  3.69k|		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  119|  3.69k|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  438|  3.69k|	} else if (0 == strcmp(disable_hw_pkcs1_padding, "both")) {
  ------------------
  |  Branch (438:13): [True: 0, False: 0]
  ------------------
  439|      0|		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  118|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01	0x00000040 /* PKCS#1 v1.5 padding type 1 */
  ------------------
              		ctx->disable_hw_pkcs1_padding = SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_01 | SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02;
  ------------------
  |  |  119|      0|#define SC_ALGORITHM_RSA_PAD_PKCS1_TYPE_02	0x00000080 /* PKCS#1 v1.5 padding type 2 */
  ------------------
  440|      0|	}
  441|       |
  442|       |#ifdef USE_OPENSSL3_LIBCTX
  443|       |	val = scconf_get_str(block, "openssl_config", NULL);
  444|       |	if (val != NULL) {
  445|       |		ctx->openssl_config = strdup(val);
  446|       |	}
  447|       |#endif
  448|       |
  449|  3.69k|	return err;
  450|  3.69k|}
ctx.c:set_drivers:
  367|  3.69k|{
  368|  3.69k|	const char *s_internal = "internal", *s_old = "old";
  369|  3.69k|	if (list != NULL)
  ------------------
  |  Branch (369:6): [True: 3.69k, False: 0]
  ------------------
  370|  3.69k|		del_drvs(opts);
  371|  11.0k|	while (list != NULL) {
  ------------------
  |  Branch (371:9): [True: 7.38k, False: 3.69k]
  ------------------
  372|  7.38k|		if (strcmp(list->data, s_internal) == 0)
  ------------------
  |  Branch (372:7): [True: 3.69k, False: 3.69k]
  ------------------
  373|  3.69k|			add_internal_drvs(opts);
  374|  3.69k|		else if (strcmp(list->data, s_old) == 0)
  ------------------
  |  Branch (374:12): [True: 3.69k, False: 0]
  ------------------
  375|  3.69k|			add_old_drvs(opts);
  376|      0|		else
  377|      0|			add_drv(opts, list->data);
  378|  7.38k|		list = list->next;
  379|  7.38k|	}
  380|  3.69k|}
ctx.c:add_old_drvs:
  308|  3.69k|{
  309|  3.69k|	const struct _sc_driver_entry *lst;
  310|  3.69k|	int i;
  311|       |
  312|  3.69k|	lst = old_card_drivers;
  313|  3.69k|	i = 0;
  314|  22.1k|	while (lst[i].name != NULL) {
  ------------------
  |  Branch (314:9): [True: 18.4k, False: 3.69k]
  ------------------
  315|  18.4k|		add_drv(opts, lst[i].name);
  316|  18.4k|		i++;
  317|  18.4k|	}
  318|  3.69k|}
ctx.c:load_card_drivers:
  563|  3.69k|{
  564|  3.69k|	const struct _sc_driver_entry *ent;
  565|  3.69k|	int drv_count;
  566|  3.69k|	int i;
  567|       |
  568|  3.69k|	for (drv_count = 0; ctx->card_drivers[drv_count] != NULL; drv_count++)
  ------------------
  |  Branch (568:22): [True: 0, False: 3.69k]
  ------------------
  569|      0|		;
  570|       |
  571|   166k|	for (i = 0; i < opts->ccount; i++) {
  ------------------
  |  Branch (571:14): [True: 162k, False: 3.69k]
  ------------------
  572|   162k|		struct sc_card_driver *(*func)(void) = NULL;
  573|   162k|		struct sc_card_driver *(**tfunc)(void) = &func;
  574|   162k|		void *dll = NULL;
  575|   162k|		int  j;
  576|       |
  577|   162k|		if (drv_count >= SC_MAX_CARD_DRIVERS - 1)   {
  ------------------
  |  |   31|   162k|#define SC_MAX_CARD_DRIVERS		48
  ------------------
  |  Branch (577:7): [True: 0, False: 162k]
  ------------------
  578|      0|			sc_log(ctx, "Not more then %i card drivers allowed.", SC_MAX_CARD_DRIVERS);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  578|      0|			sc_log(ctx, "Not more then %i card drivers allowed.", SC_MAX_CARD_DRIVERS);
  |  |  |  |  ------------------
  |  |  |  |  |  |   31|      0|#define SC_MAX_CARD_DRIVERS		48
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  579|      0|			break;
  580|      0|		}
  581|       |
  582|   162k|		ent = &opts->cdrv[i];
  583|  3.62M|		for (j = 0; internal_card_drivers[j].name != NULL; j++) {
  ------------------
  |  Branch (583:15): [True: 3.60M, False: 18.4k]
  ------------------
  584|  3.60M|			if (strcmp(ent->name, internal_card_drivers[j].name) == 0) {
  ------------------
  |  Branch (584:8): [True: 144k, False: 3.45M]
  ------------------
  585|   144k|				func = (struct sc_card_driver *(*)(void)) internal_card_drivers[j].func;
  586|   144k|				break;
  587|   144k|			}
  588|  3.60M|		}
  589|   162k|		if (func == NULL) {
  ------------------
  |  Branch (589:7): [True: 18.4k, False: 144k]
  ------------------
  590|  55.4k|			for (j = 0; old_card_drivers[j].name != NULL; j++) {
  ------------------
  |  Branch (590:16): [True: 55.4k, False: 0]
  ------------------
  591|  55.4k|				if (strcmp(ent->name, old_card_drivers[j].name) == 0) {
  ------------------
  |  Branch (591:9): [True: 18.4k, False: 36.9k]
  ------------------
  592|  18.4k|					func = (struct sc_card_driver *(*)(void)) old_card_drivers[j].func;
  593|  18.4k|					break;
  594|  18.4k|				}
  595|  55.4k|			}
  596|  18.4k|		}
  597|       |		/* if not initialized assume external module */
  598|   162k|		if (func == NULL)
  ------------------
  |  Branch (598:7): [True: 0, False: 162k]
  ------------------
  599|      0|			*(void **)(tfunc) = load_dynamic_driver(ctx, &dll, ent->name);
  600|       |		/* if still null, assume driver not found */
  601|   162k|		if (func == NULL) {
  ------------------
  |  Branch (601:7): [True: 0, False: 162k]
  ------------------
  602|      0|			sc_log(ctx, "Unable to load '%s'.", ent->name);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  603|      0|			if (dll)
  ------------------
  |  Branch (603:8): [True: 0, False: 0]
  ------------------
  604|      0|				sc_dlclose(dll);
  605|      0|			continue;
  606|      0|		}
  607|       |
  608|   162k|		ctx->card_drivers[drv_count] = func();
  609|   162k|		if (ctx->card_drivers[drv_count] == NULL) {
  ------------------
  |  Branch (609:7): [True: 0, False: 162k]
  ------------------
  610|      0|			sc_log(ctx, "Driver '%s' not available.", ent->name);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  611|      0|			continue;
  612|      0|		}
  613|       |
  614|   162k|		ctx->card_drivers[drv_count]->dll = dll;
  615|   162k|		ctx->card_drivers[drv_count]->atr_map = NULL;
  616|   162k|		ctx->card_drivers[drv_count]->natrs = 0;
  617|       |
  618|   162k|		load_card_driver_options(ctx, ctx->card_drivers[drv_count]);
  619|       |
  620|       |		/* Ensure that the list is always terminated by NULL */
  621|   162k|		ctx->card_drivers[drv_count + 1] = NULL;
  622|       |
  623|   162k|		drv_count++;
  624|   162k|	}
  625|  3.69k|	return SC_SUCCESS;
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
  626|  3.69k|}
ctx.c:load_card_driver_options:
  542|   162k|{
  543|   162k|	scconf_block **blocks, *blk;
  544|   162k|	int i;
  545|       |
  546|   325k|	for (i = 0; ctx->conf_blocks[i]; i++) {
  ------------------
  |  Branch (546:14): [True: 162k, False: 162k]
  ------------------
  547|   162k|		blocks = scconf_find_blocks(ctx->conf, ctx->conf_blocks[i],
  548|   162k|				"card_driver", driver->short_name);
  549|   162k|		if (!blocks)
  ------------------
  |  Branch (549:7): [True: 0, False: 162k]
  ------------------
  550|      0|			continue;
  551|   162k|		blk = blocks[0];
  552|   162k|		free(blocks);
  553|       |
  554|   162k|		if (blk == NULL)
  ------------------
  |  Branch (554:7): [True: 162k, False: 0]
  ------------------
  555|   162k|			continue;
  556|       |
  557|       |		/* no options at the moment */
  558|   162k|	}
  559|   162k|	return SC_SUCCESS;
  ------------------
  |  |   28|   162k|#define SC_SUCCESS				0
  ------------------
  560|   162k|}

sc_enum_apps:
  163|  2.81k|{
  164|  2.81k|	struct sc_context *ctx = card->ctx;
  165|  2.81k|	sc_path_t path;
  166|  2.81k|	int ef_structure;
  167|  2.81k|	size_t file_size, jj;
  168|  2.81k|	int r, ii, idx;
  169|  2.81k|	struct sc_file *ef_dir = NULL;
  170|       |
  171|  2.81k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.81k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.81k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.81k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.81k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  172|       |
  173|  2.81k|	sc_free_apps(card);
  174|  2.81k|	card->app_count = 0;
  175|       |
  176|  2.81k|	sc_format_path("3F002F00", &path);
  177|  2.81k|	r = sc_select_file(card, &path, &ef_dir);
  178|  2.81k|	if (r < 0)
  ------------------
  |  Branch (178:6): [True: 2.53k, False: 282]
  ------------------
  179|  2.53k|		sc_file_free(ef_dir);
  180|  2.81k|	LOG_TEST_RET(ctx, r, "Cannot select EF.DIR file");
  ------------------
  |  |  174|  2.81k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.81k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.81k|	int _ret = (r); \
  |  |  |  |  168|  2.81k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.53k, False: 282]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.53k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.53k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.53k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.53k|		return _ret; \
  |  |  |  |  172|  2.53k|	} \
  |  |  |  |  173|  2.81k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 282]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  181|       |
  182|    282|	if (ef_dir->type != SC_FILE_TYPE_WORKING_EF) {
  ------------------
  |  |  216|    282|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (182:6): [True: 79, False: 203]
  ------------------
  183|     79|		sc_file_free(ef_dir);
  184|     79|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_CARD, "EF(DIR) is not a working EF.");
  ------------------
  |  |  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: 79, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     79|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     79|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     79|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     79|		return _ret; \
  |  |  |  |  172|     79|	} \
  |  |  |  |  173|     79|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|     79|	}
  186|       |
  187|    203|	ef_structure = ef_dir->ef_structure;
  188|    203|	file_size = ef_dir->size;
  189|    203|	sc_file_free(ef_dir);
  190|    203|	if (ef_structure == SC_FILE_EF_TRANSPARENT) {
  ------------------
  |  |  221|    203|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (190:6): [True: 158, False: 45]
  ------------------
  191|    158|		u8 *buf = NULL, *p;
  192|    158|		size_t bufsize;
  193|       |
  194|    158|		if (file_size == 0)
  ------------------
  |  Branch (194:7): [True: 6, False: 152]
  ------------------
  195|    158|			LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|    152|		if (file_size > MAX_FILE_SIZE)
  ------------------
  |  |  229|    152|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (196:7): [True: 0, False: 152]
  ------------------
  197|    152|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|       |
  199|    152|		buf = malloc(file_size);
  200|    152|		if (buf == NULL)
  ------------------
  |  Branch (200:7): [True: 0, False: 152]
  ------------------
  201|    152|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  202|    152|		p = buf;
  203|    152|		r = sc_read_binary(card, 0, buf, file_size, 0);
  204|    152|		if (r < 0) {
  ------------------
  |  Branch (204:7): [True: 28, False: 124]
  ------------------
  205|     28|			free(buf);
  206|     28|			LOG_TEST_RET(ctx, r, "sc_read_binary() 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|     28|		}
  208|    124|		bufsize = r;
  209|    144|		while (bufsize > 0) {
  ------------------
  |  Branch (209:10): [True: 96, False: 48]
  ------------------
  210|     96|			if (card->app_count == SC_MAX_CARD_APPS) {
  ------------------
  |  |   33|     96|#define SC_MAX_CARD_APPS		8
  ------------------
  |  Branch (210:8): [True: 0, False: 96]
  ------------------
  211|      0|				sc_log(ctx, "Too many applications on 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__
  |  |  ------------------
  ------------------
  212|      0|				break;
  213|      0|			}
  214|     96|			r = parse_dir_record(card, &p, &bufsize, -1);
  215|     96|			if (r)
  ------------------
  |  Branch (215:8): [True: 76, False: 20]
  ------------------
  216|     76|				break;
  217|     96|		}
  218|    124|		if (buf)
  ------------------
  |  Branch (218:7): [True: 124, False: 0]
  ------------------
  219|    124|			free(buf);
  220|       |
  221|    124|	}
  222|     45|	else {	/* record structure */
  223|     45|		unsigned char buf[256], *p;
  224|     45|		unsigned int rec_nr;
  225|     45|		size_t rec_size;
  226|       |
  227|       |		/* Arbitrary set '16' as maximal number of records to check out:
  228|       |		 * to avoid endless loop because of some incomplete cards/drivers */
  229|    257|		for (rec_nr = 1; rec_nr < 16; rec_nr++) {
  ------------------
  |  Branch (229:20): [True: 255, False: 2]
  ------------------
  230|    255|			r = sc_read_record(card, rec_nr, 0, buf, sizeof(buf), SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1305|    255|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  231|    255|			if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|    255|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (231:8): [True: 0, False: 255]
  ------------------
  232|      0|				break;
  233|    255|			LOG_TEST_RET(ctx, r, "read_record() failed");
  ------------------
  |  |  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: 43, False: 212]
  |  |  |  |  ------------------
  |  |  |  |  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|    255|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 212]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  234|       |
  235|    212|			if (card->app_count == SC_MAX_CARD_APPS) {
  ------------------
  |  |   33|    212|#define SC_MAX_CARD_APPS		8
  ------------------
  |  Branch (235:8): [True: 0, False: 212]
  ------------------
  236|      0|				sc_log(ctx, "Too many applications on 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__
  |  |  ------------------
  ------------------
  237|      0|				break;
  238|      0|			}
  239|       |
  240|    212|			rec_size = r;
  241|    212|			p = buf;
  242|    212|			parse_dir_record(card, &p, &rec_size, (int)rec_nr);
  243|    212|		}
  244|     45|	}
  245|       |
  246|       |	/* Move known PKCS#15 applications to the head of the list */
  247|    147|	for (ii=0, idx=0; ii<card->app_count; ii++)   {
  ------------------
  |  Branch (247:20): [True: 21, False: 126]
  ------------------
  248|    165|		for (jj=0; jj < sizeof(apps)/sizeof(apps[0]); jj++) {
  ------------------
  |  Branch (248:14): [True: 149, False: 16]
  ------------------
  249|    149|			if (apps[jj].aid_len != card->app[ii]->aid.len)
  ------------------
  |  Branch (249:8): [True: 124, False: 25]
  ------------------
  250|    124|				continue;
  251|     25|			if (memcmp(apps[jj].aid, card->app[ii]->aid.value, apps[jj].aid_len))
  ------------------
  |  Branch (251:8): [True: 20, False: 5]
  ------------------
  252|     20|				continue;
  253|      5|			break;
  254|     25|		}
  255|       |
  256|     21|		if (ii != idx && jj < sizeof(apps)/sizeof(apps[0]))   {
  ------------------
  |  Branch (256:7): [True: 16, False: 5]
  |  Branch (256:20): [True: 5, False: 11]
  ------------------
  257|      5|			struct sc_app_info *tmp = card->app[idx];
  258|       |
  259|      5|			card->app[idx] = card->app[ii];
  260|      5|			card->app[ii] = tmp;
  261|      5|			idx++;
  262|      5|		}
  263|     21|	}
  264|       |
  265|    126|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  266|    126|}
sc_free_apps:
  269|  6.68k|{
  270|  6.68k|	int	i;
  271|       |
  272|  6.79k|	for (i = 0; i < card->app_count; i++) {
  ------------------
  |  Branch (272:14): [True: 105, False: 6.68k]
  ------------------
  273|    105|		free(card->app[i]->label);
  274|    105|		free(card->app[i]->ddo.value);
  275|    105|		free(card->app[i]);
  276|    105|	}
  277|  6.68k|	card->app_count = -1;
  278|  6.68k|}
sc_update_dir:
  402|     69|{
  403|     69|	sc_path_t path;
  404|     69|	sc_file_t *file;
  405|     69|	int r;
  406|       |
  407|     69|	sc_format_path("3F002F00", &path);
  408|       |
  409|     69|	r = sc_select_file(card, &path, &file);
  410|     69|	LOG_TEST_RET(card->ctx, r, "unable to select EF(DIR)");
  ------------------
  |  |  174|     69|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     69|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     69|	int _ret = (r); \
  |  |  |  |  168|     69|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 7, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  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|     69|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  411|       |
  412|     62|	if (file->ef_structure == SC_FILE_EF_TRANSPARENT)
  ------------------
  |  |  221|     62|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  |  Branch (412:6): [True: 59, False: 3]
  ------------------
  413|     59|		r = update_transparent(card, file);
  414|      3|	else if (app == NULL)
  ------------------
  |  Branch (414:11): [True: 3, False: 0]
  ------------------
  415|      3|		r = update_records(card);
  416|      0|	else
  417|      0|		r = update_single_record(card, app);
  418|     62|	sc_file_free(file);
  419|     62|	return r;
  420|     69|}
dir.c:parse_dir_record:
   65|    308|{
   66|    308|	struct sc_context *ctx = card->ctx;
   67|    308|	struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2];
   68|    308|	scconf_block *conf_block = NULL;
   69|    308|	sc_app_info_t *app = NULL;
   70|    308|	struct sc_aid aid;
   71|    308|	u8 label[128], path[128], ddo[128];
   72|    308|	size_t label_len = sizeof(label) - 1, path_len = sizeof(path), ddo_len = sizeof(ddo);
   73|    308|	int r;
   74|       |
   75|    308|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    308|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    308|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    308|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    308|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 308]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   76|    308|	aid.len = sizeof(aid.value);
   77|       |
   78|    308|	memset(label, 0, sizeof(label));
   79|    308|	sc_copy_asn1_entry(c_asn1_dirrecord, asn1_dirrecord);
   80|    308|	sc_copy_asn1_entry(c_asn1_dir, asn1_dir);
   81|    308|	sc_format_asn1_entry(asn1_dir + 0, asn1_dirrecord, NULL, 0);
   82|    308|	sc_format_asn1_entry(asn1_dirrecord + 0, aid.value, &aid.len, 0);
   83|    308|	sc_format_asn1_entry(asn1_dirrecord + 1, label, &label_len, 0);
   84|    308|	sc_format_asn1_entry(asn1_dirrecord + 2, path, &path_len, 0);
   85|    308|	sc_format_asn1_entry(asn1_dirrecord + 3, ddo, &ddo_len, 0);
   86|       |
   87|    308|	r = sc_asn1_decode(ctx, asn1_dir, *buf, *buflen, (const u8 **) buf, buflen);
   88|    308|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|    308|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (88:6): [True: 97, False: 211]
  ------------------
   89|    308|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|     97|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     97|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     97|	int _ret = r; \
  |  |  |  |  155|     97|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 97, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     97|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     97|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 97, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|     97|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     97|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     97|	return _ret; \
  |  |  |  |  163|     97|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   90|    211|	LOG_TEST_RET(ctx, r, "EF(DIR) parsing 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: 175, False: 36]
  |  |  |  |  ------------------
  |  |  |  |  169|    175|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    175|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    175|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    175|		return _ret; \
  |  |  |  |  172|    175|	} \
  |  |  |  |  173|    211|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 36]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|       |
   92|     36|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
   93|     36|	if (conf_block)   {
  ------------------
  |  Branch (93:6): [True: 0, False: 36]
  ------------------
   94|      0|		scconf_block **blocks = NULL;
   95|      0|		char aid_str[SC_MAX_AID_STRING_SIZE];
   96|      0|		int ignore_app = 0;
   97|       |
   98|      0|		sc_bin_to_hex(aid.value, aid.len, aid_str, sizeof(aid_str), 0);
   99|      0|		blocks = scconf_find_blocks(card->ctx->conf, conf_block, "application", aid_str);
  100|      0|		if (blocks)   {
  ------------------
  |  Branch (100:7): [True: 0, False: 0]
  ------------------
  101|      0|			ignore_app = (blocks[0] && scconf_get_bool(blocks[0], "disable", 0));
  ------------------
  |  Branch (101:18): [True: 0, False: 0]
  |  Branch (101:31): [True: 0, False: 0]
  ------------------
  102|      0|			free(blocks);
  103|      0|		 }
  104|       |
  105|      0|		if (ignore_app)   {
  ------------------
  |  Branch (105:7): [True: 0, False: 0]
  ------------------
  106|      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__
  |  |  ------------------
  ------------------
  107|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  108|      0|		}
  109|      0|	}
  110|       |
  111|     36|	app = calloc(1, sizeof(struct sc_app_info));
  112|     36|	if (app == NULL)
  ------------------
  |  Branch (112:6): [True: 0, False: 36]
  ------------------
  113|     36|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  114|       |
  115|     36|	memcpy(&app->aid, &aid, sizeof(struct sc_aid));
  116|       |
  117|     36|	if (asn1_dirrecord[1].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|     36|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (117:6): [True: 5, False: 31]
  ------------------
  118|      5|		app->label = strdup((char *) label);
  119|     31|	else
  120|     31|		app->label = NULL;
  121|       |
  122|     36|	if (asn1_dirrecord[2].flags & SC_ASN1_PRESENT && path_len > 0) {
  ------------------
  |  |  147|     72|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (122:6): [True: 0, False: 36]
  |  Branch (122:51): [True: 0, False: 0]
  ------------------
  123|       |		/* application path present: ignore AID */
  124|      0|		if (path_len > SC_MAX_PATH_SIZE) {
  ------------------
  |  |   47|      0|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (124:7): [True: 0, False: 0]
  ------------------
  125|      0|			free(app->label);
  126|      0|			free(app);
  127|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "Application path is too long.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|      0|		}
  129|      0|		memcpy(app->path.value, path, path_len);
  130|      0|		app->path.len = path_len;
  131|      0|		app->path.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
  132|      0|	}
  133|     36|	else {
  134|       |		/* application path not present: use AID as application path */
  135|     36|		memcpy(app->path.value, aid.value, aid.len);
  136|     36|		app->path.len = aid.len;
  137|     36|		app->path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|     36|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  138|     36|	}
  139|       |
  140|     36|	if (asn1_dirrecord[3].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     36|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (140:6): [True: 8, False: 28]
  ------------------
  141|      8|		app->ddo.value = malloc(ddo_len);
  142|      8|		if (app->ddo.value == NULL) {
  ------------------
  |  Branch (142:7): [True: 0, False: 8]
  ------------------
  143|      0|			free(app->label);
  144|      0|			free(app);
  145|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  146|      0|		}
  147|      8|		memcpy(app->ddo.value, ddo, ddo_len);
  148|      8|		app->ddo.len = ddo_len;
  149|     28|	} else {
  150|     28|		app->ddo.value = NULL;
  151|     28|		app->ddo.len = 0;
  152|     28|	}
  153|       |
  154|     36|	app->rec_nr = rec_nr;
  155|     36|	card->app[card->app_count] = app;
  156|     36|	card->app_count++;
  157|       |
  158|     36|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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: 36, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 36]
  |  |  |  |  ------------------
  |  |  |  |  157|     36|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     36|	} else { \
  |  |  |  |  159|      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|	return _ret; \
  |  |  |  |  163|     36|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|     36|}
dir.c:update_transparent:
  309|     59|{
  310|     59|	u8 *rec, *buf = NULL, *tmp;
  311|     59|	size_t rec_size, buf_size = 0;
  312|     59|	int i, r;
  313|       |
  314|    117|	for (i = 0; i < card->app_count; i++) {
  ------------------
  |  Branch (314:14): [True: 59, False: 58]
  ------------------
  315|     59|		r = encode_dir_record(card->ctx, card->app[i], &rec, &rec_size);
  316|     59|		if (r) {
  ------------------
  |  Branch (316:7): [True: 1, False: 58]
  ------------------
  317|      1|			if (buf)
  ------------------
  |  Branch (317:8): [True: 0, False: 1]
  ------------------
  318|      0|				free(buf);
  319|      1|			return r;
  320|      1|		}
  321|     58|		if (!rec_size)
  ------------------
  |  Branch (321:7): [True: 0, False: 58]
  ------------------
  322|      0|			continue;
  323|     58|		tmp = (u8 *) realloc(buf, buf_size + rec_size);
  324|     58|		if (!tmp) {
  ------------------
  |  Branch (324:7): [True: 0, False: 58]
  ------------------
  325|      0|			if (rec)
  ------------------
  |  Branch (325:8): [True: 0, False: 0]
  ------------------
  326|      0|				free(rec);
  327|      0|			if (buf)
  ------------------
  |  Branch (327:8): [True: 0, False: 0]
  ------------------
  328|      0|				free(buf);
  329|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  330|      0|		}
  331|     58|		buf = tmp;
  332|     58|		memcpy(buf + buf_size, rec, rec_size);
  333|     58|		buf_size += rec_size;
  334|     58|		free(rec);
  335|     58|		rec=NULL;
  336|     58|	}
  337|     58|	if (file->size > buf_size) {
  ------------------
  |  Branch (337:6): [True: 33, False: 25]
  ------------------
  338|     33|		tmp = (u8 *) realloc(buf, file->size);
  339|     33|		if (!tmp) {
  ------------------
  |  Branch (339:7): [True: 0, False: 33]
  ------------------
  340|      0|			free(buf);
  341|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  342|      0|		}
  343|     33|		buf = tmp;
  344|     33|		memset(buf + buf_size, 0, file->size - buf_size);
  345|     33|		buf_size = file->size;
  346|     33|	}
  347|     58|	r = sc_update_binary(card, 0, buf, buf_size, 0);
  348|     58|	free(buf);
  349|     58|	LOG_TEST_RET(card->ctx, r, "Unable to update EF(DIR)");
  ------------------
  |  |  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: 28, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  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|     58|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  350|       |
  351|     30|	return SC_SUCCESS;
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  352|     58|}
dir.c:encode_dir_record:
  282|     62|{
  283|     62|	struct sc_asn1_entry asn1_dirrecord[5], asn1_dir[2];
  284|     62|	sc_app_info_t   tapp = *app;
  285|     62|	int r;
  286|     62|	size_t label_len;
  287|       |
  288|     62|	sc_copy_asn1_entry(c_asn1_dirrecord, asn1_dirrecord);
  289|     62|	sc_copy_asn1_entry(c_asn1_dir, asn1_dir);
  290|     62|	sc_format_asn1_entry(asn1_dir + 0, asn1_dirrecord, NULL, 1);
  291|     62|	sc_format_asn1_entry(asn1_dirrecord + 0, (void *) tapp.aid.value, (void *) &tapp.aid.len, 1);
  292|     62|	if (tapp.label != NULL) {
  ------------------
  |  Branch (292:6): [True: 62, False: 0]
  ------------------
  293|     62|		label_len = strlen(tapp.label);
  294|     62|		sc_format_asn1_entry(asn1_dirrecord + 1, tapp.label, &label_len, 1);
  295|     62|	}
  296|     62|	if (tapp.path.len)
  ------------------
  |  Branch (296:6): [True: 62, False: 0]
  ------------------
  297|     62|		sc_format_asn1_entry(asn1_dirrecord + 2, (void *) tapp.path.value,
  298|     62|				     (void *) &tapp.path.len, 1);
  299|     62|	if (tapp.ddo.value != NULL && tapp.ddo.len)
  ------------------
  |  Branch (299:6): [True: 0, False: 62]
  |  Branch (299:32): [True: 0, False: 0]
  ------------------
  300|      0|		sc_format_asn1_entry(asn1_dirrecord + 3, (void *) tapp.ddo.value,
  301|      0|				     (void *) &tapp.ddo.len, 1);
  302|     62|	r = sc_asn1_encode(ctx, asn1_dir, buf, buflen);
  303|     62|	LOG_TEST_RET(ctx, r, "Encode DIR record error");
  ------------------
  |  |  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: 2, False: 60]
  |  |  |  |  ------------------
  |  |  |  |  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|     62|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 60]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  304|       |
  305|     60|	return SC_SUCCESS;
  ------------------
  |  |   28|     60|#define SC_SUCCESS				0
  ------------------
  306|     62|}
dir.c:update_records:
  390|      3|{
  391|      3|	int i, r;
  392|       |
  393|      3|	for (i = 0; i < card->app_count; i++) {
  ------------------
  |  Branch (393:14): [True: 3, False: 0]
  ------------------
  394|      3|		r = update_single_record(card, card->app[i]);
  395|      3|		if (r)
  ------------------
  |  Branch (395:7): [True: 3, False: 0]
  ------------------
  396|      3|			return r;
  397|      3|	}
  398|      0|	return 0;
  399|      3|}
dir.c:update_single_record:
  355|      3|{
  356|      3|	u8 *rec;
  357|      3|	size_t rec_size;
  358|      3|	int r;
  359|       |
  360|      3|	r = encode_dir_record(card->ctx, app, &rec, &rec_size);
  361|      3|	if (r)
  ------------------
  |  Branch (361:6): [True: 1, False: 2]
  ------------------
  362|      1|		return r;
  363|      2|	if (app->rec_nr > 0)
  ------------------
  |  Branch (363:6): [True: 0, False: 2]
  ------------------
  364|      0|		r = sc_update_record(card, (unsigned int)app->rec_nr, 0, rec, rec_size, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1305|      0|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  365|      2|	else if (app->rec_nr == 0) {
  ------------------
  |  Branch (365:11): [True: 2, False: 0]
  ------------------
  366|       |		/* create new record entry */
  367|      2|		r = sc_append_record(card, rec, rec_size, 0);
  368|      2|		if (r == SC_ERROR_NOT_SUPPORTED) {
  ------------------
  |  |   89|      2|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (368:7): [True: 2, False: 0]
  ------------------
  369|       |			/* if the card doesn't support APPEND RECORD we try a
  370|       |			 * UPDATE RECORD on the next unused record (and hope
  371|       |			 * that there is a record with this index).
  372|       |			 */
  373|      2|			int rec_nr = 0, i;
  374|      4|			for(i = 0; i < card->app_count; i++)
  ------------------
  |  Branch (374:15): [True: 2, False: 2]
  ------------------
  375|      2|				if (card->app[i]->rec_nr > rec_nr)
  ------------------
  |  Branch (375:9): [True: 0, False: 2]
  ------------------
  376|      0|					rec_nr = card->app[i]->rec_nr;
  377|      2|			rec_nr++;
  378|      2|			r = sc_update_record(card, (unsigned int)rec_nr, 0, rec, rec_size, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1305|      2|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  379|      2|		}
  380|      2|	} else {
  381|      0|		sc_log(card->ctx, "invalid record number\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__
  |  |  ------------------
  ------------------
  382|      0|		r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  383|      0|	}
  384|      2|	free(rec);
  385|      2|	LOG_TEST_RET(card->ctx, r, "Unable to update EF(DIR) record");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  386|      0|	return 0;
  387|      2|}

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

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

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

gp_select_aid:
   50|    510|{
   51|    510|	int rv;
   52|    510|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    510|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    510|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    510|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    510|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 510]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   53|    510|	rv = iso7816_select_aid(card, aid->value, aid->len, NULL, NULL);
   54|    510|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    510|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    510|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    510|	int _ret = r; \
  |  |  |  |  155|    510|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 510, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    510|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 482]
  |  |  |  |  ------------------
  |  |  |  |  157|    510|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    510|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    510|	return _ret; \
  |  |  |  |  163|    510|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   55|    510|}
gp_select_card_manager:
   60|    496|{
   61|    496|	int rv;
   62|       |
   63|    496|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    496|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    496|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    496|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    496|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 496]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|    496|	rv = gp_select_aid(card, &gp_card_manager);
   65|    496|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  164|    496|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    496|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    496|	int _ret = r; \
  |  |  |  |  155|    496|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 496, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    496|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 482]
  |  |  |  |  ------------------
  |  |  |  |  157|    496|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    496|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    496|	return _ret; \
  |  |  |  |  163|    496|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   66|    496|}
gp_select_isd_rid:
   71|     14|{
   72|     14|	int rv;
   73|       |
   74|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   75|     14|	rv = gp_select_aid(card, &gp_isd_rid);
   76|     14|	LOG_FUNC_RETURN(card->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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   77|     14|}

iasecc_sdo_free_fields:
  150|    155|{
  151|    155|	free(sdo->docp.tries_maximum.value);
  152|    155|	free(sdo->docp.tries_remaining.value);
  153|    155|	free(sdo->docp.usage_remaining.value);
  154|    155|	free(sdo->docp.non_repudiation.value);
  155|    155|	free(sdo->docp.acls_contact.value);
  156|    155|	free(sdo->docp.acls_contactless.value);
  157|    155|	free(sdo->docp.size.value);
  158|    155|	free(sdo->docp.name.value);
  159|    155|	free(sdo->docp.issuer_data.value);
  160|       |
  161|    155|	if (sdo->sdo_class == IASECC_SDO_CLASS_RSA_PUBLIC)   {
  ------------------
  |  |  101|    155|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  |  Branch (161:6): [True: 3, False: 152]
  ------------------
  162|      3|		free(sdo->data.pub_key.n.value);
  163|      3|		free(sdo->data.pub_key.e.value);
  164|      3|		free(sdo->data.pub_key.compulsory.value);
  165|      3|		free(sdo->data.pub_key.chr.value);
  166|      3|		free(sdo->data.pub_key.cha.value);
  167|      3|	}
  168|    152|	else if (sdo->sdo_class == IASECC_SDO_CLASS_RSA_PRIVATE)   {
  ------------------
  |  |  100|    152|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  Branch (168:11): [True: 5, False: 147]
  ------------------
  169|      5|		free(sdo->data.prv_key.p.value);
  170|      5|		free(sdo->data.prv_key.q.value);
  171|      5|		free(sdo->data.prv_key.iqmp.value);
  172|      5|		free(sdo->data.prv_key.dmp1.value);
  173|      5|		free(sdo->data.prv_key.dmq1.value);
  174|      5|		free(sdo->data.prv_key.compulsory.value);
  175|      5|	}
  176|    147|	else if (sdo->sdo_class == IASECC_SDO_CLASS_CHV)   {
  ------------------
  |  |   98|    147|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
  |  Branch (176:11): [True: 87, False: 60]
  ------------------
  177|     87|		free(sdo->data.chv.size_max.value);
  178|     87|		free(sdo->data.chv.size_min.value);
  179|     87|		free(sdo->data.chv.value.value);
  180|     87|	}
  181|       |	/* invalidate all the other members too */
  182|    155|	memset(sdo, 0, sizeof(struct iasecc_sdo));
  183|    155|}
iasecc_sdo_free:
  188|      8|{
  189|      8|	iasecc_sdo_free_fields(card, sdo);
  190|      8|	free(sdo);
  191|      8|}
iasecc_se_get_crt:
  250|      6|{
  251|      6|	struct sc_context *ctx = card->ctx;
  252|      6|	int ii;
  253|       |
  254|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  255|      6|	if (!se || !crt)
  ------------------
  |  Branch (255:6): [True: 0, False: 6]
  |  Branch (255:13): [True: 0, False: 6]
  ------------------
  256|      6|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|      6|	sc_log(ctx, "CRT search template: %X:%X:%X, refs %X:%X:...",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  258|      6|			crt->tag, crt->algo, crt->usage, crt->refs[0], crt->refs[1]);
  259|       |
  260|     52|	for (ii=0; ii<SC_MAX_CRTS_IN_SE && se->crts[ii].tag; ii++)   {
  ------------------
  |  |   50|    104|#define SC_MAX_CRTS_IN_SE		12
  ------------------
  |  Branch (260:13): [True: 52, False: 0]
  |  Branch (260:37): [True: 46, False: 6]
  ------------------
  261|     46|		if (crt->tag != se->crts[ii].tag)
  ------------------
  |  Branch (261:7): [True: 36, False: 10]
  ------------------
  262|     36|			continue;
  263|     10|		if (crt->algo && crt->algo != se->crts[ii].algo)
  ------------------
  |  Branch (263:7): [True: 0, False: 10]
  |  Branch (263:20): [True: 0, False: 0]
  ------------------
  264|      0|			continue;
  265|     10|		if (crt->usage && crt->usage != se->crts[ii].usage)
  ------------------
  |  Branch (265:7): [True: 10, False: 0]
  |  Branch (265:21): [True: 10, False: 0]
  ------------------
  266|     10|			continue;
  267|      0|		if (crt->refs[0] && crt->refs[0] != se->crts[ii].refs[0])
  ------------------
  |  Branch (267:7): [True: 0, False: 0]
  |  Branch (267:23): [True: 0, False: 0]
  ------------------
  268|      0|			continue;
  269|       |
  270|      0|		memcpy(crt, &se->crts[ii], sizeof(*crt));
  271|       |
  272|      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__
  |  |  ------------------
  ------------------
  273|      0|				se->crts[ii].refs[0], se->crts[ii].refs[1]);
  274|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  275|      0|	}
  276|       |
  277|      6|	sc_log(ctx, "iasecc_se_get_crt() CRT is not found");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  278|      6|	return SC_ERROR_DATA_OBJECT_NOT_FOUND;
  ------------------
  |  |   66|      6|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  279|      6|}
iasecc_se_parse:
  313|     13|{
  314|     13|	struct sc_context *ctx = card->ctx;
  315|     13|	size_t size, offs;
  316|     13|	int size_size;
  317|     13|	int rv;
  318|       |
  319|     13|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  320|     13|	sc_log(ctx, "data_len %"SC_FORMAT_LEN_SIZE_T"u", data_len);
  ------------------
  |  |   71|     13|#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|       |
  322|     13|	if (data_len < 1)
  ------------------
  |  Branch (322:6): [True: 0, False: 13]
  ------------------
  323|     13|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  324|       |
  325|     13|	if (*data == IASECC_SDO_TEMPLATE_TAG)   {
  ------------------
  |  |   29|     13|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
  |  Branch (325:6): [True: 0, False: 13]
  ------------------
  326|      0|		size_size = iasecc_parse_size(data + 1, data_len - 1, &size);
  327|      0|		LOG_TEST_RET(ctx, size_size, "parse error: invalid size data of IASECC_SDO_TEMPLATE");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  328|       |
  329|      0|		if (data_len < size + size_size + 1)
  ------------------
  |  Branch (329:7): [True: 0, False: 0]
  ------------------
  330|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  331|       |
  332|      0|		data += size_size + 1;
  333|      0|		data_len = size;
  334|      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__
  |  |  ------------------
  ------------------
  335|      0|		       "IASECC_SDO_TEMPLATE: size %"SC_FORMAT_LEN_SIZE_T"u, size_size %d",
  336|      0|		       size, size_size);
  337|       |
  338|      0|		if (data_len < 3)
  ------------------
  |  Branch (338:7): [True: 0, False: 0]
  ------------------
  339|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  340|       |
  341|      0|		if (*data != IASECC_SDO_TAG_HEADER)
  ------------------
  |  |   27|      0|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
  |  Branch (341:7): [True: 0, False: 0]
  ------------------
  342|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  343|       |
  344|      0|		if ((*(data + 1) & 0x7F) != IASECC_SDO_CLASS_SE)
  ------------------
  |  |  102|      0|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
  |  Branch (344:7): [True: 0, False: 0]
  ------------------
  345|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  346|       |
  347|      0|		size_size = iasecc_parse_size(data + 3, data_len - 3, &size);
  348|      0|		LOG_TEST_RET(ctx, size_size, "parse error: invalid SDO SE data 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  349|       |
  350|      0|		if (data_len != size + size_size + 3)
  ------------------
  |  Branch (350:7): [True: 0, False: 0]
  ------------------
  351|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalid SDO SE data 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  352|       |
  353|      0|		data += 3 + size_size;
  354|      0|		data_len = size;
  355|      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__
  |  |  ------------------
  ------------------
  356|      0|		       "IASECC_SDO_TEMPLATE SE: size %"SC_FORMAT_LEN_SIZE_T"u, size_size %d",
  357|      0|		       size, size_size);
  358|      0|	}
  359|       |
  360|     13|	if (*data != IASECC_SDO_CLASS_SE)   {
  ------------------
  |  |  102|     13|#define IASECC_SDO_CLASS_SE		0x7B
  ------------------
  |  Branch (360:6): [True: 1, False: 12]
  ------------------
  361|      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__
  |  |  ------------------
  ------------------
  362|      1|		       "Invalid SE tag 0x%X; data length %"SC_FORMAT_LEN_SIZE_T"u",
  363|      1|		       *data, data_len);
  364|      1|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|      1|	}
  366|       |
  367|     12|	size_size = iasecc_parse_size(data + 1, data_len - 1, &size);
  368|     12|	LOG_TEST_RET(ctx, size_size, "parse error: invalid size data");
  ------------------
  |  |  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: 0, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  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|     12|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  369|       |
  370|     12|	if (data_len != size + size_size + 1)
  ------------------
  |  Branch (370:6): [True: 1, False: 11]
  ------------------
  371|     12|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalid SE data 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  372|       |
  373|     11|	offs = 1 + size_size;
  374|    410|	for (; offs < data_len;)   {
  ------------------
  |  Branch (374:9): [True: 404, False: 6]
  ------------------
  375|    404|		rv = iasecc_crt_parse(card, data + offs, data_len - offs, se);
  376|    404|		LOG_TEST_RET(ctx, rv, "parse error: invalid SE data");
  ------------------
  |  |  174|    404|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    404|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    404|	int _ret = (r); \
  |  |  |  |  168|    404|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 5, False: 399]
  |  |  |  |  ------------------
  |  |  |  |  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|    404|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 399]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  377|       |
  378|    399|		offs += rv;
  379|    399|	}
  380|       |
  381|      6|	if (offs != data_len)
  ------------------
  |  Branch (381:6): [True: 0, False: 6]
  ------------------
  382|      6|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  383|       |
  384|      6|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  385|      6|}
iasecc_sdo_parse:
  765|    110|{
  766|    110|	struct sc_context *ctx = card->ctx;
  767|    110|	size_t size, offs;
  768|    110|	int size_size;
  769|    110|	int rv;
  770|       |
  771|    110|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    110|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    110|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    110|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    110|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 110]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  772|       |
  773|    110|	if (data == NULL || data_len < 2)
  ------------------
  |  Branch (773:6): [True: 0, False: 110]
  |  Branch (773:22): [True: 6, False: 104]
  ------------------
  774|    110|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  775|       |
  776|    104|	if (*data == IASECC_SDO_TEMPLATE_TAG)   {
  ------------------
  |  |   29|    104|#define IASECC_SDO_TEMPLATE_TAG	0x70
  ------------------
  |  Branch (776:6): [True: 2, False: 102]
  ------------------
  777|      2|		size_size = iasecc_parse_size(data + 1, data_len - 1, &size);
  778|      2|		LOG_TEST_RET(ctx, size_size, "parse error: invalid size data of IASECC_SDO_TEMPLATE");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  779|       |
  780|      2|		if (data_len < (size_t)(size_size + 1)) {
  ------------------
  |  Branch (780:7): [True: 0, False: 2]
  ------------------
  781|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  782|      0|		}
  783|      2|		data += size_size + 1;
  784|      2|		data_len -= (size_size + 1);
  785|      2|		if (size > data_len) {
  ------------------
  |  Branch (785:7): [True: 1, False: 1]
  ------------------
  786|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  787|      1|		}
  788|      1|		data_len = size;
  789|      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__
  |  |  ------------------
  ------------------
  790|      1|		       "IASECC_SDO_TEMPLATE: size %"SC_FORMAT_LEN_SIZE_T"u, size_size %d",
  791|      1|		       size, size_size);
  792|      1|	}
  793|       |
  794|    103|	if (data_len < 4 || *data != IASECC_SDO_TAG_HEADER)
  ------------------
  |  |   27|    103|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
  |  Branch (794:6): [True: 0, False: 103]
  |  Branch (794:22): [True: 7, False: 96]
  ------------------
  795|    103|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  796|       |
  797|     96|	if (sdo->sdo_class != (*(data + 1) & 0x7F))
  ------------------
  |  Branch (797:6): [True: 0, False: 96]
  ------------------
  798|     96|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  799|       |
  800|     96|	if (sdo->sdo_ref != (*(data + 2) & 0x3F))
  ------------------
  |  Branch (800:6): [True: 1, False: 95]
  ------------------
  801|     96|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  802|       |
  803|     95|	size_size = iasecc_parse_size(data + 3, data_len - 3, &size);
  804|     95|	LOG_TEST_RET(ctx, size_size, "parse error: invalid size data");
  ------------------
  |  |  174|     95|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     95|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     95|	int _ret = (r); \
  |  |  |  |  168|     95|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 94]
  |  |  |  |  ------------------
  |  |  |  |  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|     95|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  805|       |
  806|     94|	if (data_len != size + size_size + 3)
  ------------------
  |  Branch (806:6): [True: 7, False: 87]
  ------------------
  807|     94|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalid SDO data size");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  808|       |
  809|     87|	sc_log(ctx,
  ------------------
  |  |   71|     87|#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|     87|	       "sz %"SC_FORMAT_LEN_SIZE_T"u, sz_size %d",
  811|     87|	       size, size_size);
  812|       |
  813|     87|	offs = 3 + size_size;
  814|    148|	for (; offs < data_len;)   {
  ------------------
  |  Branch (814:9): [True: 147, False: 1]
  ------------------
  815|    147|		rv = iasecc_sdo_parse_data(card, data + offs, data_len - offs, sdo);
  816|    147|		if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    147|#define SC_SUCCESS				0
  ------------------
  |  Branch (816:7): [True: 147, False: 0]
  ------------------
  817|    147|			iasecc_sdo_free_fields(card, sdo);
  818|    147|			LOG_TEST_RET(ctx, rv, "parse error: invalid SDO data");
  ------------------
  |  |  174|    147|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    147|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    147|	int _ret = (r); \
  |  |  |  |  168|    147|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 86, False: 61]
  |  |  |  |  ------------------
  |  |  |  |  169|     86|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     86|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     86|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     86|		return _ret; \
  |  |  |  |  172|     86|	} \
  |  |  |  |  173|    147|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 61]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  819|    147|		}
  820|       |
  821|     61|		offs += rv;
  822|     61|	}
  823|       |
  824|      1|	if (offs != data_len)
  ------------------
  |  Branch (824:6): [True: 0, False: 1]
  ------------------
  825|      1|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  826|       |
  827|      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__
  |  |  ------------------
  ------------------
  828|      1|	       "docp.acls_contact.size %"SC_FORMAT_LEN_SIZE_T"u, docp.size.size %"SC_FORMAT_LEN_SIZE_T"u",
  829|      1|	       sdo->docp.acls_contact.size, sdo->docp.size.size);
  830|       |
  831|      1|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  832|      1|}
iasecc_sdo_allocate_and_parse:
  838|      5|{
  839|      5|	struct sc_context *ctx = card->ctx;
  840|      5|	struct iasecc_sdo *sdo = NULL;
  841|      5|	size_t size, offs;
  842|      5|	int size_size;
  843|      5|	int rv;
  844|       |
  845|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  846|       |
  847|      5|	if (*data != IASECC_SDO_TAG_HEADER)
  ------------------
  |  |   27|      5|#define IASECC_SDO_TAG_HEADER	0xBF
  ------------------
  |  Branch (847:6): [True: 0, False: 5]
  ------------------
  848|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  849|       |
  850|      5|	if (data_len < 3)
  ------------------
  |  Branch (850:6): [True: 0, False: 5]
  ------------------
  851|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  852|       |
  853|      5|	sdo = calloc(1, sizeof(struct iasecc_sdo));
  854|      5|	if (!sdo)
  ------------------
  |  Branch (854:6): [True: 0, False: 5]
  ------------------
  855|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  856|      5|	*out = sdo;
  857|       |
  858|      5|	sdo->sdo_class = *(data + 1) & 0x7F;
  859|      5|	sdo->sdo_ref = *(data + 2) & 0x3F;
  860|       |
  861|      5|	sc_log(ctx, "sdo_class 0x%X, sdo_ref 0x%X", sdo->sdo_class, sdo->sdo_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  862|      5|	if (data_len == 3)
  ------------------
  |  Branch (862:6): [True: 5, False: 0]
  ------------------
  863|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  864|       |
  865|      0|	size_size = iasecc_parse_size(data + 3, data_len - 3, &size);
  866|      0|	LOG_TEST_RET(ctx, size_size, "parse error: invalid size 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|       |
  868|      0|	if (data_len != size + size_size + 3)
  ------------------
  |  Branch (868:6): [True: 0, False: 0]
  ------------------
  869|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "parse error: invalid SDO data 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  870|       |
  871|      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__
  |  |  ------------------
  ------------------
  872|      0|	       "sz %"SC_FORMAT_LEN_SIZE_T"u, sz_size %d",
  873|      0|	       size, size_size);
  874|       |
  875|      0|	offs = 3 + size_size;
  876|      0|	for (; offs < data_len;)   {
  ------------------
  |  Branch (876:9): [True: 0, False: 0]
  ------------------
  877|      0|		rv = iasecc_sdo_parse_data(card, data + offs, data_len - offs, sdo);
  878|      0|		LOG_TEST_RET(ctx, rv, "parse error: invalid SDO 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  879|       |
  880|      0|		offs += rv;
  881|      0|	}
  882|       |
  883|      0|	if (offs != data_len)
  ------------------
  |  Branch (883:6): [True: 0, False: 0]
  ------------------
  884|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  885|       |
  886|      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__
  |  |  ------------------
  ------------------
  887|      0|	       "docp.acls_contact.size %"SC_FORMAT_LEN_SIZE_T"u; docp.size.size %"SC_FORMAT_LEN_SIZE_T"u",
  888|      0|	       sdo->docp.acls_contact.size, sdo->docp.size.size);
  889|       |
  890|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  891|      0|}
iasecc_docp_copy:
 1349|      6|{
 1350|      6|	int rv;
 1351|       |
 1352|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1353|      6|	if (!in || !out)
  ------------------
  |  Branch (1353:6): [True: 0, False: 6]
  |  Branch (1353:13): [True: 0, False: 6]
  ------------------
 1354|      6|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1355|       |
 1356|      6|	memset(out, 0, sizeof(struct iasecc_sdo_docp));
 1357|       |
 1358|      6|	rv = iasecc_tlv_copy(ctx, &in->name, &out->name);
 1359|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1360|       |
 1361|      6|	rv = iasecc_tlv_copy(ctx, &in->tries_maximum, &out->tries_maximum);
 1362|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1363|       |
 1364|      6|	rv = iasecc_tlv_copy(ctx, &in->tries_remaining, &out->tries_remaining);
 1365|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1366|       |
 1367|      6|	rv = iasecc_tlv_copy(ctx, &in->usage_maximum, &out->usage_maximum);
 1368|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1369|       |
 1370|      6|	rv = iasecc_tlv_copy(ctx, &in->usage_remaining, &out->usage_remaining);
 1371|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1372|       |
 1373|      6|	rv = iasecc_tlv_copy(ctx, &in->non_repudiation, &out->non_repudiation);
 1374|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1375|       |
 1376|      6|	rv = iasecc_tlv_copy(ctx, &in->size, &out->size);
 1377|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1378|       |
 1379|      6|	rv = iasecc_tlv_copy(ctx, &in->acls_contact, &out->acls_contact);
 1380|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1381|       |
 1382|      6|	rv = iasecc_tlv_copy(ctx, &in->acls_contactless, &out->acls_contactless);
 1383|      6|	LOG_TEST_RET(ctx, rv, "TLV copy 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1384|       |
 1385|      6|	out->amb = in->amb;
 1386|      6|	memcpy(out->scbs, in->scbs, sizeof(out->scbs));
 1387|       |
 1388|      6|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1389|      6|}
iasecc-sdo.c:iasecc_parse_acls:
   44|     14|{
   45|     14|	struct sc_context *ctx = card->ctx;
   46|     14|	struct iasecc_extended_tlv *acls = &docp->acls_contact;
   47|     14|	int ii;
   48|     14|	size_t offs;
   49|     14|	unsigned char mask = 0x40;
   50|       |
   51|     14|	if (flags)
  ------------------
  |  Branch (51:6): [True: 0, False: 14]
  ------------------
   52|      0|		acls = &docp->acls_contactless;
   53|       |
   54|     14|	if (!acls->size)
  ------------------
  |  Branch (54:6): [True: 5, False: 9]
  ------------------
   55|     14|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   56|       |
   57|      9|	docp->amb = *(acls->value + 0);
   58|      9|	memset(docp->scbs, 0xFF, sizeof(docp->scbs));
   59|     71|	for (ii=0, offs = 1; ii<7; ii++, mask >>= 1)
  ------------------
  |  Branch (59:23): [True: 63, False: 8]
  ------------------
   60|     63|		if (mask & docp->amb) {
  ------------------
  |  Branch (60:7): [True: 25, False: 38]
  ------------------
   61|     25|			if (offs >= acls->size) {
  ------------------
  |  Branch (61:8): [True: 1, False: 24]
  ------------------
   62|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   63|      1|			}
   64|     24|			docp->scbs[ii] = *(acls->value + offs++);
   65|     24|		}
   66|       |
   67|      8|	sc_log(ctx, "iasecc_parse_docp() SCBs %02X:%02X:%02X:%02X:%02X:%02X:%02X",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   68|      8|			docp->scbs[0],docp->scbs[1],docp->scbs[2],docp->scbs[3],
   69|      8|			docp->scbs[4],docp->scbs[5],docp->scbs[6]);
   70|      8|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   71|      8|}
iasecc-sdo.c:iasecc_crt_parse:
  196|    404|{
  197|    404|	struct sc_context *ctx = card->ctx;
  198|    404|	struct sc_crt crt;
  199|    404|	int ii, offs, len, parsed_len = -1;
  200|       |
  201|    404|	sc_log(ctx, "iasecc_crt_parse(0x%X) called", *data);
  ------------------
  |  |   71|    404|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  202|       |
  203|    404|	if (data_len < 2)
  ------------------
  |  Branch (203:6): [True: 0, False: 404]
  ------------------
  204|    404|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  205|       |
  206|    404|	memset(&crt, 0, sizeof(crt));
  207|    404|	crt.tag = *(data + 0);
  208|    404|	len = *(data + 1);
  209|       |
  210|    479|	for(offs = 2; offs < len + 2; offs += 3)   {
  ------------------
  |  Branch (210:16): [True: 80, False: 399]
  ------------------
  211|     80|		if ((size_t) offs + 2 >= data_len)
  ------------------
  |  Branch (211:7): [True: 0, False: 80]
  ------------------
  212|     80|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  213|     80|		sc_log(ctx, "iasecc_crt_parse(0x%X) CRT %X -> %X", *data, *(data + offs), *(data + offs + 2));
  ------------------
  |  |   71|     80|#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|     80|		if (*(data + offs) == IASECC_CRT_TAG_USAGE)   {
  ------------------
  |  |  111|     80|#define IASECC_CRT_TAG_USAGE		0x95
  ------------------
  |  Branch (214:7): [True: 0, False: 80]
  ------------------
  215|      0|			crt.usage = *(data + offs + 2);
  216|      0|		}
  217|     80|		else if (*(data + offs) == IASECC_CRT_TAG_REFERENCE)   {
  ------------------
  |  |  112|     80|#define IASECC_CRT_TAG_REFERENCE	0x83
  ------------------
  |  Branch (217:12): [True: 30, False: 50]
  ------------------
  218|     30|			int nn_refs = sizeof(crt.refs) / sizeof(crt.refs[0]);
  219|       |
  220|    110|			for (ii=0; ii<nn_refs && crt.refs[ii]; ii++)
  ------------------
  |  Branch (220:15): [True: 109, False: 1]
  |  Branch (220:29): [True: 80, False: 29]
  ------------------
  221|     80|				;
  222|     30|			if (ii == nn_refs)
  ------------------
  |  Branch (222:8): [True: 1, False: 29]
  ------------------
  223|     30|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  224|       |
  225|     29|			crt.refs[ii] = *(data + offs + 2);
  226|     29|		}
  227|     50|		else if (*(data + offs) == IASECC_CRT_TAG_ALGO)   {
  ------------------
  |  |  113|     50|#define IASECC_CRT_TAG_ALGO		0x80
  ------------------
  |  Branch (227:12): [True: 46, False: 4]
  ------------------
  228|     46|			crt.algo = *(data + offs + 2);
  229|     46|		}
  230|      4|		else   {
  231|      4|			LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  232|      4|		}
  233|     80|	}
  234|       |
  235|  1.93k|	for (ii=0; ii<SC_MAX_CRTS_IN_SE; ii++)
  ------------------
  |  |   50|  1.93k|#define SC_MAX_CRTS_IN_SE		12
  ------------------
  |  Branch (235:13): [True: 1.93k, False: 0]
  ------------------
  236|  1.93k|		if (!se->crts[ii].tag)
  ------------------
  |  Branch (236:7): [True: 399, False: 1.53k]
  ------------------
  237|    399|			break;
  238|       |
  239|    399|	if (ii==SC_MAX_CRTS_IN_SE)
  ------------------
  |  |   50|    399|#define SC_MAX_CRTS_IN_SE		12
  ------------------
  |  Branch (239:6): [True: 0, False: 399]
  ------------------
  240|    399|		LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "iasecc_crt_parse() error: too much CRTs in SE");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  241|       |
  242|    399|	memcpy(&se->crts[ii], &crt, sizeof(crt));
  243|    399|	parsed_len = len + 2;
  244|    399|	LOG_FUNC_RETURN(ctx, parsed_len);
  ------------------
  |  |  164|    399|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    399|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    399|	int _ret = r; \
  |  |  |  |  155|    399|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 399]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    399|	} else { \
  |  |  |  |  159|    399|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    399|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    399|	} \
  |  |  |  |  162|    399|	return _ret; \
  |  |  |  |  163|    399|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  245|    399|}
iasecc-sdo.c:iasecc_parse_size:
  390|    432|{
  391|    432|	if (data_len > 0 && *data < 0x80) {
  ------------------
  |  Branch (391:6): [True: 431, False: 1]
  |  Branch (391:22): [True: 408, False: 23]
  ------------------
  392|    408|		*out = *data;
  393|    408|		return 1;
  394|    408|	}
  395|     24|	else if (data_len > 1 && *data == 0x81) {
  ------------------
  |  Branch (395:11): [True: 19, False: 5]
  |  Branch (395:27): [True: 6, False: 13]
  ------------------
  396|      6|		*out = *(data + 1);
  397|      6|		return 2;
  398|      6|	}
  399|     18|	else if (data_len > 2 && *data == 0x82) {
  ------------------
  |  Branch (399:11): [True: 10, False: 8]
  |  Branch (399:27): [True: 4, False: 6]
  ------------------
  400|      4|		*out = *(data + 1) * 0x100 + *(data + 2);
  401|      4|		return 3;
  402|      4|	}
  403|       |
  404|     14|	return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|     14|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  405|    432|}
iasecc-sdo.c:iasecc_sdo_parse_data:
  676|    147|{
  677|    147|	struct sc_context *ctx = card->ctx;
  678|    147|	struct iasecc_extended_tlv tlv;
  679|    147|	int tlv_size, rv;
  680|       |
  681|    147|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    147|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    147|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    147|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    147|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 147]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  682|    147|	sc_log(ctx, "iasecc_sdo_parse_data() class %X; ref %X", sdo->sdo_class, sdo->sdo_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  683|       |
  684|    147|	tlv_size = iasecc_parse_get_tlv(card, data, data_len, &tlv);
  685|    147|	LOG_TEST_RET(ctx, tlv_size, "parse error: get TLV");
  ------------------
  |  |  174|    147|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    147|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    147|	int _ret = (r); \
  |  |  |  |  168|    147|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 13, False: 134]
  |  |  |  |  ------------------
  |  |  |  |  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|    147|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 134]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  686|       |
  687|    134|	sc_log(ctx, "iasecc_sdo_parse_data() tlv.tag 0x%X", tlv.tag);
  ------------------
  |  |   71|    134|#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|    134|	if (tlv.tag == IASECC_DOCP_TAG)   {
  ------------------
  |  |   31|    134|#define IASECC_DOCP_TAG				0xA0
  ------------------
  |  Branch (688:6): [True: 48, False: 86]
  ------------------
  689|     48|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  690|     48|		       "iasecc_sdo_parse_data() parse IASECC_DOCP_TAG: 0x%X; size %"SC_FORMAT_LEN_SIZE_T"u",
  691|     48|		       tlv.tag, tlv.size);
  692|     48|		rv = iasecc_parse_docp(card, tlv.value, tlv.size, sdo);
  693|     48|		sc_log(ctx, "iasecc_sdo_parse_data() parsed IASECC_DOCP_TAG rv %i", rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  694|     48|		free(tlv.value);
  695|     48|		LOG_TEST_RET(ctx, rv, "parse error: cannot parse DOCP");
  ------------------
  |  |  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: 43, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  696|     48|	}
  697|     86|	else if (tlv.tag == IASECC_DOCP_TAG_NON_REPUDIATION)   {
  ------------------
  |  |   37|     86|#define IASECC_DOCP_TAG_NON_REPUDIATION 		0x9E
  ------------------
  |  Branch (697:11): [True: 10, False: 76]
  ------------------
  698|     10|		free(sdo->docp.non_repudiation.value);
  699|     10|		sdo->docp.non_repudiation = tlv;
  700|     10|	}
  701|     76|	else if (tlv.tag == IASECC_DOCP_TAG_USAGE_REMAINING)   {
  ------------------
  |  |   36|     76|#define IASECC_DOCP_TAG_USAGE_REMAINING		0x9D
  ------------------
  |  Branch (701:11): [True: 11, False: 65]
  ------------------
  702|     11|		free(sdo->docp.usage_remaining.value);
  703|     11|		sdo->docp.usage_remaining = tlv;
  704|     11|	}
  705|     65|	else if (tlv.tag == IASECC_DOCP_TAG_TRIES_MAXIMUM)   {
  ------------------
  |  |   33|     65|#define IASECC_DOCP_TAG_TRIES_MAXIMUM		0x9A
  ------------------
  |  Branch (705:11): [True: 11, False: 54]
  ------------------
  706|     11|		free(sdo->docp.tries_maximum.value);
  707|     11|		sdo->docp.tries_maximum = tlv;
  708|     11|	}
  709|     54|	else if (tlv.tag == IASECC_DOCP_TAG_TRIES_REMAINING)   {
  ------------------
  |  |   34|     54|#define IASECC_DOCP_TAG_TRIES_REMAINING		0x9B
  ------------------
  |  Branch (709:11): [True: 19, False: 35]
  ------------------
  710|     19|		free(sdo->docp.tries_remaining.value);
  711|     19|		sdo->docp.tries_remaining = tlv;
  712|     19|	}
  713|     35|	else if (tlv.tag == IASECC_SDO_CHV_TAG)   {
  ------------------
  |  |   63|     35|#define IASECC_SDO_CHV_TAG		0x7F41
  ------------------
  |  Branch (713:11): [True: 14, False: 21]
  ------------------
  714|     14|		if (sdo->sdo_class != IASECC_SDO_CLASS_CHV) {
  ------------------
  |  |   98|     14|#define IASECC_SDO_CLASS_CHV		0x01
  ------------------
  |  Branch (714:7): [True: 1, False: 13]
  ------------------
  715|      1|			free(tlv.value);
  716|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  717|      1|		}
  718|       |
  719|     13|		rv = iasecc_parse_chv(card, tlv.value, tlv.size, &sdo->data.chv);
  720|     13|		free(tlv.value);
  721|     13|		LOG_TEST_RET(ctx, rv, "parse error: cannot parse SDO CHV data");
  ------------------
  |  |  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: 8, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  722|     13|	}
  723|     21|	else if (tlv.tag == IASECC_SDO_PUBKEY_TAG)   {
  ------------------
  |  |   76|     21|#define IASECC_SDO_PUBKEY_TAG			0x7F49
  ------------------
  |  Branch (723:11): [True: 1, False: 20]
  ------------------
  724|      1|		if (sdo->sdo_class != IASECC_SDO_CLASS_RSA_PUBLIC) {
  ------------------
  |  |  101|      1|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  |  Branch (724:7): [True: 1, False: 0]
  ------------------
  725|      1|			free(tlv.value);
  726|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  727|      1|		}
  728|       |
  729|      0|		rv = iasecc_parse_pubkey(card, tlv.value, tlv.size, &sdo->data.pub_key);
  730|      0|		free(tlv.value);
  731|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  732|      0|	}
  733|     20|	else if (tlv.tag == IASECC_SDO_PRVKEY_TAG)   {
  ------------------
  |  |   68|     20|#define IASECC_SDO_PRVKEY_TAG			0x7F48
  ------------------
  |  Branch (733:11): [True: 1, False: 19]
  ------------------
  734|      1|		if (sdo->sdo_class != IASECC_SDO_CLASS_RSA_PRIVATE) {
  ------------------
  |  |  100|      1|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  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_PRIVATE_KEY tag in non PRIVATE_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|      1|		}
  738|       |
  739|      0|		rv = iasecc_parse_prvkey(card, tlv.value, tlv.size, &sdo->data.prv_key);
  740|      0|		free(tlv.value);
  741|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|      0|	}
  743|     19|	else if (tlv.tag == IASECC_SDO_KEYSET_TAG)   {
  ------------------
  |  |   83|     19|#define IASECC_SDO_KEYSET_TAG			0xA2
  ------------------
  |  Branch (743:11): [True: 1, False: 18]
  ------------------
  744|      1|		if (sdo->sdo_class != IASECC_SDO_CLASS_KEYSET) {
  ------------------
  |  |   99|      1|#define IASECC_SDO_CLASS_KEYSET		0x0A
  ------------------
  |  Branch (744:7): [True: 1, False: 0]
  ------------------
  745|      1|			free(tlv.value);
  746|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  747|      1|		}
  748|       |
  749|      0|		rv = iasecc_parse_keyset(card, tlv.value, tlv.size, &sdo->data.keyset);
  750|      0|		free(tlv.value);
  751|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  752|      0|	}
  753|     18|	else   {
  754|     18|		sc_log(ctx, "iasecc_sdo_parse_data() non supported tag 0x%X", tlv.tag);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  755|     18|		free(tlv.value);
  756|     18|		LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  757|     18|	}
  758|       |
  759|     61|	return tlv_size;
  760|    134|}
iasecc-sdo.c:iasecc_parse_get_tlv:
  410|    324|{
  411|    324|	struct sc_context *ctx = card->ctx;
  412|    324|	int size_len, tag_len;
  413|       |
  414|    324|	memset(tlv, 0, sizeof(*tlv));
  415|    324|	sc_log(ctx, "iasecc_parse_get_tlv() called for tag 0x%X", *data);
  ------------------
  |  |   71|    324|#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|    324|	if (data_len < 1)
  ------------------
  |  Branch (416:6): [True: 0, False: 324]
  ------------------
  417|    324|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  418|    324|	if ((*data == 0x7F) || (*data == 0x5F))   {
  ------------------
  |  Branch (418:6): [True: 27, False: 297]
  |  Branch (418:25): [True: 3, False: 294]
  ------------------
  419|     30|		if (data_len < 2)
  ------------------
  |  Branch (419:7): [True: 1, False: 29]
  ------------------
  420|     30|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  421|     29|		tlv->tag = *data * 0x100 + *(data + 1);
  422|     29|		tag_len = 2;
  423|     29|	}
  424|    294|	else   {
  425|    294|		tlv->tag = *data;
  426|    294|		tag_len = 1;
  427|    294|	}
  428|       |
  429|    323|	sc_log(ctx, "iasecc_parse_get_tlv() tlv->tag 0x%X", tlv->tag);
  ------------------
  |  |   71|    323|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  430|    323|	size_len = iasecc_parse_size(data + tag_len, data_len - tag_len, &tlv->size);
  431|    323|	LOG_TEST_RET(ctx, size_len, "parse error: invalid size data");
  ------------------
  |  |  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: 13, False: 310]
  |  |  |  |  ------------------
  |  |  |  |  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|    323|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 310]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  432|    310|	if (tag_len + size_len + tlv->size > data_len) {
  ------------------
  |  Branch (432:6): [True: 21, False: 289]
  ------------------
  433|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|     21|	}
  435|       |
  436|    289|	tlv->value = calloc(1, tlv->size);
  437|    289|	if (!tlv->value)
  ------------------
  |  Branch (437:6): [True: 0, False: 289]
  ------------------
  438|    289|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  439|    289|	memcpy(tlv->value, data + size_len + tag_len, tlv->size);
  440|       |
  441|    289|	tlv->on_card = 1;
  442|       |
  443|    289|	sc_log(ctx,
  ------------------
  |  |   71|    289|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  444|    289|	       "iasecc_parse_get_tlv() parsed %"SC_FORMAT_LEN_SIZE_T"u bytes",
  445|    289|	       tag_len + size_len + tlv->size);
  446|    289|	return (int)(tag_len + size_len + tlv->size);
  447|    289|}
iasecc-sdo.c:iasecc_parse_docp:
  602|     56|{
  603|     56|	struct sc_context *ctx = card->ctx;
  604|     56|	size_t offs = 0;
  605|     56|	int rv;
  606|       |
  607|     56|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  608|    161|	while(offs < data_len)   {
  ------------------
  |  Branch (608:8): [True: 147, False: 14]
  ------------------
  609|    147|		struct iasecc_extended_tlv tlv;
  610|       |
  611|    147|		rv = iasecc_parse_get_tlv(card, data + offs, data_len - offs, &tlv);
  612|    147|		LOG_TEST_RET(ctx, rv, "iasecc_parse_get_tlv() get and parse TLV error");
  ------------------
  |  |  174|    147|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    147|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    147|	int _ret = (r); \
  |  |  |  |  168|    147|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 17, False: 130]
  |  |  |  |  ------------------
  |  |  |  |  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|    147|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 130]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|       |
  614|    130|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  615|    130|		       "iasecc_parse_docp() parse_get_tlv returned %i; tag %X; size %"SC_FORMAT_LEN_SIZE_T"u",
  616|    130|		       rv, tlv.tag, tlv.size);
  617|       |
  618|    130|		if (tlv.tag == IASECC_DOCP_TAG_ACLS)   {
  ------------------
  |  |   39|    130|#define IASECC_DOCP_TAG_ACLS			0xA1
  ------------------
  |  Branch (618:7): [True: 8, False: 122]
  ------------------
  619|      8|			int _rv = iasecc_parse_docp(card, tlv.value, tlv.size, sdo);
  620|      8|			free(tlv.value);
  621|      8|			LOG_TEST_RET(ctx, _rv, "parse error: cannot parse DOCP");
  ------------------
  |  |  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: 5, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  622|      8|		}
  623|    122|		else if (tlv.tag == IASECC_DOCP_TAG_ACLS_CONTACT)   {
  ------------------
  |  |   40|    122|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
  |  Branch (623:12): [True: 9, False: 113]
  ------------------
  624|      9|			free(sdo->docp.acls_contact.value);
  625|      9|			sdo->docp.acls_contact = tlv;
  626|      9|		}
  627|    113|		else if (tlv.tag == IASECC_DOCP_TAG_ACLS_CONTACTLESS)   {
  ------------------
  |  |   41|    113|#define IASECC_DOCP_TAG_ACLS_CONTACTLESS	0x9C
  ------------------
  |  Branch (627:12): [True: 22, False: 91]
  ------------------
  628|     22|			free(sdo->docp.acls_contactless.value);
  629|     22|			sdo->docp.acls_contactless = tlv;
  630|     22|		}
  631|     91|		else if (tlv.tag == IASECC_DOCP_TAG_SIZE)   {
  ------------------
  |  |   38|     91|#define IASECC_DOCP_TAG_SIZE			0x80
  ------------------
  |  Branch (631:12): [True: 13, False: 78]
  ------------------
  632|     13|			free(sdo->docp.size.value);
  633|     13|			sdo->docp.size = tlv;
  634|     13|		}
  635|     78|		else if (tlv.tag == IASECC_DOCP_TAG_NAME)   {
  ------------------
  |  |   32|     78|#define IASECC_DOCP_TAG_NAME			0x84
  ------------------
  |  Branch (635:12): [True: 10, False: 68]
  ------------------
  636|     10|			free(sdo->docp.name.value);
  637|     10|			sdo->docp.name = tlv;
  638|     10|		}
  639|     68|		else if (tlv.tag == IASECC_DOCP_TAG_ISSUER_DATA)   {
  ------------------
  |  |   43|     68|#define IASECC_DOCP_TAG_ISSUER_DATA		0x85
  ------------------
  |  Branch (639:12): [True: 6, False: 62]
  ------------------
  640|      6|			free(sdo->docp.issuer_data.value);
  641|      6|			sdo->docp.issuer_data = tlv;
  642|      6|		}
  643|     62|		else if (tlv.tag == IASECC_DOCP_TAG_NON_REPUDIATION)   {
  ------------------
  |  |   37|     62|#define IASECC_DOCP_TAG_NON_REPUDIATION 		0x9E
  ------------------
  |  Branch (643:12): [True: 8, False: 54]
  ------------------
  644|      8|			free(sdo->docp.non_repudiation.value);
  645|      8|			sdo->docp.non_repudiation = tlv;
  646|      8|		}
  647|     54|		else if (tlv.tag == IASECC_DOCP_TAG_USAGE_REMAINING)   {
  ------------------
  |  |   36|     54|#define IASECC_DOCP_TAG_USAGE_REMAINING		0x9D
  ------------------
  |  Branch (647:12): [True: 13, False: 41]
  ------------------
  648|     13|			free(sdo->docp.usage_remaining.value);
  649|     13|			sdo->docp.usage_remaining = tlv;
  650|     13|		}
  651|     41|		else if (tlv.tag == IASECC_DOCP_TAG_TRIES_MAXIMUM)   {
  ------------------
  |  |   33|     41|#define IASECC_DOCP_TAG_TRIES_MAXIMUM		0x9A
  ------------------
  |  Branch (651:12): [True: 9, False: 32]
  ------------------
  652|      9|			free(sdo->docp.tries_maximum.value);
  653|      9|			sdo->docp.tries_maximum = tlv;
  654|      9|		}
  655|     32|		else if (tlv.tag == IASECC_DOCP_TAG_TRIES_REMAINING)   {
  ------------------
  |  |   34|     32|#define IASECC_DOCP_TAG_TRIES_REMAINING		0x9B
  ------------------
  |  Branch (655:12): [True: 12, False: 20]
  ------------------
  656|     12|			free(sdo->docp.tries_remaining.value);
  657|     12|			sdo->docp.tries_remaining = tlv;
  658|     12|		}
  659|     20|		else   {
  660|     20|			free(tlv.value);
  661|     20|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "iasecc_parse_get_tlv() parse error: non DOCP tag");
  ------------------
  |  |  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: 20, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  662|     20|		}
  663|       |
  664|    105|		offs += rv;
  665|    105|	}
  666|       |
  667|     14|	rv = iasecc_parse_acls(card, &sdo->docp, 0);
  668|     14|	LOG_TEST_RET(ctx, rv, "Cannot parse ACLs in DOCP");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  669|       |
  670|      8|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  671|      8|}
iasecc-sdo.c:iasecc_parse_chv:
  452|     13|{
  453|     13|	struct sc_context *ctx = card->ctx;
  454|     13|	size_t offs = 0;
  455|     13|	int rv;
  456|       |
  457|     13|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  458|     35|	while(offs < data_len)   {
  ------------------
  |  Branch (458:8): [True: 30, False: 5]
  ------------------
  459|     30|		struct iasecc_extended_tlv tlv;
  460|       |
  461|     30|		rv = iasecc_parse_get_tlv(card, data + offs, data_len - offs, &tlv);
  462|     30|		LOG_TEST_RET(ctx, rv, "iasecc_parse_chv() get and parse TLV 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: 5, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  463|       |
  464|     25|		sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  465|     25|		       "iasecc_parse_chv() get and parse TLV returned %i; tag %X; size %"SC_FORMAT_LEN_SIZE_T"u",
  466|     25|		       rv, tlv.tag, tlv.size);
  467|       |
  468|     25|		if (tlv.tag == IASECC_SDO_CHV_TAG_SIZE_MAX) {
  ------------------
  |  |   64|     25|#define IASECC_SDO_CHV_TAG_SIZE_MAX	0x80
  ------------------
  |  Branch (468:7): [True: 10, False: 15]
  ------------------
  469|     10|			free(chv->size_max.value);
  470|     10|			chv->size_max = tlv;
  471|     15|		} else if (tlv.tag == IASECC_SDO_CHV_TAG_SIZE_MIN) {
  ------------------
  |  |   65|     15|#define IASECC_SDO_CHV_TAG_SIZE_MIN	0x81
  ------------------
  |  Branch (471:14): [True: 7, False: 8]
  ------------------
  472|      7|			free(chv->size_min.value);
  473|      7|			chv->size_min = tlv;
  474|      8|		} else if (tlv.tag == IASECC_SDO_CHV_TAG_VALUE) {
  ------------------
  |  |   66|      8|#define IASECC_SDO_CHV_TAG_VALUE	0x82
  ------------------
  |  Branch (474:14): [True: 5, False: 3]
  ------------------
  475|      5|			free(chv->value.value);
  476|      5|			chv->value = tlv;
  477|      5|		} else {
  478|      3|			free(tlv.value);
  479|      3|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "parse error: non CHV SDO 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|      3|		}
  481|       |
  482|     22|		offs += rv;
  483|     22|	}
  484|       |
  485|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  486|      5|}
iasecc-sdo.c:iasecc_tlv_copy:
 1326|     54|{
 1327|     54|	if (!in || !out)
  ------------------
  |  Branch (1327:6): [True: 0, False: 54]
  |  Branch (1327:13): [True: 0, False: 54]
  ------------------
 1328|     54|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1329|       |
 1330|     54|	memset(out, 0, sizeof(struct iasecc_extended_tlv));
 1331|     54|	out->tag = in->tag;
 1332|     54|	out->parent_tag = in->parent_tag;
 1333|     54|	out->on_card = in->on_card;
 1334|     54|	if (in->value && in->size)   {
  ------------------
  |  Branch (1334:6): [True: 0, False: 54]
  |  Branch (1334:19): [True: 0, False: 0]
  ------------------
 1335|      0|		out->value = calloc(1, in->size);
 1336|      0|		if (!out->value)
  ------------------
  |  Branch (1336:7): [True: 0, False: 0]
  ------------------
 1337|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1338|       |
 1339|      0|		memcpy(out->value, in->value, in->size);
 1340|      0|		out->size = in->size;
 1341|      0|	}
 1342|       |
 1343|     54|	return SC_SUCCESS;
  ------------------
  |  |   28|     54|#define SC_SUCCESS				0
  ------------------
 1344|     54|}

iasecc_sm_initialize:
  270|     15|{
  271|     15|	struct sc_context *ctx = card->ctx;
  272|     15|#ifdef ENABLE_SM
  273|     15|	struct sm_info *sm_info = &card->sm_ctx.info;
  274|     15|	struct sm_cwa_session *cwa_session = &sm_info->session.cwa;
  275|     15|	struct sc_remote_data rdata;
  276|     15|	int rv;
  277|       |
  278|     15|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     15|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     15|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     15|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     15|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  279|       |
  280|     15|	strlcpy(sm_info->config_section, card->sm_ctx.config_section, sizeof(sm_info->config_section));
  ------------------
  |  |   43|     15|#define strlcpy _strlcpy
  ------------------
  281|     15|	sm_info->cmd = cmd;
  282|     15|	sm_info->serialnr = card->serialnr;
  283|     15|	sm_info->card_type = card->type;
  284|     15|	sm_info->sm_type = SM_TYPE_CWA14890;
  ------------------
  |  |   39|     15|#define SM_TYPE_CWA14890	0x400
  ------------------
  285|       |
  286|     15|	rv = iasecc_sm_se_mutual_authentication(card, se_num);
  287|     15|	LOG_TEST_RET(ctx, rv, "iasecc_sm_initialize() MUTUAL AUTHENTICATION failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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:%"SC_FORMAT_LEN_SIZE_T"u) '%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__
  |  |  ------------------
  ------------------
  320|      0|	       cwa_session->mdata_len,
  321|      0|	       sc_dump_hex(cwa_session->mdata, cwa_session->mdata_len));
  322|      0|	if (cwa_session->mdata_len != 0x48)
  ------------------
  |  Branch (322:6): [True: 0, False: 0]
  ------------------
  323|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  324|       |
  325|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  326|       |#else
  327|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  328|       |	return SC_ERROR_NOT_SUPPORTED;
  329|       |#endif
  330|      0|}
iasecc_sm_read_binary:
  593|     14|{
  594|     14|	struct sc_context *ctx = card->ctx;
  595|     14|#ifdef ENABLE_SM
  596|     14|	struct sm_info *sm_info = &card->sm_ctx.info;
  597|     14|	struct sc_remote_data rdata;
  598|     14|	struct iasecc_sm_cmd_update_binary cmd_data;
  599|     14|	int rv;
  600|       |
  601|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  602|     14|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  603|     14|	       "SM read binary: acl:%X, offs:%"SC_FORMAT_LEN_SIZE_T"u, count:%"SC_FORMAT_LEN_SIZE_T"u",
  604|     14|	       se_num, offs, count);
  605|       |
  606|     14|	rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_READ);
  ------------------
  |  |   56|     14|#define SM_CMD_FILE_READ		0x201
  ------------------
  607|     14|	LOG_TEST_RET(ctx, rv, "iasecc_sm_read_binary() SM INITIALIZE 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  608|       |
  609|      0|	cmd_data.offs = offs;
  610|      0|	cmd_data.count = count;
  611|      0|	sm_info->cmd_data = &cmd_data;
  612|       |
  613|      0|	sc_remote_data_init(&rdata);
  614|      0|	rv = iasecc_sm_cmd(card, &rdata);
  615|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  616|       |
  617|      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__
  |  |  ------------------
  ------------------
  618|       |
  619|      0|	rv = sm_release (card, &rdata, buff, count);
  620|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|       |
  622|      0|	rdata.free(&rdata);
  623|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  624|       |#else
  625|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  626|       |	return SC_ERROR_NOT_SUPPORTED;
  627|       |#endif
  628|      0|}
iasecc_sm_delete_file:
  673|      1|{
  674|      1|	struct sc_context *ctx = card->ctx;
  675|      1|#ifdef ENABLE_SM
  676|      1|	struct sm_info *sm_info = &card->sm_ctx.info;
  677|      1|	struct sc_remote_data rdata;
  678|      1|	int rv;
  679|       |
  680|      1|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  681|      1|	sc_log(ctx, "SM delete file: SE#:%X, file-id:%X", se_num, 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__
  |  |  ------------------
  ------------------
  682|       |
  683|      1|	rv = iasecc_sm_initialize(card, se_num, SM_CMD_FILE_DELETE);
  ------------------
  |  |   59|      1|#define SM_CMD_FILE_DELETE		0x204
  ------------------
  684|      1|	LOG_TEST_RET(ctx, rv, "iasecc_sm_delete_file() SM INITIALIZE 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  685|       |
  686|      0|	sm_info->cmd_data = (void *)(uintptr_t)file_id;
  687|       |
  688|      0|	sc_remote_data_init(&rdata);
  689|      0|	rv = iasecc_sm_cmd(card, &rdata);
  690|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_delete_file() SM 'FILE DELETE' 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|	rv = sm_release (card, &rdata, NULL, 0);
  693|      0|	LOG_TEST_RET(ctx, rv, "iasecc_sm_delete_file() 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  694|       |
  695|      0|	rdata.free(&rdata);
  696|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  697|       |#else
  698|       |	LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "built without support of Secure-Messaging");
  699|       |	return SC_ERROR_NOT_SUPPORTED;
  700|       |#endif
  701|      0|}
iasecc-sm.c:iasecc_sm_se_mutual_authentication:
  222|     15|{
  223|     15|	struct sc_context *ctx = card->ctx;
  224|     15|	struct sm_info *sm_info = &card->sm_ctx.info;
  225|     15|	struct iasecc_se_info se;
  226|     15|	struct sc_crt *crt =  &sm_info->session.cwa.params.crt_at;
  227|     15|	struct sc_apdu apdu;
  228|     15|	unsigned char sbuf[0x100];
  229|     15|	int rv, offs;
  230|       |
  231|     15|	memset(&se, 0, sizeof(se));
  232|       |
  233|     15|	se.reference = se_num;
  234|     15|	crt->usage = IASECC_UQB_AT_MUTUAL_AUTHENTICATION;
  ------------------
  |  |  127|     15|#define IASECC_UQB_AT_MUTUAL_AUTHENTICATION	0xC0
  ------------------
  235|     15|	crt->tag = IASECC_CRT_TAG_AT;
  ------------------
  |  |  104|     15|#define IASECC_CRT_TAG_AT	0xA4
  ------------------
  236|       |
  237|     15|	rv = iasecc_se_get_info(card, &se);
  238|     15|	LOG_TEST_RET(ctx, rv, "Get SE info error");
  ------------------
  |  |  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: 9, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|     15|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  239|       |
  240|      6|	rv = iasecc_se_get_crt(card, &se, crt);
  241|      6|	sc_file_free(se.df);
  242|      6|	LOG_TEST_RET(ctx, rv, "Cannot get authentication CRT");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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:
   36|  48.3k|{
   37|  48.3k|	if (card == NULL || apdu == NULL) {
  ------------------
  |  Branch (37:6): [True: 0, False: 48.3k]
  |  Branch (37:22): [True: 0, False: 48.3k]
  ------------------
   38|      0|		return;
   39|      0|	}
   40|       |
   41|  48.3k|	if (apdu->lc > sc_get_max_send_size(card)) {
  ------------------
  |  Branch (41:6): [True: 71, False: 48.3k]
  ------------------
   42|       |		/* The lower layers will automatically do chaining */
   43|     71|		apdu->flags |= SC_APDU_FLAGS_CHAINING;
  ------------------
  |  |  306|     71|#define SC_APDU_FLAGS_CHAINING		0x00000001UL
  ------------------
   44|     71|	}
   45|       |
   46|  48.3k|	if (apdu->le > sc_get_max_recv_size(card)) {
  ------------------
  |  Branch (46:6): [True: 758, False: 47.6k]
  ------------------
   47|       |		/* The lower layers will automatically do a GET RESPONSE, if possible.
   48|       |		 * All other workarounds must be carried out by the upper layers. */
   49|    758|		apdu->le = sc_get_max_recv_size(card);
   50|    758|	}
   51|  48.3k|}
encode_do_data:
  177|  1.56k|{
  178|  1.56k|	unsigned char offset_buffer[2];
  179|  1.56k|	size_t offset_buffer_len = sizeof offset_buffer;
  180|  1.56k|	struct sc_asn1_entry asn1_do_data[sizeof c_asn1_do_data / sizeof *c_asn1_do_data];
  181|  1.56k|	sc_copy_asn1_entry(c_asn1_do_data, asn1_do_data);
  182|       |
  183|  1.56k|	if (idx > 0xFFFF)
  ------------------
  |  Branch (183:6): [True: 0, False: 1.56k]
  ------------------
  184|  1.56k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|  1.56k|	offset_buffer[0] = (u8) (idx >> 8);
  186|  1.56k|	offset_buffer[1] = (u8) (idx & 0x00FF);
  187|  1.56k|	sc_format_asn1_entry(asn1_do_data + 0, offset_buffer, &offset_buffer_len, 1);
  188|       |
  189|  1.56k|	if (data && data_len) {
  ------------------
  |  Branch (189:6): [True: 0, False: 1.56k]
  |  Branch (189:14): [True: 0, False: 0]
  ------------------
  190|      0|		sc_format_asn1_entry(asn1_do_data + 1, (void *) &data, &data_len, 1);
  191|  1.56k|	} else {
  192|  1.56k|		sc_format_asn1_entry(asn1_do_data + 1, NULL, NULL, 0);
  193|  1.56k|	}
  194|       |
  195|  1.56k|	LOG_TEST_RET(ctx,
  ------------------
  |  |  174|  1.56k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.56k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.56k|	int _ret = (r); \
  |  |  |  |  168|  1.56k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.56k]
  |  |  |  |  ------------------
  |  |  |  |  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.56k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.56k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|  1.56k|			sc_asn1_encode(ctx, asn1_do_data, out, outlen),
  197|  1.56k|			"sc_asn1_encode() failed");
  198|       |
  199|  1.56k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.56k|#define SC_SUCCESS				0
  ------------------
  200|  1.56k|}
decode_do_data:
  205|  1.26k|{
  206|  1.26k|	struct sc_asn1_entry asn1_do_data[sizeof c_asn1_do_data / sizeof *c_asn1_do_data];
  207|  1.26k|	sc_copy_asn1_entry(c_asn1_do_data, asn1_do_data);
  208|       |
  209|  1.26k|	sc_format_asn1_entry(asn1_do_data + 0, NULL, NULL, 0);
  210|  1.26k|	sc_format_asn1_entry(asn1_do_data + 1, out, outlen, 0);
  211|       |
  212|  1.26k|	LOG_TEST_RET(ctx,
  ------------------
  |  |  174|  1.26k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.26k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.26k|	int _ret = (r); \
  |  |  |  |  168|  1.26k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 59, False: 1.20k]
  |  |  |  |  ------------------
  |  |  |  |  169|     59|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     59|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     59|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     59|		return _ret; \
  |  |  |  |  172|     59|	} \
  |  |  |  |  173|  1.26k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.20k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  213|  1.20k|			sc_asn1_decode(ctx, asn1_do_data, encoded_data, encoded_data_len, NULL, NULL),
  214|  1.20k|			"sc_asn1_decode() failed");
  215|       |
  216|  1.20k|	if (!(asn1_do_data[1].flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|  1.20k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (216:6): [True: 1.02k, False: 182]
  ------------------
  217|  1.02k|		return SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|  1.02k|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  218|       |
  219|    182|	return SC_SUCCESS;
  ------------------
  |  |   28|    182|#define SC_SUCCESS				0
  ------------------
  220|  1.20k|}
iso7816_build_pin_apdu:
 1189|    810|{
 1190|    810|	int r, len = 0, pad = 0, use_pin_pad = 0, ins, p1 = 0;
 1191|    810|	int cse = SC_APDU_CASE_3_SHORT;
  ------------------
  |  |  293|    810|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
 1192|       |
 1193|    810|	switch (data->pin_type) {
 1194|    805|	case SC_AC_CHV:
  ------------------
  |  |  151|    805|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (1194:2): [True: 805, False: 5]
  ------------------
 1195|       |		/* fall through */
 1196|    805|	case SC_AC_SESSION:
  ------------------
  |  |  159|    805|#define SC_AC_SESSION			0x00000100 /* Session PIN */
  ------------------
  |  Branch (1196:2): [True: 0, False: 810]
  ------------------
 1197|    805|	case SC_AC_CONTEXT_SPECIFIC:
  ------------------
  |  |  160|    805|#define SC_AC_CONTEXT_SPECIFIC		0x00000200 /* Context specific login */
  ------------------
  |  Branch (1197:2): [True: 0, False: 810]
  ------------------
 1198|    805|		break;
 1199|      5|	default:
  ------------------
  |  Branch (1199:2): [True: 5, False: 805]
  ------------------
 1200|      5|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      5|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1201|    810|	}
 1202|       |
 1203|    805|	if (data->flags & SC_PIN_CMD_NEED_PADDING)
  ------------------
  |  |  429|    805|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  |  Branch (1203:6): [True: 57, False: 748]
  ------------------
 1204|     57|		pad = 1;
 1205|    805|	if (data->flags & SC_PIN_CMD_USE_PINPAD)
  ------------------
  |  |  428|    805|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (1205:6): [True: 0, False: 805]
  ------------------
 1206|      0|		use_pin_pad = 1;
 1207|       |
 1208|    805|	data->pin1.offset = 5;
 1209|       |
 1210|    805|	switch (data->cmd) {
 1211|      6|	case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  422|      6|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (1211:2): [True: 6, False: 799]
  ------------------
 1212|      6|		ins = 0x20;
 1213|       |		/* detect overloaded APDU with SC_PIN_CMD_GET_INFO */
 1214|      6|		if (data->pin1.len == 0 && !use_pin_pad)
  ------------------
  |  Branch (1214:7): [True: 3, False: 3]
  |  Branch (1214:30): [True: 3, False: 0]
  ------------------
 1215|      3|			return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      3|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
 1216|      3|		if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1216:7): [True: 0, False: 3]
  ------------------
 1217|      0|			return r;
 1218|      3|		len = r;
 1219|      3|		break;
 1220|    133|	case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  423|    133|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (1220:2): [True: 133, False: 672]
  ------------------
 1221|    133|		ins = 0x24;
 1222|    133|		if (data->pin1.len != 0 || (use_pin_pad && !( data->flags & SC_PIN_CMD_IMPLICIT_CHANGE))) {
  ------------------
  |  |  430|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
  |  Branch (1222:7): [True: 0, False: 133]
  |  Branch (1222:31): [True: 0, False: 133]
  |  Branch (1222:46): [True: 0, False: 0]
  ------------------
 1223|      0|			if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1223:8): [True: 0, False: 0]
  ------------------
 1224|      0|				return r;
 1225|      0|			len += r;
 1226|      0|		}
 1227|    133|		else {
 1228|       |			/* implicit test */
 1229|    133|			p1 = 1;
 1230|    133|		}
 1231|       |
 1232|    133|		data->pin2.offset = data->pin1.offset + len;
 1233|    133|		if ((r = sc_build_pin(buf+len, buf_len-len, &data->pin2, pad)) < 0)
  ------------------
  |  Branch (1233:7): [True: 0, False: 133]
  ------------------
 1234|      0|			return r;
 1235|       |		/* Special case - where provided the old PIN on the command line
 1236|       |		 * but expect the new one to be entered on the keypad.
 1237|       |		 */
 1238|    133|		if (data->pin1.len && data->pin2.len == 0) {
  ------------------
  |  Branch (1238:7): [True: 0, False: 133]
  |  Branch (1238:25): [True: 0, False: 0]
  ------------------
 1239|      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__
  |  |  ------------------
  ------------------
 1240|      0|			data->flags |= SC_PIN_CMD_IMPLICIT_CHANGE;
  ------------------
  |  |  430|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
 1241|      0|		};
 1242|    133|		len += r;
 1243|    133|		break;
 1244|      0|	case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (1244:2): [True: 0, False: 805]
  ------------------
 1245|      0|		ins = 0x2C;
 1246|      0|		if (data->pin1.len != 0 || (use_pin_pad && !( data->flags & SC_PIN_CMD_IMPLICIT_CHANGE))) {
  ------------------
  |  |  430|      0|#define SC_PIN_CMD_IMPLICIT_CHANGE	0x0004
  ------------------
  |  Branch (1246:7): [True: 0, False: 0]
  |  Branch (1246:31): [True: 0, False: 0]
  |  Branch (1246:46): [True: 0, False: 0]
  ------------------
 1247|      0|			if ((r = sc_build_pin(buf, buf_len, &data->pin1, pad)) < 0)
  ------------------
  |  Branch (1247:8): [True: 0, False: 0]
  ------------------
 1248|      0|				return r;
 1249|      0|			len += r;
 1250|      0|		} else {
 1251|      0|			p1 |= 0x02;
 1252|      0|		}
 1253|       |
 1254|      0|		if (data->pin2.len != 0 || use_pin_pad) {
  ------------------
  |  Branch (1254:7): [True: 0, False: 0]
  |  Branch (1254:30): [True: 0, False: 0]
  ------------------
 1255|      0|			data->pin2.offset = data->pin1.offset + len;
 1256|      0|			if ((r = sc_build_pin(buf+len, buf_len-len, &data->pin2, pad)) < 0)
  ------------------
  |  Branch (1256:8): [True: 0, False: 0]
  ------------------
 1257|      0|				return r;
 1258|      0|			len += r;
 1259|      0|		} else {
 1260|      0|			p1 |= 0x01;
 1261|      0|		}
 1262|      0|		if (p1 == 0x03) {
  ------------------
  |  Branch (1262:7): [True: 0, False: 0]
  ------------------
 1263|       |			/* No data to send or to receive */
 1264|      0|			cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 1265|      0|		}
 1266|      0|		break;
 1267|    666|	case SC_PIN_CMD_GET_INFO:
  ------------------
  |  |  425|    666|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1267:2): [True: 666, False: 139]
  ------------------
 1268|    666|		ins = 0x20;
 1269|       |		/* No data to send or to receive */
 1270|    666|		cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|    666|#define SC_APDU_CASE_1			0x01
  ------------------
 1271|    666|		break;
 1272|      0|	default:
  ------------------
  |  Branch (1272:2): [True: 0, False: 805]
  ------------------
 1273|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1274|    805|	}
 1275|       |
 1276|    802|	sc_format_apdu(card, apdu, cse, ins, p1, data->pin_reference);
 1277|    802|	apdu->lc = len;
 1278|    802|	apdu->datalen = len;
 1279|    802|	apdu->data = buf;
 1280|    802|	apdu->resplen = 0;
 1281|       |
 1282|    802|	return 0;
 1283|    805|}
iso7816_select_aid:
 1401|  2.78k|{
 1402|  2.78k|	struct sc_context *ctx = card->ctx;
 1403|  2.78k|	struct sc_apdu apdu;
 1404|  2.78k|	int rv;
 1405|       |
 1406|  2.78k|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
 1407|       |
 1408|  2.78k|	sc_format_apdu(card, &apdu, resp == NULL ? SC_APDU_CASE_3_SHORT : SC_APDU_CASE_4_SHORT, 0xA4, 0x04, resp == NULL ? 0x0C : 0x00);
  ------------------
  |  |  293|  2.07k|#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|    713|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  |  Branch (1408:30): [True: 2.07k, False: 713]
  |  Branch (1408:102): [True: 2.07k, False: 713]
  ------------------
 1409|  2.78k|	apdu.lc = reqlen;
 1410|  2.78k|	apdu.data = req;
 1411|  2.78k|	apdu.datalen = reqlen;
 1412|  2.78k|	apdu.resp = resp;
 1413|  2.78k|	apdu.resplen = resp == NULL ? 0 : *resplen;
  ------------------
  |  Branch (1413:17): [True: 2.07k, False: 713]
  ------------------
 1414|  2.78k|	apdu.le = resp == NULL ? 0 : 256;
  ------------------
  |  Branch (1414:12): [True: 2.07k, False: 713]
  ------------------
 1415|       |
 1416|  2.78k|	rv = sc_transmit_apdu(card, &apdu);
 1417|  2.78k|	if (resplen)
  ------------------
  |  Branch (1417:6): [True: 713, False: 2.07k]
  ------------------
 1418|    713|		*resplen = apdu.resplen;
 1419|  2.78k|	LOG_TEST_RET(card->ctx, rv, "APDU transmit failed");
  ------------------
  |  |  174|  2.78k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.78k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.78k|	int _ret = (r); \
  |  |  |  |  168|  2.78k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2, False: 2.78k]
  |  |  |  |  ------------------
  |  |  |  |  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.78k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.78k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1420|       |
 1421|  2.78k|	rv = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1422|  2.78k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|  2.78k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.78k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.78k|	int _ret = r; \
  |  |  |  |  155|  2.78k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.78k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.78k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.19k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.19k, False: 1.58k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.78k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.78k|	} else { \
  |  |  |  |  159|      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.78k|	return _ret; \
  |  |  |  |  163|  2.78k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1423|  2.78k|}
sc_get_iso7816_driver:
 1491|   113k|{
 1492|   113k|	return &iso_driver;
 1493|   113k|}
iso7816.c:no_match:
 1437|  1.35k|{
 1438|  1.35k|	return 0;
 1439|  1.35k|}
iso7816.c:iso7816_update_binary:
  404|  2.07k|{
  405|  2.07k|	struct sc_apdu apdu;
  406|  2.07k|	int r;
  407|       |
  408|  2.07k|	if (idx > 0x7fff) {
  ------------------
  |  Branch (408:6): [True: 1, False: 2.06k]
  ------------------
  409|      1|		sc_log(card->ctx, "invalid EF offset: 0x%X > 0x7FFF", idx);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  410|      1|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      1|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  411|      1|	}
  412|       |
  413|  2.06k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3, 0xD6, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  302|  2.06k|#define SC_APDU_CASE_3			0x23
  ------------------
  414|  2.06k|	apdu.lc = count;
  415|  2.06k|	apdu.datalen = count;
  416|  2.06k|	apdu.data = buf;
  417|       |
  418|  2.06k|	iso7816_fixup_transceive_length(card, &apdu);
  419|  2.06k|	r = sc_transmit_apdu(card, &apdu);
  420|  2.06k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.06k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.06k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.06k|	int _ret = (r); \
  |  |  |  |  168|  2.06k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  |  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.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  421|  2.06k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  422|  2.06k|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  174|  2.06k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.06k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.06k|	int _ret = (r); \
  |  |  |  |  168|  2.06k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 121, False: 1.94k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.94k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|       |
  424|  1.94k|	LOG_FUNC_RETURN(card->ctx, (int)count);
  ------------------
  |  |  164|  1.94k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.94k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.94k|	int _ret = r; \
  |  |  |  |  155|  1.94k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 1.94k]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define 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.94k|	} else { \
  |  |  |  |  159|  1.94k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.94k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.94k|	} \
  |  |  |  |  162|  1.94k|	return _ret; \
  |  |  |  |  163|  1.94k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  425|  1.94k|}
iso7816.c:iso7816_read_record:
  225|  4.06k|{
  226|  4.06k|	struct sc_apdu apdu;
  227|  4.06k|	int r;
  228|       |	/* XXX maybe use some bigger buffer */
  229|  4.06k|	unsigned char resp[SC_MAX_APDU_RESP_SIZE];
  230|  4.06k|	unsigned char *encoded_data = NULL, *decoded_data = NULL;
  231|  4.06k|	size_t encoded_data_len = 0, decoded_data_len = 0;
  232|       |
  233|  4.06k|	if (rec_nr > 0xFF)
  ------------------
  |  Branch (233:6): [True: 1, False: 4.06k]
  ------------------
  234|  4.06k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|       |
  236|  4.06k|	if (idx == 0) {
  ------------------
  |  Branch (236:6): [True: 2.50k, False: 1.56k]
  ------------------
  237|  2.50k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xB2, rec_nr, 0);
  ------------------
  |  |  301|  2.50k|#define SC_APDU_CASE_2			0x22
  ------------------
  238|  2.50k|		apdu.le = count;
  239|  2.50k|		apdu.resplen = count;
  240|  2.50k|		apdu.resp = buf;
  241|  2.50k|	} else {
  242|  1.56k|		r = encode_do_data(card->ctx, idx, NULL, 0, &encoded_data, &encoded_data_len);
  243|  1.56k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Could not encode data objects");
  ------------------
  |  |  184|  1.56k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.56k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.56k|	int _ret = (r); \
  |  |  |  |  178|  1.56k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 1.56k]
  |  |  |  |  ------------------
  |  |  |  |  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.56k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.56k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  244|       |
  245|  1.56k|		sc_format_apdu(card, &apdu, SC_APDU_CASE_4, 0xB3, rec_nr, 0);
  ------------------
  |  |  303|  1.56k|#define SC_APDU_CASE_4			0x24
  ------------------
  246|  1.56k|		apdu.lc = encoded_data_len;
  247|  1.56k|		apdu.datalen = encoded_data_len;
  248|  1.56k|		apdu.data = encoded_data;
  249|  1.56k|		apdu.le = sizeof resp;
  250|  1.56k|		apdu.resplen = sizeof resp;
  251|  1.56k|		apdu.resp = resp;
  252|  1.56k|	}
  253|  4.06k|	apdu.p2 = (flags & SC_RECORD_EF_ID_MASK) << 3;
  ------------------
  |  | 1300|  4.06k|#define SC_RECORD_EF_ID_MASK		0x0001FUL
  ------------------
  254|  4.06k|	if (flags & SC_RECORD_BY_REC_NR)
  ------------------
  |  | 1305|  4.06k|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
  |  Branch (254:6): [True: 4.06k, False: 0]
  ------------------
  255|  4.06k|		apdu.p2 |= 0x04;
  256|       |
  257|  4.06k|	iso7816_fixup_transceive_length(card, &apdu);
  258|  4.06k|	r = sc_transmit_apdu(card, &apdu);
  259|  4.06k|	LOG_TEST_GOTO_ERR(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  184|  4.06k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.06k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.06k|	int _ret = (r); \
  |  |  |  |  178|  4.06k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 45, False: 4.01k]
  |  |  |  |  ------------------
  |  |  |  |  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|  4.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4.01k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  260|  4.01k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  261|  4.01k|	LOG_TEST_GOTO_ERR(card->ctx, r, "Card returned error");
  ------------------
  |  |  184|  4.01k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.01k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.01k|	int _ret = (r); \
  |  |  |  |  178|  4.01k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 808, False: 3.21k]
  |  |  |  |  ------------------
  |  |  |  |  179|    808|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    808|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    808|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    808|		goto err; \
  |  |  |  |  182|    808|	} \
  |  |  |  |  183|  4.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3.21k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  262|       |
  263|  3.21k|	if (idx == 0) {
  ------------------
  |  Branch (263:6): [True: 1.94k, False: 1.26k]
  ------------------
  264|  1.94k|		r = (int)apdu.resplen;
  265|  1.94k|	} else {
  266|  1.26k|		r = decode_do_data(card->ctx, apdu.resp, apdu.resplen,
  267|  1.26k|				&decoded_data, &decoded_data_len);
  268|  1.26k|		LOG_TEST_GOTO_ERR(card->ctx, r, "Could not decode data objects");
  ------------------
  |  |  184|  1.26k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.26k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.26k|	int _ret = (r); \
  |  |  |  |  178|  1.26k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.08k, False: 182]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.08k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.08k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.08k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.08k|		goto err; \
  |  |  |  |  182|  1.08k|	} \
  |  |  |  |  183|  1.26k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 182]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  269|    182|		if (decoded_data_len <= count) {
  ------------------
  |  Branch (269:7): [True: 152, False: 30]
  ------------------
  270|    152|			count = decoded_data_len;
  271|    152|		}
  272|    182|		memcpy(buf, decoded_data, count);
  273|    182|		r = (int)count;
  274|    182|	}
  275|       |
  276|  4.06k|err:
  277|  4.06k|	free(encoded_data);
  278|  4.06k|	free(decoded_data);
  279|  4.06k|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|  4.06k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.06k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.06k|	int _ret = r; \
  |  |  |  |  155|  4.06k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.25k, False: 1.81k]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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.93k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.93k, False: 317]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.25k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.25k|	} else { \
  |  |  |  |  159|  1.81k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  1.81k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  1.81k|	} \
  |  |  |  |  162|  4.06k|	return _ret; \
  |  |  |  |  163|  4.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  280|  4.06k|}
iso7816.c:iso7816_select_file:
  631|   276k|{
  632|   276k|	struct sc_context *ctx;
  633|   276k|	struct sc_apdu apdu;
  634|   276k|	unsigned char buf[SC_MAX_APDU_BUFFER_SIZE];
  635|   276k|	unsigned char pathbuf[SC_MAX_PATH_SIZE], *path = pathbuf;
  636|   276k|	int r, pathtype;
  637|   276k|	size_t pathlen;
  638|   276k|	int select_mf = 0;
  639|   276k|	struct sc_file *file = NULL;
  640|   276k|	const u8 *buffer;
  641|   276k|	size_t buffer_len;
  642|   276k|	unsigned int cla, tag;
  643|       |
  644|   276k|	if (card == NULL || in_path == NULL) {
  ------------------
  |  Branch (644:6): [True: 0, False: 276k]
  |  Branch (644:22): [True: 0, False: 276k]
  ------------------
  645|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  646|      0|	}
  647|   276k|	ctx = card->ctx;
  648|   276k|	memcpy(path, in_path->value, in_path->len);
  649|   276k|	pathlen = in_path->len;
  650|   276k|	pathtype = in_path->type;
  651|       |
  652|   276k|	if (in_path->aid.len) {
  ------------------
  |  Branch (652:6): [True: 1.06k, False: 275k]
  ------------------
  653|  1.06k|		if (!pathlen) {
  ------------------
  |  Branch (653:7): [True: 401, False: 663]
  ------------------
  654|    401|			memcpy(path, in_path->aid.value, in_path->aid.len);
  655|    401|			pathlen = in_path->aid.len;
  656|    401|			pathtype = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    401|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  657|    663|		} else {
  658|       |			/* First, select the application */
  659|    663|			sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|    663|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  660|    663|			apdu.data = in_path->aid.value;
  661|    663|			apdu.datalen = in_path->aid.len;
  662|    663|			apdu.lc = in_path->aid.len;
  663|       |
  664|    663|			r = sc_transmit_apdu(card, &apdu);
  665|    663|			LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    663|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    663|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    663|	int _ret = (r); \
  |  |  |  |  168|    663|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 655]
  |  |  |  |  ------------------
  |  |  |  |  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|    663|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 655]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  666|    655|			r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  667|    655|			if (r)
  ------------------
  |  Branch (667:8): [True: 53, False: 602]
  ------------------
  668|    655|				LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|     53|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 53, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  669|       |
  670|    602|			if (pathtype == SC_PATH_TYPE_PATH
  ------------------
  |  |  119|  1.20k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (670:8): [True: 58, False: 544]
  ------------------
  671|    544|					|| pathtype == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|    544|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (671:9): [True: 544, False: 0]
  ------------------
  672|    602|				pathtype = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|    602|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  673|    602|		}
  674|  1.06k|	}
  675|       |
  676|   276k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0xA4, 0, 0);
  ------------------
  |  |  294|   276k|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
  677|       |
  678|   276k|	switch (pathtype) {
  679|  41.8k|	case SC_PATH_TYPE_FILE_ID:
  ------------------
  |  |  117|  41.8k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (679:2): [True: 41.8k, False: 234k]
  ------------------
  680|  41.8k|		apdu.p1 = 0;
  681|  41.8k|		if (pathlen != 2)
  ------------------
  |  Branch (681:7): [True: 511, False: 41.3k]
  ------------------
  682|    511|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    511|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  683|  41.3k|		break;
  684|  41.3k|	case SC_PATH_TYPE_DF_NAME:
  ------------------
  |  |  118|  8.60k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (684:2): [True: 8.60k, False: 267k]
  ------------------
  685|  8.60k|		apdu.p1 = 4;
  686|  8.60k|		break;
  687|   217k|	case SC_PATH_TYPE_PATH:
  ------------------
  |  |  119|   217k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (687:2): [True: 217k, False: 58.9k]
  ------------------
  688|   217k|		apdu.p1 = 8;
  689|   217k|		if (pathlen >= 2 && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (689:7): [True: 185k, False: 31.3k]
  |  Branch (689:23): [True: 112k, False: 73.1k]
  ------------------
  690|   112k|			if (pathlen == 2) {	/* only 3F00 supplied */
  ------------------
  |  Branch (690:8): [True: 2.34k, False: 110k]
  ------------------
  691|  2.34k|				select_mf = 1;
  692|  2.34k|				apdu.p1 = 0;
  693|  2.34k|				break;
  694|  2.34k|			}
  695|   110k|			path += 2;
  696|   110k|			pathlen -= 2;
  697|   110k|		}
  698|   214k|		break;
  699|   214k|	case SC_PATH_TYPE_FROM_CURRENT:
  ------------------
  |  |  122|    602|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
  |  Branch (699:2): [True: 602, False: 275k]
  ------------------
  700|    602|		apdu.p1 = 9;
  701|    602|		break;
  702|  7.87k|	case SC_PATH_TYPE_PARENT:
  ------------------
  |  |  123|  7.87k|#define SC_PATH_TYPE_PARENT		5
  ------------------
  |  Branch (702:2): [True: 7.87k, False: 268k]
  ------------------
  703|  7.87k|		apdu.p1 = 3;
  704|  7.87k|		pathlen = 0;
  705|  7.87k|		apdu.cse = SC_APDU_CASE_2_SHORT;
  ------------------
  |  |  292|  7.87k|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  706|  7.87k|		break;
  707|      0|	default:
  ------------------
  |  Branch (707:2): [True: 0, False: 276k]
  ------------------
  708|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  709|   276k|	}
  710|   275k|	apdu.lc = pathlen;
  711|   275k|	apdu.data = path;
  712|   275k|	apdu.datalen = pathlen;
  713|       |
  714|   275k|	if (file_out != NULL) {
  ------------------
  |  Branch (714:6): [True: 263k, False: 12.2k]
  ------------------
  715|   263k|		apdu.p2 = 0;		/* first record, return FCI */
  716|   263k|		apdu.resp = buf;
  717|   263k|		apdu.resplen = sizeof(buf);
  718|   263k|		apdu.le = sc_get_max_recv_size(card) < 256 ? sc_get_max_recv_size(card) : 256;
  ------------------
  |  Branch (718:13): [True: 2.02k, False: 261k]
  ------------------
  719|   263k|	}
  720|  12.2k|	else {
  721|  12.2k|		apdu.p2 = 0x0C;		/* first record, return nothing */
  722|  12.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|  24.4k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (722:14): [True: 0, False: 12.2k]
  ------------------
  723|  12.2k|	}
  724|       |
  725|   275k|	r = sc_transmit_apdu(card, &apdu);
  726|   275k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|   275k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   275k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   275k|	int _ret = (r); \
  |  |  |  |  168|   275k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 33.2k, False: 242k]
  |  |  |  |  ------------------
  |  |  |  |  169|  33.2k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.2k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  33.2k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  33.2k|		return _ret; \
  |  |  |  |  172|  33.2k|	} \
  |  |  |  |  173|   275k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 242k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  727|   242k|	if (file_out == NULL) {
  ------------------
  |  Branch (727:6): [True: 12.2k, False: 230k]
  ------------------
  728|       |		/* For some cards 'SELECT' can be only with request to return FCI/FCP. */
  729|  12.2k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  730|  12.2k|		if (apdu.sw1 == 0x6A && apdu.sw2 == 0x86)   {
  ------------------
  |  Branch (730:7): [True: 1.06k, False: 11.1k]
  |  Branch (730:27): [True: 518, False: 542]
  ------------------
  731|    518|			apdu.p2 = 0x00;
  732|    518|			if (sc_transmit_apdu(card, &apdu) == SC_SUCCESS)
  ------------------
  |  |   28|    518|#define SC_SUCCESS				0
  ------------------
  |  Branch (732:8): [True: 511, False: 7]
  ------------------
  733|    511|				r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  734|    518|		}
  735|  12.2k|		if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (735:7): [True: 0, False: 12.2k]
  ------------------
  736|  12.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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  737|  12.2k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  12.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  12.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  12.2k|	int _ret = r; \
  |  |  |  |  155|  12.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12.2k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  12.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|  7.27k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7.27k, False: 4.96k]
  |  |  |  |  ------------------
  |  |  |  |  157|  12.2k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  12.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|  12.2k|	return _ret; \
  |  |  |  |  163|  12.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  738|  12.2k|	}
  739|       |
  740|   230k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  741|   230k|	if (r)
  ------------------
  |  Branch (741:6): [True: 194k, False: 35.3k]
  ------------------
  742|   230k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|   194k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   194k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   194k|	int _ret = r; \
  |  |  |  |  155|   194k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 194k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   194k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|   194k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 194k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|   194k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   194k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|   194k|	return _ret; \
  |  |  |  |  163|   194k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  743|       |
  744|  35.3k|	if (file_out && (apdu.resplen == 0))   {
  ------------------
  |  Branch (744:6): [True: 35.3k, False: 0]
  |  Branch (744:18): [True: 6.25k, False: 29.1k]
  ------------------
  745|       |		/* For some cards 'SELECT' MF or DF_NAME do not return FCI. */
  746|  6.25k|		if (select_mf || pathtype == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  6.09k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (746:7): [True: 154, False: 6.09k]
  |  Branch (746:20): [True: 750, False: 5.34k]
  ------------------
  747|    904|			file = sc_file_new();
  748|    904|			if (file == NULL)
  ------------------
  |  Branch (748:8): [True: 0, False: 904]
  ------------------
  749|    904|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  750|    904|			file->path = *in_path;
  751|       |
  752|    904|			*file_out = file;
  753|    904|			LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    904|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    904|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    904|	int _ret = r; \
  |  |  |  |  155|    904|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 904, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    904|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 904]
  |  |  |  |  ------------------
  |  |  |  |  157|    904|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    904|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    904|	return _ret; \
  |  |  |  |  163|    904|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  754|    904|		}
  755|  6.25k|	}
  756|       |
  757|  34.4k|	if (apdu.resplen < 2)
  ------------------
  |  Branch (757:6): [True: 5.35k, False: 29.1k]
  ------------------
  758|  34.4k|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  5.35k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  5.35k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  5.35k|	int _ret = r; \
  |  |  |  |  155|  5.35k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 5.35k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  5.35k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.35k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 5.35k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  5.35k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  5.35k|	} else { \
  |  |  |  |  159|      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.35k|	return _ret; \
  |  |  |  |  163|  5.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  759|  29.1k|	switch (apdu.resp[0]) {
  760|  26.1k|	case ISO7816_TAG_FCI:
  ------------------
  |  |   15|  26.1k|#define ISO7816_TAG_FCI			0x6F
  ------------------
  |  Branch (760:2): [True: 26.1k, False: 2.90k]
  ------------------
  761|  26.2k|	case ISO7816_TAG_FCP:
  ------------------
  |  |   17|  26.2k|#define ISO7816_TAG_FCP			0x62
  ------------------
  |  Branch (761:2): [True: 34, False: 29.0k]
  ------------------
  762|  26.2k|		file = sc_file_new();
  763|  26.2k|		if (file == NULL)
  ------------------
  |  Branch (763:7): [True: 0, False: 26.2k]
  ------------------
  764|  26.2k|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  765|  26.2k|		file->path = *in_path;
  766|  26.2k|		if (card->ops->process_fci == NULL) {
  ------------------
  |  Branch (766:7): [True: 0, False: 26.2k]
  ------------------
  767|      0|			sc_file_free(file);
  768|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|      0|		}
  770|  26.2k|		buffer = apdu.resp;
  771|  26.2k|		r = sc_asn1_read_tag(&buffer, apdu.resplen, &cla, &tag, &buffer_len);
  772|  26.2k|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|  26.2k|#define SC_SUCCESS				0
  ------------------
  |  Branch (772:7): [True: 25.6k, False: 534]
  ------------------
  773|  25.6k|			card->ops->process_fci(card, file, buffer, buffer_len);
  774|  26.2k|		*file_out = file;
  775|  26.2k|		break;
  776|    367|	case 0x00: /* proprietary coding */
  ------------------
  |  Branch (776:2): [True: 367, False: 28.7k]
  ------------------
  777|    367|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|    367|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    367|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    367|	int _ret = r; \
  |  |  |  |  155|    367|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 367, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    367|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    367|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 367, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    367|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    367|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    367|	return _ret; \
  |  |  |  |  163|    367|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|  2.50k|	default:
  ------------------
  |  Branch (778:2): [True: 2.50k, False: 26.6k]
  ------------------
  779|  2.50k|		LOG_FUNC_RETURN(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  164|  2.50k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.50k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.50k|	int _ret = r; \
  |  |  |  |  155|  2.50k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.50k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|  2.50k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.50k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.50k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.50k|	return _ret; \
  |  |  |  |  163|  2.50k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  780|  29.1k|	}
  781|       |
  782|  26.2k|	return SC_SUCCESS;
  ------------------
  |  |   28|  26.2k|#define SC_SUCCESS				0
  ------------------
  783|  29.1k|}
iso7816.c:iso7816_get_response:
  906|  24.4k|{
  907|  24.4k|	struct sc_apdu apdu = {0};
  908|  24.4k|	int r;
  909|  24.4k|	size_t rlen;
  910|       |
  911|       |	/* request at most max_recv_size bytes */
  912|  24.4k|	if (*count > sc_get_max_recv_size(card))
  ------------------
  |  Branch (912:6): [True: 608, False: 23.8k]
  ------------------
  913|    608|		rlen = sc_get_max_recv_size(card);
  914|  23.8k|	else
  915|  23.8k|		rlen = *count;
  916|       |
  917|  24.4k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xC0, 0x00, 0x00);
  ------------------
  |  |  301|  24.4k|#define SC_APDU_CASE_2			0x22
  ------------------
  918|  24.4k|	apdu.le      = rlen;
  919|  24.4k|	apdu.resplen = rlen;
  920|  24.4k|	apdu.resp    = buf;
  921|       |	/* don't call GET RESPONSE recursively */
  922|  24.4k|	apdu.flags  |= SC_APDU_FLAGS_NO_GET_RESP;
  ------------------
  |  |  308|  24.4k|#define SC_APDU_FLAGS_NO_GET_RESP	0x00000002UL
  ------------------
  923|       |
  924|  24.4k|	r = sc_transmit_apdu(card, &apdu);
  925|  24.4k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  24.4k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  24.4k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  24.4k|	int _ret = (r); \
  |  |  |  |  168|  24.4k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 410, False: 24.0k]
  |  |  |  |  ------------------
  |  |  |  |  169|    410|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    410|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    410|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    410|		return _ret; \
  |  |  |  |  172|    410|	} \
  |  |  |  |  173|  24.4k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24.0k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  926|       |
  927|  24.0k|	*count = apdu.resplen;
  928|       |
  929|  24.0k|	if (apdu.resplen == 0) {
  ------------------
  |  Branch (929:6): [True: 7.93k, False: 16.0k]
  ------------------
  930|  7.93k|		LOG_FUNC_RETURN(card->ctx, sc_check_sw(card, apdu.sw1, apdu.sw2));
  ------------------
  |  |  164|  7.93k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  7.93k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  7.93k|	int _ret = r; \
  |  |  |  |  155|  7.93k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7.93k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  7.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|  1.54k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.54k, False: 6.39k]
  |  |  |  |  ------------------
  |  |  |  |  157|  7.93k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  7.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|  7.93k|	return _ret; \
  |  |  |  |  163|  7.93k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  931|  7.93k|	}
  932|  16.0k|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (932:6): [True: 5.56k, False: 10.5k]
  |  Branch (932:26): [True: 4.59k, False: 968]
  ------------------
  933|  4.59k|		r = 0;					/* no more data to read */
  934|  11.4k|	else if (apdu.sw1 == 0x61)
  ------------------
  |  Branch (934:11): [True: 7.81k, False: 3.66k]
  ------------------
  935|  7.81k|		r = apdu.sw2 == 0 ? 256 : apdu.sw2;	/* more data to read    */
  ------------------
  |  Branch (935:7): [True: 1.27k, False: 6.54k]
  ------------------
  936|  3.66k|	else if (apdu.sw1 == 0x62 && apdu.sw2 == 0x82)
  ------------------
  |  Branch (936:11): [True: 158, False: 3.50k]
  |  Branch (936:31): [True: 62, False: 96]
  ------------------
  937|     62|		r = 0; /* Le not reached but file/record ended */
  938|  3.60k|	else
  939|  3.60k|		r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  940|       |
  941|  16.0k|	return r;
  942|  24.0k|}
iso7816.c:iso7816_get_challenge:
  788|     14|{
  789|     14|	int r;
  790|     14|	struct sc_apdu apdu;
  791|       |
  792|     14|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x84, 0x00, 0x00);
  ------------------
  |  |  301|     14|#define SC_APDU_CASE_2			0x22
  ------------------
  793|     14|	apdu.le = len;
  794|     14|	apdu.resp = rnd;
  795|     14|	apdu.resplen = len;
  796|       |
  797|     14|	r = sc_transmit_apdu(card, &apdu);
  798|     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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  799|       |
  800|     14|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  801|     14|	LOG_TEST_RET(card->ctx, r, "GET CHALLENGE 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  802|       |
  803|     11|	if (len < apdu.resplen) {
  ------------------
  |  Branch (803:6): [True: 0, False: 11]
  ------------------
  804|      0|		return (int) len;
  805|      0|	}
  806|       |
  807|     11|	return (int) apdu.resplen;
  808|     11|}
iso7816.c:iso7816_create_file:
  877|    148|{
  878|    148|	int r;
  879|    148|	size_t len;
  880|    148|	u8 sbuf[SC_MAX_APDU_BUFFER_SIZE];
  881|    148|	struct sc_apdu apdu;
  882|       |
  883|    148|	len = SC_MAX_APDU_BUFFER_SIZE;
  ------------------
  |  |   34|    148|#define SC_MAX_APDU_BUFFER_SIZE		261 /* takes account of: CLA INS P1 P2 Lc [255 byte of data] Le */
  ------------------
  884|       |
  885|    148|	if (card->ops->construct_fci == NULL)
  ------------------
  |  Branch (885:6): [True: 0, False: 148]
  ------------------
  886|    148|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  887|    148|	r = card->ops->construct_fci(card, file, sbuf, &len);
  888|    148|	LOG_TEST_RET(card->ctx, r, "construct_fci() failed");
  ------------------
  |  |  174|    148|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    148|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    148|	int _ret = (r); \
  |  |  |  |  168|    148|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 142]
  |  |  |  |  ------------------
  |  |  |  |  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|    148|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  889|       |
  890|    142|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE0, 0x00, 0x00);
  ------------------
  |  |  293|    142|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  891|    142|	apdu.lc = len;
  892|    142|	apdu.datalen = len;
  893|    142|	apdu.data = sbuf;
  894|       |
  895|    142|	r = sc_transmit_apdu(card, &apdu);
  896|    142|	LOG_TEST_RET(card->ctx, r, "APDU 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: 0, False: 142]
  |  |  |  |  ------------------
  |  |  |  |  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|    142|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 142]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  897|    142|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  898|    142|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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: 56, False: 86]
  |  |  |  |  ------------------
  |  |  |  |  169|     56|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     56|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     56|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     56|		return _ret; \
  |  |  |  |  172|     56|	} \
  |  |  |  |  173|    142|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 86]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  899|       |
  900|     86|	return r;
  901|    142|}
iso7816.c:iso7816_delete_file:
  947|     34|{
  948|     34|	int r;
  949|     34|	u8 sbuf[2];
  950|     34|	struct sc_apdu apdu;
  951|       |
  952|     34|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|     34|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     34|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     34|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 34]
  |  |  ------------------
  ------------------
  953|     34|	if (path->type != SC_PATH_TYPE_FILE_ID || (path->len != 0 && path->len != 2)) {
  ------------------
  |  |  117|     68|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (953:6): [True: 0, False: 34]
  |  Branch (953:45): [True: 25, False: 9]
  |  Branch (953:63): [True: 0, False: 25]
  ------------------
  954|      0|		sc_log(card->ctx, "File type has to be SC_PATH_TYPE_FILE_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__
  |  |  ------------------
  ------------------
  955|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  956|      0|	}
  957|       |
  958|     34|	if (path->len == 2) {
  ------------------
  |  Branch (958:6): [True: 25, False: 9]
  ------------------
  959|     25|		sbuf[0] = path->value[0];
  960|     25|		sbuf[1] = path->value[1];
  961|     25|		sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xE4, 0x00, 0x00);
  ------------------
  |  |  293|     25|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  962|     25|		apdu.lc = 2;
  963|     25|		apdu.datalen = 2;
  964|     25|		apdu.data = sbuf;
  965|     25|	}
  966|      9|	else   {
  967|       |		/* No file ID given: means currently selected file */
  968|      9|		sc_format_apdu(card, &apdu, SC_APDU_CASE_1, 0xE4, 0x00, 0x00);
  ------------------
  |  |  291|      9|#define SC_APDU_CASE_1			0x01
  ------------------
  969|      9|	}
  970|       |
  971|     34|	r = sc_transmit_apdu(card, &apdu);
  972|     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: 0, False: 34]
  |  |  |  |  ------------------
  |  |  |  |  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|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 34]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  973|     34|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  974|     34|	LOG_TEST_RET(card->ctx, r, "Card returned error");
  ------------------
  |  |  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: 11, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  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|     34|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  975|       |
  976|     23|	return r;
  977|     34|}
iso7816.c:iso7816_check_sw:
  111|   505k|{
  112|   505k|	const int err_count = sizeof(iso7816_errors)/sizeof(iso7816_errors[0]);
  113|   505k|	int i;
  114|       |
  115|       |	/* Handle special cases here */
  116|   505k|	if (sw1 == 0x6C) {
  ------------------
  |  Branch (116:6): [True: 145, False: 505k]
  ------------------
  117|    145|		sc_log(card->ctx, "Wrong length; correct length is %d", sw2);
  ------------------
  |  |   71|    145|#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|    145|		return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|    145|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
  119|    145|	}
  120|   505k|	if (sw1 == 0x90 && sw2 == 0x00)
  ------------------
  |  Branch (120:6): [True: 215k, False: 289k]
  |  Branch (120:21): [True: 211k, False: 3.66k]
  ------------------
  121|   211k|		return SC_SUCCESS;
  ------------------
  |  |   28|   211k|#define SC_SUCCESS				0
  ------------------
  122|   293k|	if (sw1 == 0x63U && (sw2 & ~0x0fU) == 0xc0U) {
  ------------------
  |  Branch (122:6): [True: 22, False: 293k]
  |  Branch (122:22): [True: 2, False: 20]
  ------------------
  123|      2|		sc_log(card->ctx, "PIN not verified (remaining tries: %d)", (sw2 & 0x0f));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  124|      2|		return SC_ERROR_PIN_CODE_INCORRECT;
  ------------------
  |  |   64|      2|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  125|      2|	}
  126|  11.9M|	for (i = 0; i < err_count; i++)   {
  ------------------
  |  Branch (126:14): [True: 11.8M, False: 19.3k]
  ------------------
  127|  11.8M|		if (iso7816_errors[i].SWs == ((sw1 << 8) | sw2)) {
  ------------------
  |  Branch (127:7): [True: 273k, False: 11.6M]
  ------------------
  128|   273k|			sc_log(card->ctx, "%s", iso7816_errors[i].errorstr);
  ------------------
  |  |   71|   273k|#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|   273k|			return iso7816_errors[i].errorno;
  130|   273k|		}
  131|  11.8M|	}
  132|       |
  133|  19.3k|	sc_log(card->ctx, "Unknown SWs; SW1=%02X, SW2=%02X", sw1, sw2);
  ------------------
  |  |   71|  19.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__
  |  |  ------------------
  ------------------
  134|  19.3k|	return SC_ERROR_CARD_CMD_FAILED;
  ------------------
  |  |   50|  19.3k|#define SC_ERROR_CARD_CMD_FAILED		-1200
  ------------------
  135|   293k|}
iso7816.c:iso7816_process_fci:
  431|  20.9k|{
  432|  20.9k|	struct sc_context *ctx = card->ctx;
  433|  20.9k|	const unsigned char *p, *end;
  434|  20.9k|	unsigned int cla = 0, tag = 0;
  435|  20.9k|	size_t length;
  436|       |
  437|  20.9k|	file->status = SC_FILE_STATUS_UNKNOWN;
  ------------------
  |  |  254|  20.9k|#define SC_FILE_STATUS_UNKNOWN		0xff /* if tag 0x8A is missing, there is no information about LCSB */
  ------------------
  438|       |
  439|  20.9k|	for (p = buf, length = buflen, end = buf + buflen;
  440|  95.1k|			p < end;
  ------------------
  |  Branch (440:4): [True: 85.2k, False: 9.87k]
  ------------------
  441|  85.2k|			p += length, length = end - p) {
  442|       |
  443|  85.2k|		if (SC_SUCCESS != sc_asn1_read_tag(&p, length, &cla, &tag, &length)
  ------------------
  |  |   28|  85.2k|#define SC_SUCCESS				0
  ------------------
  |  Branch (443:7): [True: 7.53k, False: 77.7k]
  ------------------
  444|  77.7k|				|| p == NULL) {
  ------------------
  |  Branch (444:8): [True: 3.55k, False: 74.1k]
  ------------------
  445|  11.0k|			break;
  446|  11.0k|		}
  447|  74.1k|		switch (cla | tag) {
  ------------------
  |  Branch (447:11): [True: 68.9k, False: 5.22k]
  ------------------
  448|  7.58k|			case 0x81:
  ------------------
  |  Branch (448:4): [True: 7.58k, False: 66.6k]
  ------------------
  449|  7.58k|				if (file->size != 0) {
  ------------------
  |  Branch (449:9): [True: 1.82k, False: 5.75k]
  ------------------
  450|       |					/* don't overwrite existing file size excluding structural information */
  451|  1.82k|					break;
  452|  1.82k|				}
  453|       |				/* fall through */
  454|  13.2k|			case 0x80:
  ------------------
  |  Branch (454:4): [True: 7.51k, False: 66.6k]
  ------------------
  455|       |				/* determine the file size */
  456|  13.2k|				file->size = 0;
  457|  13.2k|				if (p && length <= sizeof(size_t)) {
  ------------------
  |  Branch (457:9): [True: 13.2k, False: 0]
  |  Branch (457:14): [True: 12.4k, False: 819]
  ------------------
  458|  12.4k|					size_t size = 0, i;
  459|  38.0k|					for (i = 0; i < length; i++) {
  ------------------
  |  Branch (459:18): [True: 25.5k, False: 12.4k]
  ------------------
  460|  25.5k|						size <<= 8;
  461|  25.5k|						size |= p[i];
  462|  25.5k|					}
  463|  12.4k|					if (size > MAX_FILE_SIZE) {
  ------------------
  |  |  229|  12.4k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (463:10): [True: 211, False: 12.2k]
  ------------------
  464|    211|						file->size = MAX_FILE_SIZE;
  ------------------
  |  |  229|    211|#define MAX_FILE_SIZE 65535
  ------------------
  465|    211|						sc_log(ctx, "  file size truncated, encoded length: %"SC_FORMAT_LEN_SIZE_T"u", size);
  ------------------
  |  |   71|    211|#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|  12.2k|					} else {
  467|  12.2k|						file->size = size;
  468|  12.2k|					}
  469|  12.4k|				}
  470|       |
  471|  13.2k|				sc_log(ctx, "  bytes in file: %"SC_FORMAT_LEN_SIZE_T"u", file->size);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  472|  13.2k|				break;
  473|       |
  474|  13.0k|			case 0x82:
  ------------------
  |  Branch (474:4): [True: 13.0k, False: 61.1k]
  ------------------
  475|  13.0k|				if (length > 0) {
  ------------------
  |  Branch (475:9): [True: 12.8k, False: 171]
  ------------------
  476|  12.8k|					unsigned char byte = p[0];
  477|  12.8k|					const char *type;
  478|       |
  479|  12.8k|					file->shareable = byte & 0x40 ? 1 : 0;
  ------------------
  |  Branch (479:24): [True: 413, False: 12.4k]
  ------------------
  480|  12.8k|					sc_log(ctx, "  shareable: %s", (byte & 0x40) ? "yes" : "no");
  ------------------
  |  |   71|  25.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: 413, False: 12.4k]
  |  |  ------------------
  ------------------
  481|  12.8k|					file->ef_structure = byte & 0x07;
  482|  12.8k|					switch ((byte >> 3) & 7) {
  483|  5.64k|						case 0:
  ------------------
  |  Branch (483:7): [True: 5.64k, False: 7.24k]
  ------------------
  484|  5.64k|							type = "working EF";
  485|  5.64k|							file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|  5.64k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  486|  5.64k|							break;
  487|    129|						case 1:
  ------------------
  |  Branch (487:7): [True: 129, False: 12.7k]
  ------------------
  488|    129|							type = "internal EF";
  489|    129|							file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|    129|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  490|    129|							break;
  491|  3.06k|						case 7:
  ------------------
  |  Branch (491:7): [True: 3.06k, False: 9.83k]
  ------------------
  492|  3.06k|							type = "DF";
  493|  3.06k|							file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|  3.06k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  494|  3.06k|							break;
  495|  4.05k|						default:
  ------------------
  |  Branch (495:7): [True: 4.05k, False: 8.84k]
  ------------------
  496|  4.05k|							file->type = SC_FILE_TYPE_UNKNOWN;
  ------------------
  |  |  213|  4.05k|#define SC_FILE_TYPE_UNKNOWN		0x00
  ------------------
  497|  4.05k|							type = "unknown";
  498|  4.05k|							break;
  499|  12.8k|					}
  500|  12.8k|					sc_log(ctx, "  type: %s", type);
  ------------------
  |  |   71|  12.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__
  |  |  ------------------
  ------------------
  501|  12.8k|					sc_log(ctx, "  EF structure: %d", byte & 0x07);
  ------------------
  |  |   71|  12.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__
  |  |  ------------------
  ------------------
  502|  12.8k|					sc_log(ctx, "  tag 0x82: 0x%02x", byte);
  ------------------
  |  |   71|  12.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__
  |  |  ------------------
  ------------------
  503|       |
  504|       |					/* if possible, get additional information for non-DFs */
  505|  12.8k|					if (file->type != SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|  12.8k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (505:10): [True: 9.83k, False: 3.06k]
  ------------------
  506|       |						/* max. record length for fixed- & variable-sized records */
  507|  9.83k|						if (length > 2 && byte & 0x06) {
  ------------------
  |  Branch (507:11): [True: 873, False: 8.95k]
  |  Branch (507:25): [True: 463, False: 410]
  ------------------
  508|    463|							file->record_length = (length > 3)
  ------------------
  |  Branch (508:30): [True: 448, False: 15]
  ------------------
  509|    463|								? bebytes2ushort(p+2)
  510|    463|								: p[2];
  511|    463|							sc_log(ctx, "  record length: %"SC_FORMAT_LEN_SIZE_T"u",
  ------------------
  |  |   71|    463|#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|    463|								file->record_length);
  513|    463|						}
  514|       |
  515|       |						/* number of records */
  516|  9.83k|						if (length > 4) {
  ------------------
  |  Branch (516:11): [True: 844, False: 8.98k]
  ------------------
  517|    844|							file->record_count = (length > 5)
  ------------------
  |  Branch (517:29): [True: 195, False: 649]
  ------------------
  518|    844|								? bebytes2ushort(p+4)
  519|    844|								: p[4];
  520|    844|							sc_log(ctx, "  records: %"SC_FORMAT_LEN_SIZE_T"u",
  ------------------
  |  |   71|    844|#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|    844|								file->record_count);
  522|    844|						}
  523|  9.83k|					}
  524|       |
  525|  12.8k|					if (SC_SUCCESS != sc_file_set_type_attr(file, p, length))
  ------------------
  |  |   28|  12.8k|#define SC_SUCCESS				0
  ------------------
  |  Branch (525:10): [True: 0, False: 12.8k]
  ------------------
  526|      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__
  |  |  ------------------
  ------------------
  527|  12.8k|				}
  528|  13.0k|				break;
  529|       |
  530|  13.0k|			case 0x83:
  ------------------
  |  Branch (530:4): [True: 11.3k, False: 62.8k]
  ------------------
  531|  11.3k|				if (length == 2) {
  ------------------
  |  Branch (531:9): [True: 11.1k, False: 186]
  ------------------
  532|  11.1k|					file->id = (p[0] << 8) | p[1];
  533|  11.1k|					sc_log(ctx, "  file identifier: 0x%02X%02X", p[0], p[1]);
  ------------------
  |  |   71|  11.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__
  |  |  ------------------
  ------------------
  534|  11.1k|				}
  535|  11.3k|				break;
  536|       |
  537|  2.48k|			case 0x84:
  ------------------
  |  Branch (537:4): [True: 2.48k, False: 71.7k]
  ------------------
  538|  2.48k|				if (length > 0 && length <= 16) {
  ------------------
  |  Branch (538:9): [True: 2.16k, False: 318]
  |  Branch (538:23): [True: 2.13k, False: 29]
  ------------------
  539|  2.13k|					memcpy(file->name, p, length);
  540|  2.13k|					file->namelen = length;
  541|       |
  542|  2.13k|					sc_log_hex(ctx, "  File name:", file->name, file->namelen);
  ------------------
  |  |  129|  2.13k|    sc_debug_hex(ctx, SC_LOG_DEBUG_NORMAL, label, data, len)
  |  |  ------------------
  |  |  |  |  127|  2.13k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  543|  2.13k|					if (!file->type)
  ------------------
  |  Branch (543:10): [True: 821, False: 1.31k]
  ------------------
  544|    821|						file->type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|    821|#define SC_FILE_TYPE_DF			0x04
  ------------------
  545|  2.13k|				}
  546|  2.48k|				break;
  547|       |
  548|  8.02k|			case 0x85:
  ------------------
  |  Branch (548:4): [True: 8.02k, False: 66.1k]
  ------------------
  549|  8.03k|			case 0xA5:
  ------------------
  |  Branch (549:4): [True: 7, False: 74.1k]
  ------------------
  550|  8.03k|				if (SC_SUCCESS != sc_file_set_prop_attr(file, p, length)) {
  ------------------
  |  |   28|  8.03k|#define SC_SUCCESS				0
  ------------------
  |  Branch (550:9): [True: 0, False: 8.03k]
  ------------------
  551|      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__
  |  |  ------------------
  ------------------
  552|      0|				}
  553|  8.03k|				break;
  554|       |
  555|  11.4k|			case 0x86:
  ------------------
  |  Branch (555:4): [True: 11.4k, False: 62.7k]
  ------------------
  556|  11.4k|				if (SC_SUCCESS != sc_file_set_sec_attr(file, p, length)) {
  ------------------
  |  |   28|  11.4k|#define SC_SUCCESS				0
  ------------------
  |  Branch (556:9): [True: 0, False: 11.4k]
  ------------------
  557|      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__
  |  |  ------------------
  ------------------
  558|      0|				}
  559|  11.4k|				break;
  560|       |
  561|      5|			case 0x88:
  ------------------
  |  Branch (561:4): [True: 5, False: 74.1k]
  ------------------
  562|      5|				if (length == 1) {
  ------------------
  |  Branch (562:9): [True: 2, False: 3]
  ------------------
  563|      2|					file->sid = *p;
  564|      2|					sc_log(ctx, "  short file identifier: 0x%02X", *p);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  565|      2|				}
  566|      5|				break;
  567|       |
  568|  6.74k|			case 0x8A:
  ------------------
  |  Branch (568:4): [True: 6.74k, False: 67.4k]
  ------------------
  569|  6.74k|				if (length == 1) {
  ------------------
  |  Branch (569:9): [True: 6.72k, False: 19]
  ------------------
  570|  6.72k|					switch (p[0]) {
  571|     43|						case 0:
  ------------------
  |  Branch (571:7): [True: 43, False: 6.68k]
  ------------------
  572|     43|							file->status =SC_FILE_STATUS_NO_INFO;
  ------------------
  |  |  243|     43|#define SC_FILE_STATUS_NO_INFO		0x04 /* ISO7816-4: No information given, (0) */
  ------------------
  573|     43|							break;
  574|  5.82k|						case 1:
  ------------------
  |  Branch (574:7): [True: 5.82k, False: 902]
  ------------------
  575|  5.82k|							file->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|  5.82k|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  576|  5.82k|							break;
  577|     13|						case 3:
  ------------------
  |  Branch (577:7): [True: 13, False: 6.71k]
  ------------------
  578|     13|							file->status = SC_FILE_STATUS_INITIALISATION;
  ------------------
  |  |  242|     13|#define SC_FILE_STATUS_INITIALISATION	0x03 /* ISO7816-4: Initialisation state, (3) */
  ------------------
  579|     13|							break;
  580|      6|						case 4:
  ------------------
  |  Branch (580:7): [True: 6, False: 6.72k]
  ------------------
  581|      6|						case 6:
  ------------------
  |  Branch (581:7): [True: 0, False: 6.72k]
  ------------------
  582|      6|							file->status = SC_FILE_STATUS_INVALIDATED;
  ------------------
  |  |  237|      6|#define SC_FILE_STATUS_INVALIDATED	0x01 /* ISO7816-4: Operational state (deactivated) (4, 6) */
  ------------------
  583|      6|							break;
  584|    371|						case 5:
  ------------------
  |  Branch (584:7): [True: 371, False: 6.35k]
  ------------------
  585|    373|						case 7:
  ------------------
  |  Branch (585:7): [True: 2, False: 6.72k]
  ------------------
  586|    373|							file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|    373|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  587|    373|							break;
  588|     21|						case 12:
  ------------------
  |  Branch (588:7): [True: 21, False: 6.70k]
  ------------------
  589|     23|						case 13:
  ------------------
  |  Branch (589:7): [True: 2, False: 6.72k]
  ------------------
  590|     23|						case 14:
  ------------------
  |  Branch (590:7): [True: 0, False: 6.72k]
  ------------------
  591|     23|						case 15:
  ------------------
  |  Branch (591:7): [True: 0, False: 6.72k]
  ------------------
  592|     23|							file->status = SC_FILE_STATUS_TERMINATION;
  ------------------
  |  |  244|     23|#define SC_FILE_STATUS_TERMINATION	0x0c /* ISO7816-4: Termination state (12,13,14,15) */
  ------------------
  593|     23|							break;
  594|     73|						case 2:
  ------------------
  |  Branch (594:7): [True: 73, False: 6.65k]
  ------------------
  595|     73|							file->status = SC_FILE_STATUS_RFU_2;
  ------------------
  |  |  248|     73|#define SC_FILE_STATUS_RFU_2		0x07 /* ISO7816-4: (0x02) */
  ------------------
  596|     73|							break;
  597|      4|						case 8:
  ------------------
  |  Branch (597:7): [True: 4, False: 6.72k]
  ------------------
  598|      4|							file->status = SC_FILE_STATUS_RFU_8;
  ------------------
  |  |  249|      4|#define SC_FILE_STATUS_RFU_8		0x08 /* ISO7816-4: (0x08) */
  ------------------
  599|      4|							break;
  600|     67|						case 9:
  ------------------
  |  Branch (600:7): [True: 67, False: 6.66k]
  ------------------
  601|     67|							file->status = SC_FILE_STATUS_RFU_9;
  ------------------
  |  |  250|     67|#define SC_FILE_STATUS_RFU_9		0x09 /* ISO7816-4: (0x09) */
  ------------------
  602|     67|							break;
  603|    131|						case 10:
  ------------------
  |  Branch (603:7): [True: 131, False: 6.59k]
  ------------------
  604|    131|							file->status = SC_FILE_STATUS_RFU_10;
  ------------------
  |  |  251|    131|#define SC_FILE_STATUS_RFU_10		0x0a /* ISO7816-4: (0x0a) */
  ------------------
  605|    131|							break;
  606|      2|						case 11:
  ------------------
  |  Branch (606:7): [True: 2, False: 6.72k]
  ------------------
  607|      2|							file->status = SC_FILE_STATUS_RFU_11;
  ------------------
  |  |  252|      2|#define SC_FILE_STATUS_RFU_11		0x0b /* ISO7816-4: (0x0b) */
  ------------------
  608|      2|							break;
  609|    167|						default:
  ------------------
  |  Branch (609:7): [True: 167, False: 6.56k]
  ------------------
  610|    167|							file->status = SC_FILE_STATUS_PROPRIETARY;
  ------------------
  |  |  245|    167|#define SC_FILE_STATUS_PROPRIETARY	0xf0 /* ISO7816-4: codes > 15 */
  ------------------
  611|  6.72k|					}
  612|  6.72k|				}
  613|  6.74k|				break;
  614|       |
  615|  6.74k|			case 0x62:
  ------------------
  |  Branch (615:4): [True: 0, False: 74.1k]
  ------------------
  616|      3|			case 0x64:
  ------------------
  |  Branch (616:4): [True: 3, False: 74.1k]
  ------------------
  617|    750|			case 0x6F:
  ------------------
  |  Branch (617:4): [True: 747, False: 73.4k]
  ------------------
  618|       |				/* allow nested FCP/FMD/FCI templates */
  619|    750|				iso7816_process_fci(card, file, p, length);
  620|  74.1k|		}
  621|  74.1k|	}
  622|       |
  623|  20.9k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|  20.9k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  624|       |
  625|  20.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  20.9k|#define SC_SUCCESS				0
  ------------------
  626|  20.9k|}
iso7816.c:iso7816_construct_fci:
  814|    113|{
  815|    113|	u8 *p = out;
  816|    113|	u8 buf[64];
  817|       |
  818|    113|	if (*outlen < 2)
  ------------------
  |  Branch (818:6): [True: 0, False: 113]
  ------------------
  819|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  820|    113|	*p++ = 0x6F;
  821|    113|	p++;
  822|       |
  823|    113|	buf[0] = (file->size >> 8) & 0xFF;
  824|    113|	buf[1] = file->size & 0xFF;
  825|    113|	sc_asn1_put_tag(0x81, buf, 2, p, *outlen - (p - out), &p);
  826|       |
  827|    113|	if (file->type_attr_len) {
  ------------------
  |  Branch (827:6): [True: 44, False: 69]
  ------------------
  828|     44|		if (sizeof(buf) < file->type_attr_len)
  ------------------
  |  Branch (828:7): [True: 0, False: 44]
  ------------------
  829|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  830|     44|		memcpy(buf, file->type_attr, file->type_attr_len);
  831|     44|		sc_asn1_put_tag(0x82, buf, file->type_attr_len,
  832|     44|				p, *outlen - (p - out), &p);
  833|     69|	} else {
  834|     69|		buf[0] = file->shareable ? 0x40 : 0;
  ------------------
  |  Branch (834:12): [True: 0, False: 69]
  ------------------
  835|     69|		switch (file->type) {
  836|      1|		case SC_FILE_TYPE_INTERNAL_EF:
  ------------------
  |  |  215|      1|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (836:3): [True: 1, False: 68]
  ------------------
  837|      1|			buf[0] |= 0x08;
  838|       |			/* fall through */
  839|     36|		case SC_FILE_TYPE_WORKING_EF:
  ------------------
  |  |  216|     36|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (839:3): [True: 35, False: 34]
  ------------------
  840|     36|			buf[0] |= file->ef_structure & 7;
  841|     36|			break;
  842|     30|		case SC_FILE_TYPE_DF:
  ------------------
  |  |  214|     30|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (842:3): [True: 30, False: 39]
  ------------------
  843|     30|			buf[0] |= 0x38;
  844|     30|			break;
  845|      3|		default:
  ------------------
  |  Branch (845:3): [True: 3, False: 66]
  ------------------
  846|      3|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  847|     69|		}
  848|     66|		sc_asn1_put_tag(0x82, buf, 1, p, *outlen - (p - out), &p);
  849|     66|	}
  850|    110|	buf[0] = (file->id >> 8) & 0xFF;
  851|    110|	buf[1] = file->id & 0xFF;
  852|    110|	sc_asn1_put_tag(0x83, buf, 2, p, *outlen - (p - out), &p);
  853|       |	/* 0x84 = DF name */
  854|    110|	if (file->prop_attr_len) {
  ------------------
  |  Branch (854:6): [True: 46, False: 64]
  ------------------
  855|     46|		if (sizeof(buf) < file->prop_attr_len)
  ------------------
  |  Branch (855:7): [True: 0, False: 46]
  ------------------
  856|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  857|     46|		memcpy(buf, file->prop_attr, file->prop_attr_len);
  858|     46|		sc_asn1_put_tag(0x85, buf, file->prop_attr_len,
  859|     46|				p, *outlen - (p - out), &p);
  860|     46|	}
  861|    110|	if (file->sec_attr_len) {
  ------------------
  |  Branch (861:6): [True: 100, False: 10]
  ------------------
  862|    100|		if (sizeof(buf) < file->sec_attr_len)
  ------------------
  |  Branch (862:7): [True: 0, False: 100]
  ------------------
  863|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  864|    100|		memcpy(buf, file->sec_attr, file->sec_attr_len);
  865|    100|		sc_asn1_put_tag(0x86, buf, file->sec_attr_len,
  866|    100|				p, *outlen - (p - out), &p);
  867|    100|	}
  868|    110|	out[1] = p - out - 2;
  869|       |
  870|    110|	*outlen = p - out;
  871|    110|	return 0;
  872|    110|}
iso7816.c:iso7816_pin_cmd:
 1288|    928|{
 1289|    928|	struct sc_apdu local_apdu, *apdu;
 1290|    928|	int r;
 1291|    928|	u8  sbuf[SC_MAX_APDU_BUFFER_SIZE];
 1292|       |
 1293|    928|	data->pin1.tries_left = -1;
 1294|       |
 1295|       |	/* Many cards do support PIN status queries, but some cards don't and
 1296|       |	 * mistakenly count the command as a failed PIN attempt, so for now we
 1297|       |	 * allow cards with this flag.  In future this may be reduced to a
 1298|       |	 * blocklist, subject to testing more cards. */
 1299|    928|	if (data->cmd == SC_PIN_CMD_GET_INFO &&
  ------------------
  |  |  425|  1.85k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1299:6): [True: 781, False: 147]
  ------------------
 1300|    781|	    !(card->caps & SC_CARD_CAP_ISO7816_PIN_INFO)) {
  ------------------
  |  |  560|    781|#define SC_CARD_CAP_ISO7816_PIN_INFO	0x00000008
  ------------------
  |  Branch (1300:6): [True: 115, False: 666]
  ------------------
 1301|    115|		sc_log(card->ctx, "Card does not support PIN status queries");
  ------------------
  |  |   71|    115|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1302|    115|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    115|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1303|    115|	}
 1304|       |
 1305|       |	/* See if we've been called from another card driver, which is
 1306|       |	 * passing an APDU to us (this allows to write card drivers
 1307|       |	 * whose PIN functions behave "mostly like ISO" except in some
 1308|       |	 * special circumstances.
 1309|       |	 */
 1310|    813|	if (data->apdu == NULL) {
  ------------------
  |  Branch (1310:6): [True: 810, False: 3]
  ------------------
 1311|    810|		r = iso7816_build_pin_apdu(card, &local_apdu, data, sbuf, sizeof(sbuf));
 1312|    810|		if (r < 0)
  ------------------
  |  Branch (1312:7): [True: 8, False: 802]
  ------------------
 1313|      8|			return r;
 1314|    802|		data->apdu = &local_apdu;
 1315|    802|	}
 1316|    805|	apdu = data->apdu;
 1317|       |
 1318|    805|	if (!(data->flags & SC_PIN_CMD_USE_PINPAD) || data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  428|    805|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
              	if (!(data->flags & SC_PIN_CMD_USE_PINPAD) || data->cmd == SC_PIN_CMD_GET_INFO) {
  ------------------
  |  |  425|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1318:6): [True: 805, False: 0]
  |  Branch (1318:48): [True: 0, False: 0]
  ------------------
 1319|       |		/* Transmit the APDU to the card */
 1320|    805|		r = sc_transmit_apdu(card, apdu);
 1321|       |
 1322|       |		/* Clear the buffer - it may contain pins */
 1323|    805|		sc_mem_clear(sbuf, sizeof(sbuf));
 1324|    805|	}
 1325|      0|	else {
 1326|       |		/* Call the reader driver to collect
 1327|       |		 * the PIN and pass on the APDU to the card */
 1328|      0|		if (data->pin1.offset == 0) {
  ------------------
  |  Branch (1328:7): [True: 0, False: 0]
  ------------------
 1329|      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__
  |  |  ------------------
  ------------------
 1330|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1331|      0|		}
 1332|      0|		if (card->reader && card->reader->ops && card->reader->ops->perform_verify) {
  ------------------
  |  Branch (1332:7): [True: 0, False: 0]
  |  Branch (1332:23): [True: 0, False: 0]
  |  Branch (1332:44): [True: 0, False: 0]
  ------------------
 1333|      0|			r = card->reader->ops->perform_verify(card->reader, data);
 1334|       |			/* sw1/sw2 filled in by reader driver */
 1335|      0|		}
 1336|      0|		else {
 1337|      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__
  |  |  ------------------
  ------------------
 1338|      0|					"PIN entry through reader key pad");
 1339|      0|			r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1340|      0|		}
 1341|      0|	}
 1342|       |
 1343|       |	/* Don't pass references to local variables up to the caller. */
 1344|    805|	if (data->apdu == &local_apdu)
  ------------------
  |  Branch (1344:6): [True: 802, False: 3]
  ------------------
 1345|    802|		data->apdu = NULL;
 1346|       |
 1347|    805|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    805|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    805|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    805|	int _ret = (r); \
  |  |  |  |  168|    805|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 805]
  |  |  |  |  ------------------
  |  |  |  |  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|    805|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 805]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1348|    805|	r = sc_check_sw(card, apdu->sw1, apdu->sw2);
 1349|       |
 1350|    805|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    805|#define SC_SUCCESS				0
  ------------------
  |  Branch (1350:6): [True: 528, False: 277]
  ------------------
 1351|    528|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_IN;
  ------------------
  |  |  439|    528|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
 1352|    528|	} else if (r == SC_ERROR_PIN_CODE_INCORRECT) {
  ------------------
  |  |   64|    277|#define SC_ERROR_PIN_CODE_INCORRECT		-1214
  ------------------
  |  Branch (1352:13): [True: 0, False: 277]
  ------------------
 1353|      0|		data->pin1.tries_left = apdu->sw2 & 0xF;
 1354|      0|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  438|      0|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 1355|      0|		if (data->cmd == SC_PIN_CMD_GET_INFO)
  ------------------
  |  |  425|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1355:7): [True: 0, False: 0]
  ------------------
 1356|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1357|    277|	} else if (r == SC_ERROR_AUTH_METHOD_BLOCKED) {
  ------------------
  |  |   62|    277|#define SC_ERROR_AUTH_METHOD_BLOCKED		-1212
  ------------------
  |  Branch (1357:13): [True: 1, False: 276]
  ------------------
 1358|      1|		data->pin1.tries_left = 0;
 1359|      1|		data->pin1.logged_in = SC_PIN_STATE_LOGGED_OUT;
  ------------------
  |  |  438|      1|#define SC_PIN_STATE_LOGGED_OUT 1
  ------------------
 1360|      1|		if (data->cmd == SC_PIN_CMD_GET_INFO)
  ------------------
  |  |  425|      1|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (1360:7): [True: 0, False: 1]
  ------------------
 1361|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1362|      1|	}
 1363|       |
 1364|    805|	return r;
 1365|    805|}
iso7816.c:iso7816_get_data:
 1369|    234|{
 1370|    234|	int                             r, cse;
 1371|    234|	struct sc_apdu                  apdu;
 1372|       |
 1373|    234|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    234|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    234|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    234|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 234]
  |  |  ------------------
  ------------------
 1374|       |
 1375|    234|	if (buf && len)
  ------------------
  |  Branch (1375:6): [True: 234, False: 0]
  |  Branch (1375:13): [True: 234, False: 0]
  ------------------
 1376|    234|		cse = SC_APDU_CASE_2;
  ------------------
  |  |  301|    234|#define SC_APDU_CASE_2			0x22
  ------------------
 1377|      0|	else
 1378|      0|		cse = SC_APDU_CASE_1;
  ------------------
  |  |  291|      0|#define SC_APDU_CASE_1			0x01
  ------------------
 1379|       |
 1380|    234|	sc_format_apdu(card, &apdu, cse, 0xCA, (tag >> 8) & 0xff, tag & 0xff);
 1381|    234|	apdu.le = len;
 1382|    234|	apdu.resp = buf;
 1383|    234|	apdu.resplen = len;
 1384|    234|	r = sc_transmit_apdu(card, &apdu);
 1385|    234|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|    234|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    234|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    234|	int _ret = (r); \
  |  |  |  |  168|    234|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 233]
  |  |  |  |  ------------------
  |  |  |  |  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|    234|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 233]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1386|       |
 1387|    233|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
 1388|    233|	LOG_TEST_RET(card->ctx, r, "GET_DATA returned error");
  ------------------
  |  |  174|    233|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    233|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    233|	int _ret = (r); \
  |  |  |  |  168|    233|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 137, False: 96]
  |  |  |  |  ------------------
  |  |  |  |  169|    137|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    137|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    137|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    137|		return _ret; \
  |  |  |  |  172|    137|	} \
  |  |  |  |  173|    233|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 96]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1389|       |
 1390|     96|	if (apdu.resplen > len)
  ------------------
  |  Branch (1390:6): [True: 0, False: 96]
  ------------------
 1391|      0|		r = SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 1392|     96|	else
 1393|     96|		r = (int)apdu.resplen;
 1394|       |
 1395|     96|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|     96|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     96|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     96|	int _ret = r; \
  |  |  |  |  155|     96|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 89, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  156|     89|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 89]
  |  |  |  |  ------------------
  |  |  |  |  157|     89|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     89|	} 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|     96|	return _ret; \
  |  |  |  |  163|     96|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1396|     96|}
iso7816.c:iso7816_read_binary:
  140|  42.2k|{
  141|  42.2k|	struct sc_context *ctx = card->ctx;
  142|  42.2k|	struct sc_apdu apdu;
  143|  42.2k|	int r;
  144|       |
  145|  42.2k|	if (idx > 0x7FFF) {
  ------------------
  |  Branch (145:6): [True: 3, False: 42.2k]
  ------------------
  146|      3|		sc_log(ctx, "invalid EF offset: 0x%X > 0x7FFF", idx);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  147|      3|		return SC_ERROR_OFFSET_TOO_LARGE;
  ------------------
  |  |   96|      3|#define SC_ERROR_OFFSET_TOO_LARGE		-1415
  ------------------
  148|      3|	}
  149|       |
  150|  42.2k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0xB0, (idx >> 8) & 0x7F, idx & 0xFF);
  ------------------
  |  |  301|  42.2k|#define SC_APDU_CASE_2			0x22
  ------------------
  151|  42.2k|	apdu.le = count;
  152|  42.2k|	apdu.resplen = count;
  153|  42.2k|	apdu.resp = buf;
  154|       |
  155|  42.2k|	iso7816_fixup_transceive_length(card, &apdu);
  156|  42.2k|	r = sc_transmit_apdu(card, &apdu);
  157|  42.2k|	LOG_TEST_RET(ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  42.2k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  42.2k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  42.2k|	int _ret = (r); \
  |  |  |  |  168|  42.2k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.99k, False: 40.2k]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.99k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.99k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.99k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.99k|		return _ret; \
  |  |  |  |  172|  1.99k|	} \
  |  |  |  |  173|  42.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 40.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|       |
  159|  40.2k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  160|  40.2k|	if (r == SC_ERROR_FILE_END_REACHED || r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   69|  80.5k|#define SC_ERROR_FILE_END_REACHED		-1219
  ------------------
              	if (r == SC_ERROR_FILE_END_REACHED || r == SC_ERROR_INCORRECT_PARAMETERS)
  ------------------
  |  |   55|  39.5k|#define SC_ERROR_INCORRECT_PARAMETERS		-1205
  ------------------
  |  Branch (160:6): [True: 672, False: 39.5k]
  |  Branch (160:40): [True: 357, False: 39.2k]
  ------------------
  161|  40.2k|		LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|  1.02k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.02k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.02k|	int _ret = r; \
  |  |  |  |  155|  1.02k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 308, False: 721]
  |  |  |  |  ------------------
  |  |  |  |  156|    308|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 308]
  |  |  |  |  ------------------
  |  |  |  |  157|    308|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    721|	} else { \
  |  |  |  |  159|    721|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    721|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    721|	} \
  |  |  |  |  162|  1.02k|	return _ret; \
  |  |  |  |  163|  1.02k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|  39.2k|	LOG_TEST_RET(ctx, r, "Check SW error");
  ------------------
  |  |  174|  39.2k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  39.2k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  39.2k|	int _ret = (r); \
  |  |  |  |  168|  39.2k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 16.9k, False: 22.2k]
  |  |  |  |  ------------------
  |  |  |  |  169|  16.9k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.9k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  16.9k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  16.9k|		return _ret; \
  |  |  |  |  172|  16.9k|	} \
  |  |  |  |  173|  39.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 22.2k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  163|       |
  164|  22.2k|	LOG_FUNC_RETURN(ctx, (int)apdu.resplen);
  ------------------
  |  |  164|  22.2k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  22.2k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  22.2k|	int _ret = r; \
  |  |  |  |  155|  22.2k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.88k, False: 20.3k]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.88k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.88k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  20.3k|	} else { \
  |  |  |  |  159|  20.3k|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|  20.3k|			"returning with: %d\n", _ret); \
  |  |  |  |  161|  20.3k|	} \
  |  |  |  |  162|  22.2k|	return _ret; \
  |  |  |  |  163|  22.2k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|  22.2k|}

sc_do_log:
   58|  12.1M|{
   59|  12.1M|	va_list ap;
   60|       |
   61|  12.1M|	va_start(ap, format);
   62|  12.1M|	sc_do_log_va(ctx, level, file, line, func, 0, format, ap);
   63|       |	va_end(ap);
   64|  12.1M|}
sc_do_log_color:
   67|  5.18M|{
   68|  5.18M|	va_list ap;
   69|       |
   70|  5.18M|	va_start(ap, format);
   71|  5.18M|	sc_do_log_va(ctx, level, file, line, func, color, format, ap);
   72|       |	va_end(ap);
   73|  5.18M|}
sc_do_log_openssl:
   77|      1|{
   78|      1|	BIO *bio = NULL;
   79|      1|	int length, rc;
   80|      1|	char *buffer = NULL;
   81|       |
   82|      1|	if ((bio = BIO_new(BIO_s_mem())) == NULL) {
  ------------------
  |  Branch (82:6): [True: 0, False: 1]
  ------------------
   83|      0|		sc_do_log(ctx, level, file, line, func, "Cannot log OpenSSL error");
   84|      0|		goto end;
   85|      0|	}
   86|      1|	ERR_print_errors(bio);
   87|       |
   88|      1|	length = BIO_pending(bio);
   89|      1|	if (length <= 0) {
  ------------------
  |  Branch (89:6): [True: 0, False: 1]
  ------------------
   90|       |		/* no error? */
   91|      0|		goto end;
   92|      0|	}
   93|       |	/* trailing null byte */
   94|      1|	buffer = malloc(length + 1);
   95|      1|	if (buffer == NULL) {
  ------------------
  |  Branch (95:6): [True: 0, False: 1]
  ------------------
   96|      0|		sc_do_log(ctx, level, file, line, func, "No memory!");
   97|      0|		goto end;
   98|      0|	}
   99|      1|	rc = BIO_read(bio, buffer, length);
  100|      1|	buffer[length] = '\0';
  101|      1|	if (rc <= 0) {
  ------------------
  |  Branch (101:6): [True: 0, False: 1]
  ------------------
  102|      0|		sc_do_log(ctx, level, file, line, func, "Cannot read OpenSSL error");
  103|      0|		goto end;
  104|      0|	}
  105|       |
  106|      1|	sc_do_log(ctx, level, file, line, func, "OpenSSL error\n%s", buffer);
  107|      1|end:
  108|      1|	free(buffer);
  109|      1|	BIO_free(bio);
  110|      1|}
_sc_debug_hex:
  343|   359k|{
  344|   359k|	size_t blen = len * 5 + 128;
  345|   359k|	char *buf = malloc(blen);
  346|   359k|	if (buf == NULL)
  ------------------
  |  Branch (346:6): [True: 0, False: 359k]
  ------------------
  347|      0|		return;
  348|       |
  349|   359k|	sc_hex_dump(data, len, buf, blen);
  350|       |
  351|   359k|	if (label)
  ------------------
  |  Branch (351:6): [True: 359k, False: 0]
  ------------------
  352|   359k|		sc_do_log(ctx, type, file, line, func,
  353|   359k|			"\n%s (%"SC_FORMAT_LEN_SIZE_T"u byte%s):\n%s",
  354|   359k|			label, len, len==1?"":"s", buf);
  ------------------
  |  Branch (354:16): [True: 585, False: 359k]
  ------------------
  355|      0|	else
  356|      0|		sc_do_log(ctx, type, file, line, func,
  357|      0|			"%"SC_FORMAT_LEN_SIZE_T"u byte%s:\n%s",
  358|      0|			len, len==1?"":"s", buf);
  ------------------
  |  Branch (358:9): [True: 0, False: 0]
  ------------------
  359|       |
  360|   359k|	free(buf);
  361|   359k|}
sc_hex_dump:
  364|   359k|{
  365|   359k|	char *p = buf;
  366|   359k|	size_t p_len = len;
  367|   359k|	int lines = 0;
  368|       |
  369|   359k|	if (buf == NULL || (in == NULL && count != 0)) {
  ------------------
  |  Branch (369:6): [True: 0, False: 359k]
  |  Branch (369:22): [True: 243, False: 359k]
  |  Branch (369:36): [True: 0, False: 243]
  ------------------
  370|      0|		return;
  371|      0|	}
  372|   359k|	buf[0] = 0;
  373|   359k|	if ((count * 5) > len)
  ------------------
  |  Branch (373:6): [True: 0, False: 359k]
  ------------------
  374|      0|		return;
  375|  2.08M|	while (count) {
  ------------------
  |  Branch (375:9): [True: 1.73M, False: 359k]
  ------------------
  376|  1.73M|		char ascbuf[17];
  377|  1.73M|		size_t i;
  378|       |
  379|  26.1M|		for (i = 0; i < count && i < 16; i++) {
  ------------------
  |  Branch (379:15): [True: 25.7M, False: 328k]
  |  Branch (379:28): [True: 24.3M, False: 1.40M]
  ------------------
  380|  24.3M|			sprintf(p, "%02X ", *in);
  381|  24.3M|			if (isprint(*in))
  ------------------
  |  Branch (381:8): [True: 13.2M, False: 11.1M]
  ------------------
  382|  13.2M|				ascbuf[i] = *in;
  383|  11.1M|			else
  384|  11.1M|				ascbuf[i] = '.';
  385|  24.3M|			p += 3;
  386|  24.3M|			p_len -= 3;
  387|  24.3M|			in++;
  388|  24.3M|		}
  389|  1.73M|		count -= i;
  390|  1.73M|		ascbuf[i] = 0;
  391|  3.66M|		for (; i < 16 && lines; i++) {
  ------------------
  |  Branch (391:10): [True: 2.05M, False: 1.61M]
  |  Branch (391:20): [True: 1.93M, False: 111k]
  ------------------
  392|  1.93M|			strlcat(p, "   ", p_len);
  393|  1.93M|			p += 3;
  394|  1.93M|			p_len -= 3;
  395|  1.93M|		}
  396|  1.73M|		snprintf(p, p_len, "%s\n", ascbuf);
  397|  1.73M|		p += strlen(ascbuf) + 1;
  398|  1.73M|		p_len -= strlen(ascbuf) - 1;
  399|  1.73M|		lines++;
  400|  1.73M|	}
  401|   359k|}
sc_dump_hex:
  405|  52.1k|{
  406|  52.1k|	static char dump_buf[0x1000];
  407|  52.1k|	size_t ii, size = sizeof(dump_buf) - 0x10;
  408|  52.1k|	size_t offs = 0;
  409|       |
  410|  52.1k|	memset(dump_buf, 0, sizeof(dump_buf));
  411|  52.1k|	if (in == NULL)
  ------------------
  |  Branch (411:6): [True: 100, False: 52.0k]
  ------------------
  412|    100|		return dump_buf;
  413|       |
  414|   342k|	for (ii=0; ii<count; ii++) {
  ------------------
  |  Branch (414:13): [True: 290k, False: 52.0k]
  ------------------
  415|   290k|		if (ii && !(ii%16))   {
  ------------------
  |  Branch (415:7): [True: 254k, False: 35.7k]
  |  Branch (415:13): [True: 589, False: 253k]
  ------------------
  416|    589|			if (!(ii%48))
  ------------------
  |  Branch (416:8): [True: 132, False: 457]
  ------------------
  417|    132|				snprintf(dump_buf + offs, size - offs, "\n");
  418|    457|			else
  419|    457|				snprintf(dump_buf + offs, size - offs, " ");
  420|    589|			offs = strlen(dump_buf);
  421|    589|		}
  422|       |
  423|   290k|		snprintf(dump_buf + offs, size - offs, "%02X", *(in + ii));
  424|   290k|		offs += 2;
  425|       |
  426|   290k|		if (offs > size)
  ------------------
  |  Branch (426:7): [True: 2, False: 290k]
  ------------------
  427|      2|			break;
  428|   290k|	}
  429|       |
  430|  52.0k|	if (ii<count)
  ------------------
  |  Branch (430:6): [True: 2, False: 52.0k]
  ------------------
  431|      2|		snprintf(dump_buf + offs, sizeof(dump_buf) - offs, "....\n");
  432|       |
  433|  52.0k|	return dump_buf;
  434|  52.1k|}
sc_dump_oid:
  438|  2.82k|{
  439|  2.82k|	static char dump_buf[SC_MAX_OBJECT_ID_OCTETS * 20];
  440|  2.82k|        size_t ii;
  441|       |
  442|  2.82k|	memset(dump_buf, 0, sizeof(dump_buf));
  443|  2.82k|	if (oid)
  ------------------
  |  Branch (443:6): [True: 2.82k, False: 0]
  ------------------
  444|  17.8k|		for (ii=0; ii<SC_MAX_OBJECT_ID_OCTETS && oid->value[ii] != -1; ii++)
  ------------------
  |  |   46|  35.7k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (444:14): [True: 17.8k, False: 0]
  |  Branch (444:44): [True: 15.0k, False: 2.82k]
  ------------------
  445|  15.0k|			snprintf(dump_buf + strlen(dump_buf), sizeof(dump_buf) - strlen(dump_buf), "%s%i", (ii ? "." : ""), oid->value[ii]);
  ------------------
  |  Branch (445:88): [True: 12.2k, False: 2.82k]
  ------------------
  446|       |
  447|  2.82k|	return dump_buf;
  448|  2.82k|}
log.c:sc_do_log_va:
  124|  17.3M|{
  125|       |#ifdef _WIN32
  126|       |	SYSTEMTIME st;
  127|       |#else
  128|  17.3M|	struct tm *tm;
  129|  17.3M|	struct timeval tv;
  130|  17.3M|	char time_string[40];
  131|  17.3M|#endif
  132|       |
  133|  17.3M|	if (!ctx || ctx->debug < level)
  ------------------
  |  Branch (133:6): [True: 0, False: 17.3M]
  |  Branch (133:14): [True: 17.3M, False: 0]
  ------------------
  134|  17.3M|		return;
  135|       |
  136|       |#ifdef _WIN32
  137|       |	/* In Windows, file handles can not be shared between DLL-s, each DLL has a
  138|       |	 * separate file handle table. Make sure we always have a valid file
  139|       |	 * descriptor. */
  140|       |	if (sc_ctx_log_to_file(ctx, ctx->debug_filename) < 0)
  141|       |		return;
  142|       |#endif
  143|      0|	if (ctx->debug_file == NULL)
  ------------------
  |  Branch (143:6): [True: 0, False: 0]
  ------------------
  144|      0|		return;
  145|       |
  146|       |#ifdef _WIN32
  147|       |	GetLocalTime(&st);
  148|       |	sc_color_fprintf(SC_COLOR_FG_GREEN|SC_COLOR_BOLD,
  149|       |			ctx, ctx->debug_file,
  150|       |			"P:%lu; T:%lu",
  151|       |			(unsigned long)GetCurrentProcessId(),
  152|       |			(unsigned long)GetCurrentThreadId());
  153|       |	sc_color_fprintf(SC_COLOR_FG_GREEN,
  154|       |			ctx, ctx->debug_file,
  155|       |			" %i-%02i-%02i %02i:%02i:%02i.%03i",
  156|       |			st.wYear, st.wMonth, st.wDay,
  157|       |			st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
  158|       |#else
  159|      0|	sc_color_fprintf(SC_COLOR_FG_GREEN|SC_COLOR_BOLD,
  ------------------
  |  |   45|      0|#define SC_COLOR_FG_GREEN		0x0002
  ------------------
              	sc_color_fprintf(SC_COLOR_FG_GREEN|SC_COLOR_BOLD,
  ------------------
  |  |   56|      0|#define SC_COLOR_BOLD			0x8080
  ------------------
  160|      0|			ctx, ctx->debug_file,
  161|      0|			"P:%lu; T:0x%lu",
  162|      0|			(unsigned long)getpid(),
  163|      0|			(unsigned long)pthread_self());
  164|      0|	gettimeofday (&tv, NULL);
  165|      0|	tm = localtime (&tv.tv_sec);
  166|      0|	strftime (time_string, sizeof(time_string), "%H:%M:%S", tm);
  167|      0|	sc_color_fprintf(SC_COLOR_FG_GREEN,
  ------------------
  |  |   45|      0|#define SC_COLOR_FG_GREEN		0x0002
  ------------------
  168|      0|			ctx, ctx->debug_file,
  169|      0|			" %s.%03ld",
  170|      0|			time_string,
  171|      0|			(long)tv.tv_usec / 1000);
  172|      0|#endif
  173|       |
  174|      0|	sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  175|      0|			ctx, ctx->debug_file,
  176|      0|			" [");
  177|      0|	sc_color_fprintf(SC_COLOR_FG_YELLOW|SC_COLOR_BOLD,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
              	sc_color_fprintf(SC_COLOR_FG_YELLOW|SC_COLOR_BOLD,
  ------------------
  |  |   56|      0|#define SC_COLOR_BOLD			0x8080
  ------------------
  178|      0|			ctx, ctx->debug_file,
  179|      0|			"%s",
  180|      0|			ctx->app_name);
  181|      0|	sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  182|      0|			ctx, ctx->debug_file,
  183|      0|			"] ");
  184|       |
  185|      0|	if (file != NULL) {
  ------------------
  |  Branch (185:6): [True: 0, False: 0]
  ------------------
  186|      0|		sc_color_fprintf(SC_COLOR_FG_YELLOW,
  ------------------
  |  |   46|      0|#define SC_COLOR_FG_YELLOW		0x0004
  ------------------
  187|      0|				ctx, ctx->debug_file,
  188|      0|				"%s:%d:%s: ",
  189|      0|				file, line, func ? func : "");
  ------------------
  |  Branch (189:17): [True: 0, False: 0]
  ------------------
  190|      0|	}
  191|       |
  192|      0|	sc_color_fprintf_va(color, ctx, ctx->debug_file, format, args);
  193|      0|	if (strlen(format) == 0 || format[strlen(format) - 1] != '\n')
  ------------------
  |  Branch (193:6): [True: 0, False: 0]
  |  Branch (193:29): [True: 0, False: 0]
  ------------------
  194|      0|		sc_color_fprintf(color, ctx, ctx->debug_file, "\n");
  195|      0|	fflush(ctx->debug_file);
  196|       |
  197|       |#ifdef _WIN32
  198|       |	if (ctx->debug_file && (ctx->debug_file != stderr && ctx->debug_file != stdout))
  199|       |		fclose(ctx->debug_file);
  200|       |	ctx->debug_file = NULL;
  201|       |#endif
  202|      0|}

mscfs_new:
   45|    295|mscfs_t *mscfs_new(void) {
   46|    295|	mscfs_t *fs = malloc(sizeof(mscfs_t));
   47|    295|	if (!fs)
  ------------------
  |  Branch (47:6): [True: 0, False: 295]
  ------------------
   48|      0|		return NULL;
   49|    295|	memset(fs, 0, sizeof(mscfs_t));
   50|    295|	memcpy(fs->currentPath, "\x3F\x00", 2);
   51|    295|	return fs;
   52|    295|}
mscfs_free:
   54|    295|void mscfs_free(mscfs_t *fs) {
   55|    295|	mscfs_clear_cache(fs);
   56|    295|	free(fs);
   57|    295|}
mscfs_clear_cache:
   59|    786|void mscfs_clear_cache(mscfs_t* fs) {
   60|    786|	if(!fs->cache.array) {
  ------------------
  |  Branch (60:5): [True: 638, False: 148]
  ------------------
   61|    638|		return;
   62|    638|	}
   63|    148|	free(fs->cache.array);
   64|       |	fs->cache.array = NULL;
   65|    148|	fs->cache.totalSize = 0;
   66|    148|	fs->cache.size = 0;
   67|    148|}
mscfs_push_file:
   83|   124k|{
   84|   124k|	mscfs_cache_t *cache = &fs->cache;
   85|   124k|	if (cache->size >= MAX_FILES)
  ------------------
  |  |   81|   124k|#define MAX_FILES 10000
  ------------------
  |  Branch (85:6): [True: 2, False: 124k]
  ------------------
   86|      2|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      2|#define SC_ERROR_INTERNAL			-1400
  ------------------
   87|   124k|	if(!cache->array || cache->size == cache->totalSize) {
  ------------------
  |  Branch (87:5): [True: 148, False: 124k]
  |  Branch (87:22): [True: 941, False: 123k]
  ------------------
   88|  1.08k|		int length = cache->totalSize + MSCFS_CACHE_INCREMENT;
  ------------------
  |  |   35|  1.08k|#define MSCFS_CACHE_INCREMENT 128
  ------------------
   89|  1.08k|		mscfs_file_t *oldArray;
   90|  1.08k|		cache->totalSize = length;
   91|  1.08k|		oldArray = cache->array;
   92|  1.08k|		cache->array = malloc(sizeof(mscfs_file_t) * length);
   93|  1.08k|		if(!cache->array)
  ------------------
  |  Branch (93:6): [True: 0, False: 1.08k]
  ------------------
   94|      0|			return MSCFS_NO_MEMORY;
  ------------------
  |  |   32|      0|#define MSCFS_NO_MEMORY  	SC_ERROR_OUT_OF_MEMORY
  |  |  ------------------
  |  |  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  |  |  ------------------
  ------------------
   95|  1.08k|		if(oldArray) {
  ------------------
  |  Branch (95:6): [True: 941, False: 148]
  ------------------
   96|    941|			memcpy(cache->array, oldArray, sizeof(mscfs_file_t) * cache->size);
   97|    941|			free(oldArray);
   98|    941|		}
   99|  1.08k|	}
  100|   124k|	cache->array[cache->size] = *file;
  101|   124k|	cache->size++;
  102|   124k|	return SC_SUCCESS;
  ------------------
  |  |   28|   124k|#define SC_SUCCESS				0
  ------------------
  103|   124k|}
mscfs_update_cache:
  105|    404|int mscfs_update_cache(mscfs_t* fs) {
  106|    404|	mscfs_file_t file;
  107|    404|	int r;
  108|    404|	mscfs_clear_cache(fs);
  109|    404|	r = fs->listFile(&file, 1, fs->udata);
  110|    404|	if(r == 0)
  ------------------
  |  Branch (110:5): [True: 37, False: 367]
  ------------------
  111|     37|		return 0;
  112|    367|	else if(r < 0)
  ------------------
  |  Branch (112:10): [True: 218, False: 149]
  ------------------
  113|    218|		return r;
  114|   124k|	while(1) {
  ------------------
  |  Branch (114:8): [True: 124k, Folded]
  ------------------
  115|   124k|		if(!mscfs_is_ignored(fs, file.objectId)) {
  ------------------
  |  Branch (115:6): [True: 124k, False: 32]
  ------------------
  116|       |			/* Check if its a directory in the root */
  117|   124k|			u8* oid = file.objectId.id;
  118|   124k|			if(oid[2] == 0 && oid[3] == 0) {
  ------------------
  |  Branch (118:7): [True: 112k, False: 12.5k]
  |  Branch (118:22): [True: 107k, False: 4.42k]
  ------------------
  119|   107k|				oid[2] = oid[0];
  120|   107k|				oid[3] = oid[1];
  121|   107k|				oid[0] = 0x3F;
  122|   107k|				oid[1] = 0x00;
  123|   107k|				file.ef = 0;
  124|   107k|			} else  {
  125|  17.0k|				file.ef = 1; /* File is a working elementary file */
  126|  17.0k|			}
  127|       |
  128|   124k|			r = mscfs_push_file(fs, &file);
  129|   124k|			if (r != SC_SUCCESS)
  ------------------
  |  |   28|   124k|#define SC_SUCCESS				0
  ------------------
  |  Branch (129:8): [True: 2, False: 124k]
  ------------------
  130|      2|				return r;
  131|   124k|		}
  132|   124k|		r = fs->listFile(&file, 0, fs->udata);
  133|   124k|		if(r == 0)
  ------------------
  |  Branch (133:6): [True: 12, False: 124k]
  ------------------
  134|     12|			break;
  135|   124k|		else if(r < 0)
  ------------------
  |  Branch (135:11): [True: 135, False: 124k]
  ------------------
  136|    135|			return r;
  137|   124k|	}
  138|     12|	return fs->cache.size;
  139|    149|}
mscfs_check_cache:
  142|   101k|{
  143|   101k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|   101k|#define SC_SUCCESS				0
  ------------------
  144|   101k|	if(!fs->cache.array) {
  ------------------
  |  Branch (144:5): [True: 404, False: 100k]
  ------------------
  145|    404|		r = mscfs_update_cache(fs);
  146|    404|	}
  147|   101k|	return r;
  148|   101k|}
mscfs_lookup_path:
  151|  1.10k|{
  152|  1.10k|	u8* oid = objectId->id;
  153|  1.10k|	if ((pathlen & 1) != 0) /* not divisible by 2 */
  ------------------
  |  Branch (153:6): [True: 75, False: 1.02k]
  ------------------
  154|     75|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   33|     75|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|     75|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  155|  1.02k|	if(isDirectory) {
  ------------------
  |  Branch (155:5): [True: 0, False: 1.02k]
  ------------------
  156|       |		/* Directory must be right next to root */
  157|      0|		if ((pathlen == 4 && 0 == memcmp(path, "\x3F\x00", 2)) ||
  ------------------
  |  Branch (157:8): [True: 0, False: 0]
  |  Branch (157:24): [True: 0, False: 0]
  ------------------
  158|      0|		    (pathlen == 2 && 0 == memcmp(fs->currentPath, "\x3F\x00", 2))) {
  ------------------
  |  Branch (158:8): [True: 0, False: 0]
  |  Branch (158:24): [True: 0, False: 0]
  ------------------
  159|      0|			oid[0] = path[pathlen - 2];
  160|      0|			oid[1] = path[pathlen - 1];
  161|      0|			oid[2] = oid[3] = 0;
  162|      0|		} else {
  163|      0|			return MSCFS_INVALID_ARGS;
  ------------------
  |  |   33|      0|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  164|      0|		}
  165|      0|	}
  166|  1.02k|	oid[0] = fs->currentPath[0];
  167|  1.02k|	oid[1] = fs->currentPath[1];
  168|       |	/* Chop off the root in the path */
  169|  1.02k|	if(pathlen > 2 && memcmp(path, "\x3F\x00", 2) == 0) {
  ------------------
  |  Branch (169:5): [True: 693, False: 335]
  |  Branch (169:20): [True: 657, False: 36]
  ------------------
  170|    657|		path += 2;
  171|    657|		pathlen -= 2;
  172|    657|		oid[0] = 0x3F;
  173|    657|		oid[1] = 0x00;
  174|    657|	}
  175|       |	/* Limit to a single directory */
  176|  1.02k|	if(pathlen > 4)
  ------------------
  |  Branch (176:5): [True: 1, False: 1.02k]
  ------------------
  177|      1|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   33|      1|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|      1|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  178|       |	/* Reset to root */
  179|  1.02k|	if(pathlen == 2 && 0 == memcmp(path, "\x3F\x00", 2)) {
  ------------------
  |  Branch (179:5): [True: 632, False: 395]
  |  Branch (179:21): [True: 207, False: 425]
  ------------------
  180|    207|		oid[0] = oid[2] = path[0];
  181|    207|		oid[1] = oid[3] = path[1];
  182|    820|	} else if(pathlen == 2) { /* Path preserved for current-path */
  ------------------
  |  Branch (182:12): [True: 425, False: 395]
  ------------------
  183|    425|		oid[2] = path[0];
  184|    425|		oid[3] = path[1];
  185|    425|	} else if(pathlen == 4) {
  ------------------
  |  Branch (185:12): [True: 302, False: 93]
  ------------------
  186|    302|		oid[0] = path[0];
  187|    302|		oid[1] = path[1];
  188|    302|		oid[2] = path[2];
  189|    302|		oid[3] = path[3];
  190|    302|	}
  191|       |
  192|  1.02k|	return 0;
  193|  1.02k|}
mscfs_check_selection:
  207|  1.45k|{
  208|  1.45k|	if(fs->currentPath[0] == 0 && fs->currentPath[1] == 0)
  ------------------
  |  Branch (208:5): [True: 0, False: 1.45k]
  |  Branch (208:32): [True: 0, False: 0]
  ------------------
  209|      0|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   33|      0|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  210|  1.45k|	if(requiredItem == 1 && fs->currentFile[0] == 0 && fs->currentFile[1] == 0)
  ------------------
  |  Branch (210:5): [True: 0, False: 1.45k]
  |  Branch (210:26): [True: 0, False: 0]
  |  Branch (210:53): [True: 0, False: 0]
  ------------------
  211|      0|		return MSCFS_INVALID_ARGS;
  ------------------
  |  |   33|      0|#define MSCFS_INVALID_ARGS 	SC_ERROR_INVALID_ARGUMENTS
  |  |  ------------------
  |  |  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  |  |  ------------------
  ------------------
  212|  1.45k|	return 0;
  213|  1.45k|}
mscfs_loadFileInfo:
  216|  1.10k|{
  217|  1.10k|	msc_id fullPath = {{0, 0, 0, 0}};
  218|  1.10k|	int x, rc;
  219|  1.10k|	if (fs == NULL || path == NULL || file_data == NULL)
  ------------------
  |  Branch (219:6): [True: 0, False: 1.10k]
  |  Branch (219:20): [True: 0, False: 1.10k]
  |  Branch (219:36): [True: 0, False: 1.10k]
  ------------------
  220|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  221|  1.10k|	rc = mscfs_lookup_path(fs, path, pathlen, &fullPath, 0);
  222|  1.10k|	if (rc != SC_SUCCESS) {
  ------------------
  |  |   28|  1.10k|#define SC_SUCCESS				0
  ------------------
  |  Branch (222:6): [True: 76, False: 1.02k]
  ------------------
  223|     76|		return rc;
  224|     76|	}
  225|       |
  226|       |	/* Obtain file information while checking if it exists */
  227|  1.02k|	rc = mscfs_check_cache(fs);
  228|  1.02k|	if (rc < 0)
  ------------------
  |  Branch (228:6): [True: 28, False: 999]
  ------------------
  229|     28|		return rc;
  230|    999|	if(idx) *idx = -1;
  ------------------
  |  Branch (230:5): [True: 910, False: 89]
  ------------------
  231|   440k|	for(x = 0; x < fs->cache.size; x++) {
  ------------------
  |  Branch (231:13): [True: 440k, False: 529]
  ------------------
  232|   440k|		*file_data = &fs->cache.array[x];
  233|   440k|		if (*file_data) {
  ------------------
  |  Branch (233:7): [True: 440k, False: 0]
  ------------------
  234|   440k|			msc_id objectId;
  235|   440k|			objectId = (*file_data)->objectId;
  236|   440k|			if(0 == memcmp(objectId.id, fullPath.id, 4)) {
  ------------------
  |  Branch (236:7): [True: 470, False: 439k]
  ------------------
  237|    470|				if (idx)
  ------------------
  |  Branch (237:9): [True: 386, False: 84]
  ------------------
  238|    386|					*idx = x;
  239|    470|				break;
  240|    470|			}
  241|   439k|			*file_data = NULL;
  242|   439k|		}
  243|   440k|	}
  244|    999|	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 (244:5): [True: 529, False: 470]
  |  Branch (244:28): [True: 3, False: 526]
  |  Branch (244:79): [True: 219, False: 307]
  |  Branch (244:131): [True: 30, False: 277]
  ------------------
  245|    252|		static mscfs_file_t ROOT_FILE;
  246|    252|		ROOT_FILE.ef = 0;
  247|    252|		ROOT_FILE.size = 0;
  248|       |		/* Faked Root ID */
  249|    252|		ROOT_FILE.objectId = rootId;
  250|       |
  251|    252|		ROOT_FILE.read = 0;
  252|    252|		ROOT_FILE.write = 0x02; /* User Pin access */
  253|    252|		ROOT_FILE.delete = 0x02;
  254|       |
  255|    252|		*file_data = &ROOT_FILE;
  256|    252|		if(idx) *idx = -2;
  ------------------
  |  Branch (256:6): [True: 252, False: 0]
  ------------------
  257|    747|	} else if(*file_data == NULL) {
  ------------------
  |  Branch (257:12): [True: 277, False: 470]
  ------------------
  258|    277|		return MSCFS_FILE_NOT_FOUND;
  ------------------
  |  |   34|    277|#define MSCFS_FILE_NOT_FOUND 	SC_ERROR_FILE_NOT_FOUND
  |  |  ------------------
  |  |  |  |   51|    277|#define SC_ERROR_FILE_NOT_FOUND			-1201
  |  |  ------------------
  ------------------
  259|    277|	}
  260|       |
  261|    722|	return 0;
  262|    999|}
muscle-filesystem.c:mscfs_is_ignored:
   70|   124k|{
   71|   124k|	int ignored = 0;
   72|   124k|	const u8** ptr = ignoredFiles;
   73|   374k|	while(ptr && *ptr && !ignored) {
  ------------------
  |  Branch (73:8): [True: 374k, False: 0]
  |  Branch (73:15): [True: 249k, False: 124k]
  |  Branch (73:23): [True: 249k, False: 32]
  ------------------
   74|   249k|		if(0 == memcmp(objectId.id, *ptr, 4))
  ------------------
  |  Branch (74:6): [True: 32, False: 249k]
  ------------------
   75|     32|			ignored = 1;
   76|   249k|		ptr++;
   77|   249k|	}
   78|   124k|	return ignored;
   79|   124k|}

msc_list_objects:
   37|   125k|int msc_list_objects(sc_card_t* card, u8 next, mscfs_file_t* file) {
   38|   125k|	sc_apdu_t apdu;
   39|   125k|	u8 fileData[14];
   40|   125k|	int r;
   41|       |
   42|   125k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2, 0x58, next, 0x00);
  ------------------
  |  |  301|   125k|#define SC_APDU_CASE_2			0x22
  ------------------
   43|   125k|	apdu.le = 14;
   44|   125k|	apdu.resplen = 14;
   45|   125k|	apdu.resp = fileData;
   46|   125k|	r = sc_transmit_apdu(card, &apdu);
   47|   125k|	if (r)
  ------------------
  |  Branch (47:6): [True: 21, False: 125k]
  ------------------
   48|     21|		return r;
   49|       |
   50|   125k|	if(apdu.sw1 == 0x9C && apdu.sw2 == 0x12) {
  ------------------
  |  Branch (50:5): [True: 8, False: 125k]
  |  Branch (50:25): [True: 0, False: 8]
  ------------------
   51|      0|		return 0;
   52|      0|	}
   53|   125k|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
   54|   125k|	if (r)
  ------------------
  |  Branch (54:6): [True: 315, False: 124k]
  ------------------
   55|    315|		return r;
   56|   124k|	if(apdu.resplen == 0) /* No more left */
  ------------------
  |  Branch (56:5): [True: 49, False: 124k]
  ------------------
   57|     49|		return 0;
   58|   124k|	if (apdu.resplen != 14) {
  ------------------
  |  Branch (58:6): [True: 17, False: 124k]
  ------------------
   59|     17|		sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
   60|     17|			 "expected 14 bytes, got %"SC_FORMAT_LEN_SIZE_T"u.\n",
   61|     17|			 apdu.resplen);
   62|     17|		return SC_ERROR_UNKNOWN_DATA_RECEIVED;
  ------------------
  |  |   63|     17|#define SC_ERROR_UNKNOWN_DATA_RECEIVED		-1213
  ------------------
   63|     17|	}
   64|   124k|	memcpy(file->objectId.id, fileData, 4);
   65|   124k|	file->size = bebytes2ulong(fileData + 4);
   66|   124k|	file->read = bebytes2ushort(fileData + 8);
   67|   124k|	file->write = bebytes2ushort(fileData + 10);
   68|   124k|	file->delete = bebytes2ushort(fileData + 12);
   69|       |
   70|   124k|	return 1;
   71|   124k|}
msc_partial_read_object:
   74|    180|{
   75|    180|	u8 buffer[9];
   76|    180|	sc_apdu_t apdu;
   77|    180|	int r;
   78|       |
   79|    180|	sc_format_apdu(card, &apdu, SC_APDU_CASE_4_SHORT, 0x56, 0x00, 0x00);
  ------------------
  |  |  294|    180|#define SC_APDU_CASE_4_SHORT		0x04
  ------------------
   80|       |
   81|    180|	sc_log(card->ctx,
  ------------------
  |  |   71|    180|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   82|    180|		"READ: Offset: %x\tLength: %"SC_FORMAT_LEN_SIZE_T"u\n", offset,
   83|    180|		 dataLength);
   84|    180|	memcpy(buffer, objectId.id, 4);
   85|    180|	ulong2bebytes(buffer + 4, offset);
   86|    180|	buffer[8] = (u8)dataLength;
   87|    180|	apdu.data = buffer;
   88|    180|	apdu.datalen = 9;
   89|    180|	apdu.lc = 9;
   90|    180|	apdu.le = dataLength;
   91|    180|	apdu.resplen = dataLength;
   92|    180|	apdu.resp = data;
   93|    180|	r = sc_transmit_apdu(card, &apdu);
   94|    180|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 10, False: 170]
  |  |  |  |  ------------------
  |  |  |  |  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|    180|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 170]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   95|    170|	if (apdu.sw1 == 0x90 && apdu.sw2 == 0x00 && dataLength <= apdu.resplen)
  ------------------
  |  Branch (95:6): [True: 145, False: 25]
  |  Branch (95:26): [True: 145, False: 0]
  |  Branch (95:46): [True: 137, False: 8]
  ------------------
   96|    137|		return (int)dataLength;
   97|     33|	if (apdu.sw1 == 0x9C) {
  ------------------
  |  Branch (97:6): [True: 0, False: 33]
  ------------------
   98|      0|		if (apdu.sw2 == 0x07) {
  ------------------
  |  Branch (98:7): [True: 0, False: 0]
  ------------------
   99|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  100|      0|		} else if (apdu.sw2 == 0x06) {
  ------------------
  |  Branch (100:14): [True: 0, False: 0]
  ------------------
  101|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_ALLOWED);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  102|      0|		} else if (apdu.sw2 == 0x0F) {
  ------------------
  |  Branch (102:14): [True: 0, False: 0]
  ------------------
  103|       |			/* GUESSED */
  104|      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]
  |  |  ------------------
  ------------------
  105|      0|		}
  106|      0|	}
  107|     33|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  108|     33|		"got strange SWs: 0x%02X 0x%02X\n", apdu.sw1, apdu.sw2);
  109|     33|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  110|     33|}
msc_read_object:
  113|    182|{
  114|    182|	int r = 0;
  115|    182|	unsigned int i;
  116|    182|	size_t max_read_unit = MSC_MAX_READ;
  ------------------
  |  |   35|    182|#define MSC_MAX_READ (card->max_recv_size > 0 ? card->max_recv_size : 255)
  |  |  ------------------
  |  |  |  Branch (35:23): [True: 182, False: 0]
  |  |  ------------------
  ------------------
  117|       |
  118|    319|	for (i = 0; i < dataLength; i += r) {
  ------------------
  |  Branch (118:14): [True: 180, False: 139]
  ------------------
  119|    180|		r = msc_partial_read_object(card, objectId, offset + i, data + i, MIN(dataLength - i, max_read_unit));
  ------------------
  |  |   70|    180|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 13, False: 167]
  |  |  ------------------
  ------------------
  120|    180|		LOG_TEST_RET(card->ctx, r, "Error in partial object 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: 43, False: 137]
  |  |  |  |  ------------------
  |  |  |  |  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|    180|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 137]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  121|    137|		if (r == 0)
  ------------------
  |  Branch (121:7): [True: 0, False: 137]
  ------------------
  122|      0|			break;
  123|    137|	}
  124|    139|	return (int)dataLength;
  125|    182|}
msc_zero_object:
  128|      1|{
  129|      1|	u8 zeroBuffer[MSC_MAX_APDU];
  130|      1|	size_t i;
  131|      1|	size_t max_write_unit = MIN(MSC_MAX_APDU, MSC_MAX_SEND - 9); /* - 9 for object ID+length */
  ------------------
  |  |   70|      2|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 1]
  |  |  |  Branch (70:28): [True: 1, False: 0]
  |  |  |  Branch (70:41): [True: 1, False: 0]
  |  |  ------------------
  ------------------
  132|       |
  133|      1|	memset(zeroBuffer, 0, max_write_unit);
  134|      1|	for(i = 0; i < dataLength; i += max_write_unit) {
  ------------------
  |  Branch (134:13): [True: 1, False: 0]
  ------------------
  135|      1|		int r = msc_partial_update_object(card, objectId, i, zeroBuffer, MIN(dataLength - i, max_write_unit));
  ------------------
  |  |   70|      1|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 0, False: 1]
  |  |  ------------------
  ------------------
  136|      1|		LOG_TEST_RET(card->ctx, r, "Error in zeroing file update");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  137|      1|	}
  138|      0|	return 0;
  139|      1|}
msc_create_object:
  142|      3|{
  143|      3|	u8 buffer[14];
  144|      3|	sc_apdu_t apdu;
  145|      3|	int r;
  146|       |
  147|      3|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x5A, 0x00, 0x00);
  ------------------
  |  |  293|      3|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  148|      3|	apdu.lc = 14;
  149|      3|	apdu.data = buffer,
  150|      3|	apdu.datalen = 14;
  151|       |
  152|      3|	memcpy(buffer, objectId.id, 4);
  153|      3|	ulong2bebytes(buffer + 4, objectSize);
  154|      3|	ushort2bebytes(buffer + 8, readAcl);
  155|      3|	ushort2bebytes(buffer + 10, writeAcl);
  156|      3|	ushort2bebytes(buffer + 12, deleteAcl);
  157|      3|	r = sc_transmit_apdu(card, &apdu);
  158|      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: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  159|      3|	if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (159:5): [True: 2, False: 1]
  |  Branch (159:25): [True: 2, False: 0]
  ------------------
  160|      2|		return (int)objectSize;
  161|      1|	if(apdu.sw1 == 0x9C) {
  ------------------
  |  Branch (161:5): [True: 0, False: 1]
  ------------------
  162|      0|		if(apdu.sw2 == 0x01) {
  ------------------
  |  Branch (162:6): [True: 0, False: 0]
  ------------------
  163|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_MEMORY_FAILURE);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_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|		} else if(apdu.sw2 == 0x08) {
  ------------------
  |  Branch (164:13): [True: 0, False: 0]
  ------------------
  165|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_FILE_ALREADY_EXISTS);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_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|		} else if(apdu.sw2 == 0x06) {
  ------------------
  |  Branch (166:13): [True: 0, False: 0]
  ------------------
  167|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_ALLOWED);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  168|      0|		}
  169|      0|	}
  170|      1|	if (card->ctx->debug >= 2) {
  ------------------
  |  Branch (170:6): [True: 0, False: 1]
  ------------------
  171|      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__
  |  |  ------------------
  ------------------
  172|      0|		     apdu.sw1, apdu.sw2);
  173|      0|	}
  174|      1|	msc_zero_object(card, objectId, objectSize);
  175|      1|	return (int)objectSize;
  176|      1|}
msc_partial_update_object:
  180|  2.57k|{
  181|  2.57k|	u8 buffer[MSC_MAX_APDU];
  182|  2.57k|	sc_apdu_t apdu;
  183|  2.57k|	int r;
  184|       |
  185|  2.57k|	if (dataLength + 9 > MSC_MAX_APDU)
  ------------------
  |  |   30|  2.57k|#define MSC_MAX_APDU 512 /* Max APDU send/recv, used for stack allocation */
  ------------------
  |  Branch (185:6): [True: 0, False: 2.57k]
  ------------------
  186|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  187|       |
  188|  2.57k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x54, 0x00, 0x00);
  ------------------
  |  |  293|  2.57k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  189|  2.57k|	apdu.lc = dataLength + 9;
  190|  2.57k|	if (card->ctx->debug >= 2)
  ------------------
  |  Branch (190:6): [True: 0, False: 2.57k]
  ------------------
  191|      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__
  |  |  ------------------
  ------------------
  192|  2.57k|			 "WRITE: Offset: %zx\tLength: %"SC_FORMAT_LEN_SIZE_T"u\n",
  193|  2.57k|			 offset, dataLength);
  194|       |
  195|  2.57k|	memcpy(buffer, objectId.id, 4);
  196|  2.57k|	ulong2bebytes(buffer + 4, offset);
  197|  2.57k|	buffer[8] = (u8)dataLength;
  198|  2.57k|	memcpy(buffer + 9, data, dataLength);
  199|  2.57k|	apdu.data = buffer;
  200|  2.57k|	apdu.datalen = apdu.lc;
  201|  2.57k|	r = sc_transmit_apdu(card, &apdu);
  202|  2.57k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  2.57k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.57k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.57k|	int _ret = (r); \
  |  |  |  |  168|  2.57k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1, False: 2.57k]
  |  |  |  |  ------------------
  |  |  |  |  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.57k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.57k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  203|  2.57k|	if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (203:5): [True: 534, False: 2.03k]
  |  Branch (203:25): [True: 443, False: 91]
  ------------------
  204|    443|		return (int)dataLength;
  205|  2.12k|	if(apdu.sw1 == 0x9C) {
  ------------------
  |  Branch (205:5): [True: 0, False: 2.12k]
  ------------------
  206|      0|		if(apdu.sw2 == 0x07) {
  ------------------
  |  Branch (206:6): [True: 0, False: 0]
  ------------------
  207|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  208|      0|		} else if(apdu.sw2 == 0x06) {
  ------------------
  |  Branch (208:13): [True: 0, False: 0]
  ------------------
  209|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_ALLOWED);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  210|      0|		} else if(apdu.sw2 == 0x0F) {
  ------------------
  |  Branch (210:13): [True: 0, False: 0]
  ------------------
  211|       |			/* GUESSED */
  212|      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]
  |  |  ------------------
  ------------------
  213|      0|		}
  214|      0|	}
  215|  2.12k|	if (card->ctx->debug >= 2) {
  ------------------
  |  Branch (215:6): [True: 0, False: 2.12k]
  ------------------
  216|      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__
  |  |  ------------------
  ------------------
  217|      0|		     apdu.sw1, apdu.sw2);
  218|      0|	}
  219|  2.12k|	return (int)dataLength;
  220|  2.12k|}
msc_update_object:
  223|  1.28k|{
  224|  1.28k|	int r;
  225|  1.28k|	size_t i;
  226|  1.28k|	size_t max_write_unit = MSC_MAX_SEND - 9;
  ------------------
  |  |   36|  1.28k|#define MSC_MAX_SEND (card->max_send_size > 0 ? card->max_send_size : 255)
  |  |  ------------------
  |  |  |  Branch (36:23): [True: 1.28k, False: 0]
  |  |  ------------------
  ------------------
  227|  3.85k|	for(i = 0; i < dataLength; i += max_write_unit) {
  ------------------
  |  Branch (227:13): [True: 2.57k, False: 1.28k]
  ------------------
  228|  2.57k|		r = msc_partial_update_object(card, objectId, offset + i, data + i, MIN(dataLength - i, max_write_unit));
  ------------------
  |  |   70|  2.57k|#define MIN(x, y) (((x) < (y)) ? (x) : (y))
  |  |  ------------------
  |  |  |  Branch (70:20): [True: 1.28k, False: 1.28k]
  |  |  ------------------
  ------------------
  229|  2.57k|		LOG_TEST_RET(card->ctx, r, "Error in partial object update");
  ------------------
  |  |  174|  2.57k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.57k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.57k|	int _ret = (r); \
  |  |  |  |  168|  2.57k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.57k]
  |  |  |  |  ------------------
  |  |  |  |  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.57k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.57k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  230|  2.57k|	}
  231|  1.28k|	return (int)dataLength;
  232|  1.28k|}
msc_delete_object:
  235|   102k|{
  236|   102k|	sc_apdu_t apdu;
  237|   102k|	int r;
  238|       |
  239|   102k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x52, 0x00, zero ? 0x01 : 0x00);
  ------------------
  |  |  293|   102k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  |  Branch (239:64): [True: 102k, False: 0]
  ------------------
  240|   102k|	apdu.lc = 4;
  241|   102k|	apdu.data = objectId.id;
  242|   102k|	apdu.datalen = 4;
  243|   102k|	r = sc_transmit_apdu(card, &apdu);
  244|   102k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|   102k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   102k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   102k|	int _ret = (r); \
  |  |  |  |  168|   102k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 61, False: 102k]
  |  |  |  |  ------------------
  |  |  |  |  169|     61|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     61|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     61|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     61|		return _ret; \
  |  |  |  |  172|     61|	} \
  |  |  |  |  173|   102k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 102k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  245|   102k|	if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (245:5): [True: 3.15k, False: 99.4k]
  |  Branch (245:25): [True: 3.08k, False: 67]
  ------------------
  246|  3.08k|		return 0;
  247|  99.5k|	if(apdu.sw1 == 0x9C) {
  ------------------
  |  Branch (247:5): [True: 3, False: 99.5k]
  ------------------
  248|      3|		if(apdu.sw2 == 0x07) {
  ------------------
  |  Branch (248:6): [True: 0, False: 3]
  ------------------
  249|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|      0|	return _ret; \
  |  |  163|      0|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  250|      3|		} else if(apdu.sw2 == 0x06) {
  ------------------
  |  Branch (250:13): [True: 0, False: 3]
  ------------------
  251|      0|			SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_ALLOWED);
  ------------------
  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|      0|	int _ret = r; \
  |  |  155|      0|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  ------------------
  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  ------------------
  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|      0|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_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|      0|		}
  253|      3|	}
  254|  99.5k|	if (card->ctx->debug >= 2) {
  ------------------
  |  Branch (254:6): [True: 0, False: 99.5k]
  ------------------
  255|      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__
  |  |  ------------------
  ------------------
  256|      0|		     apdu.sw1, apdu.sw2);
  257|      0|	}
  258|  99.5k|	return 0;
  259|  99.5k|}
msc_select_applet:
  262|  1.35k|{
  263|  1.35k|	sc_apdu_t apdu;
  264|  1.35k|	int r;
  265|       |
  266|  1.35k|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0xA4, 4, 0);
  ------------------
  |  |  293|  1.35k|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  267|  1.35k|	apdu.lc = appletIdLength;
  268|  1.35k|	apdu.data = appletId;
  269|  1.35k|	apdu.datalen = appletIdLength;
  270|  1.35k|	apdu.resplen = 0;
  271|  1.35k|	apdu.le = 0;
  272|       |
  273|  1.35k|	r = sc_transmit_apdu(card, &apdu);
  274|  1.35k|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|  1.35k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.35k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.35k|	int _ret = (r); \
  |  |  |  |  168|  1.35k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 1.35k]
  |  |  |  |  ------------------
  |  |  |  |  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.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.35k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  275|  1.35k|	if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00)
  ------------------
  |  Branch (275:5): [True: 382, False: 971]
  |  Branch (275:25): [True: 295, False: 87]
  ------------------
  276|    295|		return 1;
  277|       |
  278|  1.05k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,  SC_ERROR_CARD_CMD_FAILED);
  ------------------
  |  |  153|  1.05k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  1.05k|	int _ret = r; \
  |  |  155|  1.05k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1.05k, False: 0]
  |  |  ------------------
  |  |  156|  1.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|  1.05k|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 1.05k, False: 0]
  |  |  ------------------
  |  |  157|  1.05k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  1.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|  1.05k|	return _ret; \
  |  |  163|  1.05k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  279|  1.05k|}
msc_generate_keypair:
  520|     25|{
  521|     25|	sc_apdu_t apdu;
  522|     25|	u8 buffer[16]; /* Key pair payload length */
  523|     25|	u8 *ptr = buffer;
  524|     25|	int r;
  525|     25|	unsigned short prRead = 0xFFFF, prWrite = 0x0002, prCompute = 0x0002,
  526|     25|		puRead = 0x0000, puWrite = 0x0002, puCompute = 0x0000;
  527|       |
  528|     25|	if (privateKey > 0x0F || publicKey > 0x0F)
  ------------------
  |  Branch (528:6): [True: 0, False: 25]
  |  Branch (528:27): [True: 0, False: 25]
  ------------------
  529|     25|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  530|       |
  531|     25|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x30, privateKey, publicKey);
  ------------------
  |  |  293|     25|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  532|       |
  533|     25|	*ptr = algorithm; ptr++;
  534|       |
  535|     25|	ushort2bebytes(ptr, keySize);
  536|     25|	ptr+=2;
  537|       |
  538|     25|	ushort2bebytes(ptr, prRead);
  539|     25|	ptr+=2;
  540|     25|	ushort2bebytes(ptr, prWrite);
  541|     25|	ptr+=2;
  542|     25|	ushort2bebytes(ptr, prCompute);
  543|     25|	ptr+=2;
  544|       |
  545|     25|	ushort2bebytes(ptr, puRead);
  546|     25|	ptr+=2;
  547|     25|	ushort2bebytes(ptr, puWrite);
  548|     25|	ptr+=2;
  549|     25|	ushort2bebytes(ptr, puCompute);
  550|     25|	ptr+=2;
  551|       |
  552|     25|	*ptr = 0; /* options; -- no options for now, they need extra data */
  553|       |
  554|     25|	apdu.data = buffer;
  555|     25|	apdu.datalen = 16;
  556|     25|	apdu.lc = 16;
  557|       |
  558|     25|	r = sc_transmit_apdu(card, &apdu);
  559|     25|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  174|     25|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     25|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     25|	int _ret = (r); \
  |  |  |  |  168|     25|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|     25|	if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (560:5): [True: 9, False: 16]
  |  Branch (560:25): [True: 9, False: 0]
  ------------------
  561|      9|		return 0;
  562|      9|	}
  563|     16|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  564|     16|	if (r) {
  ------------------
  |  Branch (564:6): [True: 16, False: 0]
  ------------------
  565|     16|		if (card->ctx->debug >= 2) {
  ------------------
  |  Branch (565:7): [True: 0, False: 16]
  ------------------
  566|      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__
  |  |  ------------------
  ------------------
  567|      0|			     apdu.sw1, apdu.sw2);
  568|      0|		}
  569|     16|		LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  570|     16|	}
  571|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  572|      0|}
msc_extract_key:
  576|      9|{
  577|      9|	sc_apdu_t apdu;
  578|      9|	u8 encoding = 0;
  579|      9|	int r;
  580|       |
  581|      9|	sc_format_apdu(card, &apdu, SC_APDU_CASE_3_SHORT, 0x34, keyLocation, 0x00);
  ------------------
  |  |  293|      9|#define SC_APDU_CASE_3_SHORT		0x03
  ------------------
  582|      9|	apdu.data = &encoding;
  583|      9|	apdu.datalen = 1;
  584|      9|	apdu.lc = 1;
  585|      9|	r = sc_transmit_apdu(card, &apdu);
  586|      9|	LOG_TEST_RET(card->ctx, r, "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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  587|      9|	if(apdu.sw1 == 0x90 && apdu.sw2 == 0x00) {
  ------------------
  |  Branch (587:5): [True: 8, False: 1]
  |  Branch (587:25): [True: 7, False: 1]
  ------------------
  588|      7|		return 0;
  589|      7|	}
  590|      2|	r = sc_check_sw(card, apdu.sw1, apdu.sw2);
  591|      2|	if (r) {
  ------------------
  |  Branch (591:6): [True: 2, False: 0]
  ------------------
  592|      2|		if (card->ctx->debug >= 2) {
  ------------------
  |  Branch (592:7): [True: 0, False: 2]
  ------------------
  593|      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__
  |  |  ------------------
  ------------------
  594|      0|			     apdu.sw1, apdu.sw2);
  595|      0|		}
  596|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  597|      2|	}
  598|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  599|      0|}
msc_extract_rsa_public_key:
  607|      9|{
  608|      9|	int r;
  609|      9|	u8 buffer[1024]; /* Should be plenty... */
  610|      9|	int fileLocation = 1;
  611|       |
  612|      9|	r = msc_extract_key(card, keyLocation);
  613|      9|	if(r < 0) 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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (613:5): [True: 2, False: 7]
  ------------------
  614|       |
  615|       |	/* Read keyType, keySize, and what should be the modulus size */
  616|      7|	r = msc_read_object(card, inputId, fileLocation, buffer, 5);
  617|      7|	fileLocation += 5;
  618|      7|	if(r < 0) LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (618:5): [True: 5, False: 2]
  ------------------
  619|       |
  620|      2|	if(buffer[0] != MSC_RSA_PUBLIC) LOG_FUNC_RETURN(card->ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED);
  ------------------
  |  |   30|      2|#define MSC_RSA_PUBLIC		0x01
  ------------------
              	if(buffer[0] != MSC_RSA_PUBLIC) 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  |  Branch (620:5): [True: 0, False: 2]
  ------------------
  621|      2|	*modLength = (buffer[3] << 8) | buffer[4];
  622|       |	/* Read the modulus and the exponent length */
  623|       |
  624|      2|	if (*modLength + 2 > sizeof buffer)
  ------------------
  |  Branch (624:6): [True: 0, False: 2]
  ------------------
  625|      2|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  626|      2|	r = msc_read_object(card, inputId, fileLocation, buffer, *modLength + 2);
  627|      2|	fileLocation += *modLength + 2;
  628|      2|	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 (628:5): [True: 0, False: 2]
  ------------------
  629|       |
  630|      2|	*modulus = malloc(*modLength);
  631|      2|	if(!*modulus) 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 (631:5): [True: 0, False: 2]
  ------------------
  632|      2|	memcpy(*modulus, buffer, *modLength);
  633|      2|	*expLength = (buffer[*modLength] << 8) | buffer[*modLength + 1];
  634|      2|	if (*expLength > sizeof buffer) {
  ------------------
  |  Branch (634:6): [True: 0, False: 2]
  ------------------
  635|      0|		free(*modulus); *modulus = NULL;
  636|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  637|      0|	}
  638|      2|	r = msc_read_object(card, inputId, fileLocation, buffer, *expLength);
  639|      2|	if(r < 0) {
  ------------------
  |  Branch (639:5): [True: 0, False: 2]
  ------------------
  640|      0|		free(*modulus); *modulus = NULL;
  641|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  642|      0|	}
  643|      2|	*exponent = malloc(*expLength);
  644|      2|	if(!*exponent) {
  ------------------
  |  Branch (644:5): [True: 0, False: 2]
  ------------------
  645|      0|		free(*modulus);
  646|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  647|      0|	}
  648|      2|	memcpy(*exponent, buffer, *expLength);
  649|      2|	return 0;
  650|      2|}

sc_asn1_encode_algorithm_id:
  547|     26|{
  548|     26|	struct sc_asn1_pkcs15_algorithm_info *alg_info;
  549|     26|	struct sc_algorithm_id temp_id;
  550|     26|	struct sc_asn1_entry asn1_alg_id[3];
  551|     26|	u8 *obj = NULL;
  552|     26|	size_t obj_len = 0;
  553|     26|	int r;
  554|     26|	u8 *tmp;
  555|       |
  556|     26|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     26|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     26|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     26|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  557|     26|        sc_log(ctx, "type of algorithm to encode: %lu", id->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  558|     26|	alg_info = sc_asn1_get_algorithm_info(id);
  559|     26|	if (alg_info == NULL) {
  ------------------
  |  Branch (559:6): [True: 0, False: 26]
  ------------------
  560|      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__
  |  |  ------------------
  ------------------
  561|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  562|      0|	}
  563|       |
  564|       |	/* Set the oid if not yet given */
  565|     26|	if (!sc_valid_oid(&id->oid)) {
  ------------------
  |  Branch (565:6): [True: 26, False: 0]
  ------------------
  566|     26|		temp_id = *id;
  567|     26|		temp_id.oid = alg_info->oid;
  568|     26|		id = &temp_id;
  569|     26|	}
  570|       |
  571|     26|        sc_log(ctx, "encode algo %s", sc_dump_oid(&(id->oid)));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  572|     26|	sc_copy_asn1_entry(c_asn1_alg_id, asn1_alg_id);
  573|     26|	sc_format_asn1_entry(asn1_alg_id + 0, (void *) &id->oid, NULL, 1);
  574|       |
  575|       |	/* no parameters, write NULL tag */
  576|       |	/* If it's EDDSA/XEDDSA, according to RFC8410, params
  577|       |	 * MUST be absent */
  578|       |	/* PKCS11 3.0 list them under ec_params */
  579|     26|	if (id->algorithm != SC_ALGORITHM_EDDSA &&
  ------------------
  |  |   81|     52|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (579:6): [True: 26, False: 0]
  ------------------
  580|     26|	    id->algorithm != SC_ALGORITHM_XEDDSA &&
  ------------------
  |  |   82|     52|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (580:6): [True: 26, False: 0]
  ------------------
  581|     26|	    (!id->params || !alg_info->encode))
  ------------------
  |  Branch (581:7): [True: 16, False: 10]
  |  Branch (581:22): [True: 0, False: 10]
  ------------------
  582|     16|		asn1_alg_id[1].flags |= SC_ASN1_PRESENT;
  ------------------
  |  |  147|     16|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  583|       |
  584|     26|	r = _sc_asn1_encode(ctx, asn1_alg_id, buf, len, depth + 1);
  585|     26|	LOG_TEST_RET(ctx, r, "ASN.1 encode of algorithm 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: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  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|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  586|       |
  587|       |	/* Encode any parameters */
  588|     26|	if (id->params && alg_info->encode) {
  ------------------
  |  Branch (588:6): [True: 10, False: 16]
  |  Branch (588:20): [True: 10, False: 0]
  ------------------
  589|     10|		r = alg_info->encode(ctx, id->params, &obj, &obj_len, depth+1);
  590|     10|		if (r < 0) {
  ------------------
  |  Branch (590:7): [True: 0, False: 10]
  ------------------
  591|      0|			if (obj)
  ------------------
  |  Branch (591:8): [True: 0, False: 0]
  ------------------
  592|      0|				free(obj);
  593|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  594|      0|		}
  595|     10|	}
  596|       |
  597|     26|	if (obj_len) {
  ------------------
  |  Branch (597:6): [True: 10, False: 16]
  ------------------
  598|     10|		tmp = (u8 *) realloc(*buf, *len + obj_len);
  599|     10|		if (!tmp) {
  ------------------
  |  Branch (599:7): [True: 0, False: 10]
  ------------------
  600|      0|			free(*buf);
  601|      0|			*buf = NULL;
  602|      0|			free(obj);
  603|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  604|      0|		}
  605|     10|		*buf = tmp;
  606|     10|		memcpy(*buf + *len, obj, obj_len);
  607|     10|		*len += obj_len;
  608|     10|		free(obj);
  609|     10|	}
  610|       |
  611|     26|	sc_log(ctx, "return encoded algorithm ID: %s", sc_dump_hex(*buf, *len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  612|     26|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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: 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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  613|     26|}
sc_asn1_clear_algorithm_id:
  617|     84|{
  618|     84|	struct sc_asn1_pkcs15_algorithm_info *aip;
  619|       |
  620|     84|	if (id->params && (aip = sc_asn1_get_algorithm_info(id)) && aip->free) {
  ------------------
  |  Branch (620:6): [True: 10, False: 74]
  |  Branch (620:20): [True: 10, False: 0]
  |  Branch (620:62): [True: 10, False: 0]
  ------------------
  621|     10|		aip->free(id->params);
  622|       |		id->params = NULL;
  623|     10|	}
  624|     84|}
pkcs15-algo.c:sc_asn1_get_algorithm_info:
  486|     36|{
  487|     36|	struct sc_asn1_pkcs15_algorithm_info *aip = NULL;
  488|       |
  489|    340|	for (aip = algorithm_table; aip->id >= 0; aip++)   {
  ------------------
  |  Branch (489:30): [True: 340, False: 0]
  ------------------
  490|    340|		if ((int) id->algorithm < 0 && sc_compare_oid(&id->oid, &aip->oid))
  ------------------
  |  Branch (490:7): [True: 0, False: 340]
  |  Branch (490:34): [True: 0, False: 0]
  ------------------
  491|      0|			return aip;
  492|       |
  493|    340|		if (aip->id == (int)id->algorithm)
  ------------------
  |  Branch (493:7): [True: 36, False: 304]
  ------------------
  494|     36|			return aip;
  495|    340|	}
  496|       |
  497|      0|	return NULL;
  498|     36|}
pkcs15-algo.c:asn1_encode_ec_params:
  314|     10|{
  315|     10|	 struct sc_ec_parameters *ecp = (struct sc_ec_parameters *) params;
  316|       |
  317|       |	/* Only handle named curves. They may be absent too */
  318|     10|	sc_debug(ctx, SC_LOG_DEBUG_ASN1, "asn1_encode_ec_params() called");
  ------------------
  |  |   70|     10|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  319|     10|	*buf = NULL;
  320|     10|	*buflen = 0;
  321|     10|	if (ecp && ecp->type == 1 && ecp->der.value) { /* named curve */
  ------------------
  |  Branch (321:6): [True: 10, False: 0]
  |  Branch (321:13): [True: 10, False: 0]
  |  Branch (321:31): [True: 10, False: 0]
  ------------------
  322|     10|		*buf = malloc(ecp->der.len);
  323|     10|		if (*buf == NULL)
  ------------------
  |  Branch (323:7): [True: 0, False: 10]
  ------------------
  324|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  325|       |
  326|     10|		memcpy(*buf, ecp->der.value, ecp->der.len);
  327|     10|		*buflen = ecp->der.len;
  328|     10|	}
  329|      0|	else   {
  330|      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__
  |  |  ------------------
  ------------------
  331|      0|	}
  332|       |
  333|     10|	return 0;
  334|     10|}
pkcs15-algo.c:asn1_free_ec_params:
  338|     10|{
  339|     10|	struct sc_ec_parameters *ecp = (struct sc_ec_parameters *) params;
  340|       |
  341|     10|	if (ecp) {
  ------------------
  |  Branch (341:6): [True: 10, False: 0]
  ------------------
  342|     10|		if (ecp->der.value)
  ------------------
  |  Branch (342:7): [True: 10, False: 0]
  ------------------
  343|     10|			free(ecp->der.value);
  344|     10|		if (ecp->named_curve)
  ------------------
  |  Branch (344:7): [True: 0, False: 10]
  ------------------
  345|      0|			free(ecp->named_curve);
  346|     10|		free(ecp);
  347|     10|	}
  348|     10|}

sc_pkcs15emu_cac_init_ex:
  372|  3.39k|{
  373|  3.39k|	sc_card_t   *card = p15card->card;
  374|  3.39k|	sc_context_t    *ctx = card->ctx;
  375|       |
  376|  3.39k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.39k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.39k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.39k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.39k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.39k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  377|       |
  378|  3.39k|	if (cac_detect_card(p15card))
  ------------------
  |  Branch (378:6): [True: 3.39k, False: 0]
  ------------------
  379|  3.39k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  380|      0|	return sc_pkcs15emu_cac_init(p15card);
  381|  3.39k|}
pkcs15-cac.c:cac_detect_card:
   65|  3.39k|{
   66|  3.39k|	sc_card_t *card = p15card->card;
   67|       |
   68|  3.39k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.39k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.39k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.39k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.39k]
  |  |  ------------------
  ------------------
   69|  3.39k|	if (card->type < SC_CARD_TYPE_CAC_GENERIC
  ------------------
  |  Branch (69:6): [True: 3.38k, False: 13]
  ------------------
   70|     13|		|| card->type >= SC_CARD_TYPE_CAC_GENERIC+1000)
  ------------------
  |  Branch (70:6): [True: 13, False: 0]
  ------------------
   71|  3.39k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  3.39k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
   72|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
   73|  3.39k|}

sc_pkcs15_read_cached_file:
  113|  91.8k|{
  114|  91.8k|	char fname[PATH_MAX];
  115|  91.8k|	int rv;
  116|  91.8k|	FILE *f;
  117|  91.8k|	size_t count;
  118|  91.8k|	struct stat stbuf;
  119|  91.8k|	u8 *data = NULL;
  120|       |
  121|  91.8k|	if (path->len < 2)
  ------------------
  |  Branch (121:6): [True: 18.9k, False: 72.9k]
  ------------------
  122|  18.9k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  18.9k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  123|       |
  124|       |	/* Accept full path or FILE-ID path with AID */
  125|  72.9k|	if ((path->type != SC_PATH_TYPE_PATH) && (path->type != SC_PATH_TYPE_FILE_ID || path->aid.len == 0))
  ------------------
  |  |  119|  72.9k|#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|  19.4k|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  |  Branch (125:6): [True: 9.73k, False: 63.1k]
  |  Branch (125:44): [True: 0, False: 9.73k]
  |  Branch (125:82): [True: 9.73k, False: 0]
  ------------------
  126|  9.73k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  9.73k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  127|       |
  128|  63.1k|	sc_log(p15card->card->ctx, "try to read cache for %s", sc_print_path(path));
  ------------------
  |  |   71|  63.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__
  |  |  ------------------
  ------------------
  129|  63.1k|	rv = generate_cache_filename(p15card, path, fname, sizeof(fname));
  130|  63.1k|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|  63.1k|#define SC_SUCCESS				0
  ------------------
  |  Branch (130:6): [True: 2.79k, False: 60.3k]
  ------------------
  131|  2.79k|		return rv;
  132|  60.3k|	sc_log(p15card->card->ctx, "read cached file %s", fname);
  ------------------
  |  |   71|  60.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|       |
  134|  60.3k|	f = fopen(fname, "rb");
  135|  60.3k|	if (!f)
  ------------------
  |  Branch (135:6): [True: 60.2k, False: 120]
  ------------------
  136|  60.2k|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  60.2k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  137|    120|	if (fstat(fileno(f), &stbuf))   {
  ------------------
  |  Branch (137:6): [True: 0, False: 120]
  ------------------
  138|      0|		fclose(f);
  139|      0|		return  SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  140|      0|	}
  141|       |
  142|    120|	if (path->count < 0) {
  ------------------
  |  Branch (142:6): [True: 119, False: 1]
  ------------------
  143|    119|		count = stbuf.st_size;
  144|    119|	}
  145|      1|	else {
  146|      1|		count = path->count;
  147|      1|		if (path->index + count > (size_t)stbuf.st_size)   {
  ------------------
  |  Branch (147:7): [True: 0, False: 1]
  ------------------
  148|      0|			rv = SC_ERROR_FILE_NOT_FOUND; /* cache file bad? */
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  149|      0|			goto err;
  150|      0|		}
  151|       |
  152|      1|		if (0 != fseek(f, (long)path->index, SEEK_SET)) {
  ------------------
  |  Branch (152:7): [True: 0, False: 1]
  ------------------
  153|      0|			rv = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  154|      0|			goto err;
  155|      0|		}
  156|      1|	}
  157|       |
  158|    120|	if (*buf == NULL) {
  ------------------
  |  Branch (158:6): [True: 120, False: 0]
  ------------------
  159|    120|		data = malloc((size_t)stbuf.st_size);
  160|    120|		if (data == NULL)   {
  ------------------
  |  Branch (160:7): [True: 0, False: 120]
  ------------------
  161|      0|			rv = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  162|      0|			goto err;
  163|      0|		}
  164|    120|	}
  165|      0|	else {
  166|      0|		if (count > *bufsize) {
  ------------------
  |  Branch (166:7): [True: 0, False: 0]
  ------------------
  167|      0|			rv =  SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  168|      0|			goto err;
  169|      0|		}
  170|      0|		data = *buf;
  171|      0|	}
  172|       |
  173|    120|	if (count != fread(data, 1, count, f)) {
  ------------------
  |  Branch (173:6): [True: 0, False: 120]
  ------------------
  174|      0|		rv = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  175|      0|		goto err;
  176|      0|	}
  177|    120|	*buf = data;
  178|    120|	*bufsize = count;
  179|       |
  180|    120|	rv = SC_SUCCESS;
  ------------------
  |  |   28|    120|#define SC_SUCCESS				0
  ------------------
  181|       |
  182|    120|err:
  183|    120|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|    120|#define SC_SUCCESS				0
  ------------------
  |  Branch (183:6): [True: 0, False: 120]
  ------------------
  184|      0|		if (data != *buf) {
  ------------------
  |  Branch (184:7): [True: 0, False: 0]
  ------------------
  185|      0|			free(data);
  186|      0|		}
  187|      0|	}
  188|       |
  189|    120|	fclose(f);
  190|    120|	return rv;
  191|    120|}
sc_pkcs15_cache_file:
  196|  1.15k|{
  197|  1.15k|	char fname[PATH_MAX];
  198|  1.15k|	int r;
  199|  1.15k|	long len;
  200|  1.15k|	FILE *f;
  201|  1.15k|	size_t c;
  202|       |
  203|  1.15k|	r = generate_cache_filename(p15card, path, fname, sizeof(fname));
  204|  1.15k|	if (r != 0)
  ------------------
  |  Branch (204:6): [True: 1.08k, False: 72]
  ------------------
  205|  1.08k|		return r;
  206|       |
  207|     72|	f = fopen(fname, "ab");
  208|       |	/* If the open failed because the cache directory does
  209|       |	 * not exist, create it and a re-try the fopen() call.
  210|       |	 */
  211|     72|	if (f == NULL && errno == ENOENT) {
  ------------------
  |  Branch (211:6): [True: 27, False: 45]
  |  Branch (211:19): [True: 26, False: 1]
  ------------------
  212|     26|		if ((r = sc_make_cache_dir(p15card->card->ctx)) < 0)
  ------------------
  |  Branch (212:7): [True: 26, False: 0]
  ------------------
  213|     26|			return r;
  214|      0|		f = fopen(fname, "ab");
  215|      0|	}
  216|     46|	if (f == NULL)
  ------------------
  |  Branch (216:6): [True: 1, False: 45]
  ------------------
  217|      1|		return 0;
  218|       |
  219|       |	/* we opened the file for appending so we should be at the end of file.
  220|       |	 * The ftell() will give use the length of the file */
  221|     45|	len = ftell(f);
  222|     45|	if (len > path->index) {
  ------------------
  |  Branch (222:6): [True: 4, False: 41]
  ------------------
  223|       |		/* override previous cache records on this location */
  224|      4|		r = fseek(f, path->index, SEEK_SET);
  225|      4|		if (r != 0) {
  ------------------
  |  Branch (225:7): [True: 0, False: 4]
  ------------------
  226|      0|			fclose(f);
  227|      0|			return 0;
  228|      0|		}
  229|     41|	} else if (path->index > len) {
  ------------------
  |  Branch (229:13): [True: 0, False: 41]
  ------------------
  230|       |		/* We miss some bytes so we will not cache this chunk */
  231|      0|		fclose(f);
  232|      0|		return 0;
  233|      0|	}
  234|       |
  235|     45|	c = fwrite(buf, 1, bufsize, f);
  236|     45|	fclose(f);
  237|     45|	if (c != bufsize) {
  ------------------
  |  Branch (237:6): [True: 0, False: 45]
  ------------------
  238|      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__
  |  |  ------------------
  ------------------
  239|      0|			 "fwrite() wrote only %"SC_FORMAT_LEN_SIZE_T"u bytes",
  240|      0|			 c);
  241|      0|		unlink(fname);
  242|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  243|      0|	}
  244|     45|	return 0;
  245|     45|}
pkcs15-cache.c:generate_cache_filename:
   44|  64.3k|{
   45|  64.3k|	char dir[PATH_MAX];
   46|  64.3k|	char *last_update = NULL;
   47|  64.3k|	int  r;
   48|  64.3k|	unsigned u;
   49|  64.3k|	size_t change_counter;
   50|       |
   51|  64.3k|	if (p15card->tokeninfo->serial_number == NULL
  ------------------
  |  Branch (51:6): [True: 3.78k, False: 60.5k]
  ------------------
   52|  3.78k|			&& (p15card->card->uid.len == 0
  ------------------
  |  Branch (52:8): [True: 3.78k, False: 0]
  ------------------
   53|      0|				|| p15card->card->uid.value[0] == RANDOM_UID_INDICATOR))
  ------------------
  |  |   40|      0|#define RANDOM_UID_INDICATOR 0x08
  ------------------
  |  Branch (53:8): [True: 0, False: 0]
  ------------------
   54|  3.78k|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  3.78k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   55|       |
   56|  60.5k|	if (path->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  60.5k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (56:6): [True: 0, False: 60.5k]
  ------------------
   57|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   58|  60.5k|	r = sc_get_cache_dir(p15card->card->ctx, dir, sizeof(dir));
   59|  60.5k|	if (r)
  ------------------
  |  Branch (59:6): [True: 0, False: 60.5k]
  ------------------
   60|      0|		return r;
   61|  60.5k|	snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "/");
   62|       |
   63|  60.5k|	last_update = sc_pkcs15_get_lastupdate(p15card);
   64|  60.5k|	if (!last_update)
  ------------------
  |  Branch (64:6): [True: 55.6k, False: 4.91k]
  ------------------
   65|  55.6k|		last_update = "NODATE";
   66|       |
   67|  60.5k|	if (p15card->tokeninfo->serial_number) {
  ------------------
  |  Branch (67:6): [True: 60.5k, False: 0]
  ------------------
   68|  60.5k|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
   69|  60.5k|				"%s_%s", p15card->tokeninfo->serial_number,
   70|  60.5k|				last_update);
   71|  60.5k|	} else {
   72|      0|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
   73|      0|				"uid-%s_%s", sc_dump_hex(
   74|      0|					p15card->card->uid.value,
   75|      0|					p15card->card->uid.len), last_update);
   76|      0|	}
   77|       |
   78|  60.5k|	if (SC_SUCCESS == sc_card_ctl(p15card->card, SC_CARDCTL_GET_CHANGE_COUNTER, &change_counter))
  ------------------
  |  |   28|  60.5k|#define SC_SUCCESS				0
  ------------------
  |  Branch (78:6): [True: 776, False: 59.7k]
  ------------------
   79|    776|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "_%" SC_FORMAT_LEN_SIZE_T "u", change_counter);
   80|       |
   81|  60.5k|	if (path->aid.len &&
  ------------------
  |  Branch (81:6): [True: 0, False: 60.5k]
  ------------------
   82|      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 (82:4): [True: 0, False: 0]
  |  Branch (82:42): [True: 0, False: 0]
  ------------------
   83|      0|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "_");
   84|      0|		for (u = 0; u < path->aid.len; u++)
  ------------------
  |  Branch (84:15): [True: 0, False: 0]
  ------------------
   85|      0|			snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
   86|      0|					"%02X",  path->aid.value[u]);
   87|      0|	}
   88|  60.5k|	else if (path->type != SC_PATH_TYPE_PATH)  {
  ------------------
  |  |  119|  60.5k|#define SC_PATH_TYPE_PATH		2
  ------------------
  |  Branch (88:11): [True: 95, False: 60.4k]
  ------------------
   89|     95|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     95|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   90|     95|	}
   91|       |
   92|  60.4k|	if (path->len)   {
  ------------------
  |  Branch (92:6): [True: 60.4k, False: 0]
  ------------------
   93|  60.4k|		size_t offs = 0;
   94|       |
   95|  60.4k|		if (path->len > 2 && memcmp(path->value, "\x3F\x00", 2) == 0)
  ------------------
  |  Branch (95:7): [True: 60.4k, False: 0]
  |  Branch (95:24): [True: 59.8k, False: 613]
  ------------------
   96|  59.8k|			offs = 2;
   97|  60.4k|		snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir), "_");
   98|   236k|		for (u = 0; u < path->len - offs; u++)
  ------------------
  |  Branch (98:15): [True: 176k, False: 60.4k]
  ------------------
   99|   176k|			snprintf(dir + strlen(dir), sizeof(dir) - strlen(dir),
  100|   176k|					"%02X",  path->value[u + offs]);
  101|  60.4k|	}
  102|       |
  103|  60.4k|	if (!buf)
  ------------------
  |  Branch (103:6): [True: 0, False: 60.4k]
  ------------------
  104|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  105|  60.4k|	strlcpy(buf, dir, bufsize);
  ------------------
  |  |   43|  60.4k|#define strlcpy _strlcpy
  ------------------
  106|       |
  107|  60.4k|	return SC_SUCCESS;
  ------------------
  |  |   28|  60.4k|#define SC_SUCCESS				0
  ------------------
  108|  60.4k|}

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

sc_pkcs15_read_certificate:
  371|     73|{
  372|     73|	struct sc_context *ctx = NULL;
  373|     73|	struct sc_pkcs15_cert *cert = NULL;
  374|     73|	struct sc_pkcs15_der der;
  375|     73|	int r;
  376|       |
  377|     73|	if (p15card == NULL || info == NULL || cert_out == NULL) {
  ------------------
  |  Branch (377:6): [True: 0, False: 73]
  |  Branch (377:25): [True: 0, False: 73]
  |  Branch (377:41): [True: 0, False: 73]
  ------------------
  378|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  379|      0|	}
  380|     73|	ctx = p15card->card->ctx;
  381|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  382|       |
  383|     73|	if (info->value.len && info->value.value)   {
  ------------------
  |  Branch (383:6): [True: 0, False: 73]
  |  Branch (383:25): [True: 0, False: 0]
  ------------------
  384|      0|		sc_der_copy(&der, &info->value);
  385|      0|	}
  386|     73|	else if (info->path.len) {
  ------------------
  |  Branch (386:11): [True: 73, False: 0]
  ------------------
  387|     73|		r = sc_pkcs15_read_file(p15card, &info->path, &der.value, &der.len, private_obj);
  388|     73|		LOG_TEST_RET(ctx, r, "Unable to read certificate file.");
  ------------------
  |  |  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: 67, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|     73|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  389|     73|	}
  390|      0|	else   {
  391|      0|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  392|      0|	}
  393|       |
  394|      6|	cert = malloc(sizeof(struct sc_pkcs15_cert));
  395|      6|	if (cert == NULL) {
  ------------------
  |  Branch (395:6): [True: 0, False: 6]
  ------------------
  396|      0|		free(der.value);
  397|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|      0|	}
  399|      6|	memset(cert, 0, sizeof(struct sc_pkcs15_cert));
  400|      6|	if (parse_x509_cert(ctx, &der, cert)) {
  ------------------
  |  Branch (400:6): [True: 6, False: 0]
  ------------------
  401|      6|		free(der.value);
  402|      6|		sc_pkcs15_free_certificate(cert);
  403|      6|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ASN1_OBJECT);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  404|      6|	}
  405|      0|	free(der.value);
  406|       |
  407|      0|	*cert_out = cert;
  408|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  409|      0|}
sc_pkcs15_decode_cdf_entry:
  446|    161|{
  447|    161|	sc_context_t *ctx = p15card->card->ctx;
  448|    161|	struct sc_pkcs15_cert_info info;
  449|    161|	struct sc_asn1_entry	asn1_cred_ident[3], asn1_com_cert_attr[4],
  450|    161|				asn1_x509_cert_attr[2], asn1_type_cert_attr[2],
  451|    161|				asn1_cert[2], asn1_x509_cert_value_choice[3];
  452|    161|	struct sc_asn1_pkcs15_object cert_obj = {
  453|    161|		obj, asn1_com_cert_attr, NULL,
  454|    161|		asn1_type_cert_attr };
  455|    161|	sc_pkcs15_der_t *der = &info.value;
  456|    161|	u8 id_value[128];
  457|    161|	int id_type;
  458|    161|	size_t id_value_len = sizeof(id_value);
  459|    161|	int r;
  460|       |
  461|    161|	sc_copy_asn1_entry(c_asn1_cred_ident, asn1_cred_ident);
  462|    161|	sc_copy_asn1_entry(c_asn1_com_cert_attr, asn1_com_cert_attr);
  463|    161|	sc_copy_asn1_entry(c_asn1_x509_cert_attr, asn1_x509_cert_attr);
  464|    161|	sc_copy_asn1_entry(c_asn1_x509_cert_value_choice, asn1_x509_cert_value_choice);
  465|    161|	sc_copy_asn1_entry(c_asn1_type_cert_attr, asn1_type_cert_attr);
  466|    161|	sc_copy_asn1_entry(c_asn1_cert, asn1_cert);
  467|       |
  468|    161|	sc_format_asn1_entry(asn1_cred_ident + 0, &id_type, NULL, 0);
  469|    161|	sc_format_asn1_entry(asn1_cred_ident + 1, &id_value, &id_value_len, 0);
  470|    161|	sc_format_asn1_entry(asn1_com_cert_attr + 0, &info.id, NULL, 0);
  471|    161|	sc_format_asn1_entry(asn1_com_cert_attr + 1, &info.authority, NULL, 0);
  472|    161|	sc_format_asn1_entry(asn1_com_cert_attr + 2, asn1_cred_ident, NULL, 0);
  473|    161|	sc_format_asn1_entry(asn1_x509_cert_attr + 0, asn1_x509_cert_value_choice, NULL, 0);
  474|    161|	sc_format_asn1_entry(asn1_x509_cert_value_choice + 0, &info.path, NULL, 0);
  475|    161|	sc_format_asn1_entry(asn1_x509_cert_value_choice + 1, &der->value, &der->len, 0);
  476|    161|	sc_format_asn1_entry(asn1_type_cert_attr + 0, asn1_x509_cert_attr, NULL, 0);
  477|    161|	sc_format_asn1_entry(asn1_cert + 0, &cert_obj, NULL, 0);
  478|       |
  479|       |	/* Fill in defaults */
  480|    161|	memset(&info, 0, sizeof(info));
  481|    161|	info.authority = 0;
  482|       |
  483|    161|	r = sc_asn1_decode(ctx, asn1_cert, *buf, *buflen, buf, buflen);
  484|       |	/* In case of error, trash the cert value (direct coding) */
  485|    161|	if (r < 0 && der->value)
  ------------------
  |  Branch (485:6): [True: 126, False: 35]
  |  Branch (485:15): [True: 0, False: 126]
  ------------------
  486|      0|		free(der->value);
  487|    161|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|    161|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (487:6): [True: 10, False: 151]
  ------------------
  488|     10|		return r;
  489|    151|	LOG_TEST_RET(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  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: 116, False: 35]
  |  |  |  |  ------------------
  |  |  |  |  169|    116|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    116|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    116|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    116|		return _ret; \
  |  |  |  |  172|    116|	} \
  |  |  |  |  173|    151|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  490|       |
  491|     35|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (491:6): [True: 34, False: 1]
  |  Branch (491:23): [True: 1, False: 0]
  ------------------
  492|     35|		if (!p15card->file_app) {
  ------------------
  |  Branch (492:7): [True: 0, False: 35]
  ------------------
  493|      0|			free(der->value);
  494|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  495|      0|		}
  496|     35|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path);
  497|     35|		LOG_TEST_RET(ctx, r, "Cannot make absolute path");
  ------------------
  |  |  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: 0, False: 35]
  |  |  |  |  ------------------
  |  |  |  |  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|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 35]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  498|     35|	}
  499|      0|	else   {
  500|      0|		info.path.aid = p15card->app->ddo.aid;
  501|      0|	}
  502|     35|	sc_log(ctx, "Certificate path '%s'", sc_print_path(&info.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  503|       |
  504|     35|	switch (p15card->opts.pin_protected_certificate) {
  ------------------
  |  Branch (504:10): [True: 0, False: 35]
  ------------------
  505|      0|		case SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY:
  ------------------
  |  |  611|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY	2
  ------------------
  |  Branch (505:3): [True: 0, False: 35]
  ------------------
  506|      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__
  |  |  ------------------
  ------------------
  507|      0|			obj->flags &= ~SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  508|      0|			break;
  509|      0|		case SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE:
  ------------------
  |  |  610|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE		1
  ------------------
  |  Branch (509:3): [True: 0, False: 35]
  ------------------
  510|      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__
  |  |  ------------------
  ------------------
  511|      0|			free(der->value);
  512|      0|			return 0;
  513|     35|	}
  514|       |
  515|     35|	obj->type = SC_PKCS15_TYPE_CERT_X509;
  ------------------
  |  |  439|     35|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  516|     35|	obj->data = malloc(sizeof(info));
  517|     35|	if (obj->data == NULL)
  ------------------
  |  Branch (517:6): [True: 0, False: 35]
  ------------------
  518|     35|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|     35|	memcpy(obj->data, &info, sizeof(info));
  520|       |
  521|     35|	return 0;
  522|     35|}
sc_pkcs15_free_certificate:
  645|      6|{
  646|      6|	if (cert == NULL) {
  ------------------
  |  Branch (646:6): [True: 0, False: 6]
  ------------------
  647|      0|		return;
  648|      0|	}
  649|       |
  650|      6|	sc_pkcs15_free_pubkey(cert->key);
  651|      6|	free(cert->subject);
  652|      6|	free(cert->issuer);
  653|      6|	free(cert->serial);
  654|      6|	free(cert->data.value);
  655|      6|	free(cert->extensions);
  656|      6|	free(cert);
  657|      6|}
sc_pkcs15_free_cert_info:
  662|    278|{
  663|    278|	if (!cert)
  ------------------
  |  Branch (663:6): [True: 0, False: 278]
  ------------------
  664|      0|		return;
  665|    278|	free(cert->value.value);
  666|    278|	free(cert);
  667|    278|}
pkcs15-cert.c:parse_x509_cert:
   40|      6|{
   41|      6|	int r;
   42|      6|	struct sc_algorithm_id sig_alg = {0};
   43|      6|	struct sc_pkcs15_pubkey *pubkey = NULL;
   44|      6|	unsigned char *serial = NULL, *issuer = NULL, *subject = NULL, *buf =  der->value;
   45|      6|	size_t serial_len = 0, issuer_len = 0, subject_len = 0, data_len = 0, buflen = der->len;
   46|      6|	struct sc_asn1_entry asn1_version[] = {
   47|      6|		{ "version", SC_ASN1_INTEGER, SC_ASN1_TAG_INTEGER, 0, &cert->version, NULL },
  ------------------
  |  |  154|      6|#define SC_ASN1_INTEGER                 2
  ------------------
              		{ "version", SC_ASN1_INTEGER, SC_ASN1_TAG_INTEGER, 0, &cert->version, NULL },
  ------------------
  |  |  196|      6|#define SC_ASN1_TAG_INTEGER		2
  ------------------
   48|      6|		{ NULL, 0, 0, 0, NULL, NULL }
   49|      6|	};
   50|      6|	struct sc_asn1_entry asn1_extensions[] = {
   51|      6|		{ "x509v3",		SC_ASN1_OCTET_STRING,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_OPTIONAL| SC_ASN1_ALLOC, &cert->extensions, &cert->extensions_len },
  ------------------
  |  |  157|      6|#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|      6|#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|      6|#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|      6|#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|      6|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   52|      6|		{ NULL, 0, 0, 0, NULL, NULL }
   53|      6|	};
   54|      6|	struct sc_asn1_entry asn1_tbscert[] = {
   55|      6|		{ "version",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 0 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_version, NULL },
  ------------------
  |  |  169|      6|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "version",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 0 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_version, NULL },
  ------------------
  |  |  139|      6|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
              		{ "version",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 0 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_version, NULL },
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "version",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 0 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_version, NULL },
  ------------------
  |  |  148|      6|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
   56|      6|		{ "serialNumber",	SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, &serial, &serial_len },
  ------------------
  |  |  157|      6|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "serialNumber",	SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, &serial, &serial_len },
  ------------------
  |  |  196|      6|#define SC_ASN1_TAG_INTEGER		2
  ------------------
              		{ "serialNumber",	SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, &serial, &serial_len },
  ------------------
  |  |  149|      6|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   57|      6|		{ "signature",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  169|      6|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "signature",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  206|      6|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "signature",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
   58|      6|		{ "issuer",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &issuer, &issuer_len },
  ------------------
  |  |  157|      6|#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|      6|#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|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "issuer",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &issuer, &issuer_len },
  ------------------
  |  |  149|      6|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   59|      6|		{ "validity",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  169|      6|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "validity",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  206|      6|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "validity",		SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, NULL, NULL },
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
   60|      6|		{ "subject",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &subject, &subject_len },
  ------------------
  |  |  157|      6|#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|      6|#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|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "subject",		SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, &subject, &subject_len },
  ------------------
  |  |  149|      6|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   61|       |		/* Use a callback to get the algorithm, parameters and pubkey into sc_pkcs15_pubkey */
   62|      6|		{ "subjectPublicKeyInfo",SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki_fields,  &pubkey },
  ------------------
  |  |  181|      6|#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|      6|#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|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
   63|      6|		{ "extensions",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 3 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_extensions, NULL },
  ------------------
  |  |  169|      6|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "extensions",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 3 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_extensions, NULL },
  ------------------
  |  |  139|      6|#define SC_ASN1_CTX			0x80000000 /* Context */
  ------------------
              		{ "extensions",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 3 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_extensions, NULL },
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "extensions",		SC_ASN1_STRUCT,    SC_ASN1_CTX | 3 | SC_ASN1_CONS, SC_ASN1_OPTIONAL, asn1_extensions, NULL },
  ------------------
  |  |  148|      6|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
   64|      6|		{ NULL, 0, 0, 0, NULL, NULL }
   65|      6|	};
   66|      6|	struct sc_asn1_entry asn1_cert[] = {
   67|      6|		{ "tbsCertificate",	SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, asn1_tbscert, NULL },
  ------------------
  |  |  169|      6|#define SC_ASN1_STRUCT			129
  ------------------
              		{ "tbsCertificate",	SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, asn1_tbscert, NULL },
  ------------------
  |  |  206|      6|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "tbsCertificate",	SC_ASN1_STRUCT,    SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, asn1_tbscert, NULL },
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
   68|      6|		{ "signatureAlgorithm",	SC_ASN1_ALGORITHM_ID, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, &sig_alg, NULL },
  ------------------
  |  |  177|      6|#define SC_ASN1_ALGORITHM_ID		259
  ------------------
              		{ "signatureAlgorithm",	SC_ASN1_ALGORITHM_ID, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, &sig_alg, NULL },
  ------------------
  |  |  206|      6|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "signatureAlgorithm",	SC_ASN1_ALGORITHM_ID, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, &sig_alg, NULL },
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
   69|      6|		{ "signatureValue",	SC_ASN1_BIT_STRING, SC_ASN1_TAG_BIT_STRING, 0, NULL, NULL },
  ------------------
  |  |  155|      6|#define SC_ASN1_BIT_STRING              3
  ------------------
              		{ "signatureValue",	SC_ASN1_BIT_STRING, SC_ASN1_TAG_BIT_STRING, 0, NULL, NULL },
  ------------------
  |  |  197|      6|#define SC_ASN1_TAG_BIT_STRING		3
  ------------------
   70|      6|		{ NULL, 0, 0, 0, NULL, NULL }
   71|      6|	};
   72|      6|	struct sc_asn1_entry asn1_serial_number[] = {
   73|      6|		{ "serialNumber", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  157|      6|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "serialNumber", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  196|      6|#define SC_ASN1_TAG_INTEGER		2
  ------------------
              		{ "serialNumber", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_INTEGER, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|      6|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   74|      6|		{ NULL, 0, 0, 0, NULL, NULL }
   75|      6|	};
   76|      6|	struct sc_asn1_entry asn1_subject[] = {
   77|      6|		{ "subject", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  157|      6|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "subject", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  206|      6|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "subject", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "subject", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|      6|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   78|      6|		{ NULL, 0, 0, 0, NULL, NULL }
   79|      6|	};
   80|      6|	struct sc_asn1_entry asn1_issuer[] = {
   81|      6|		{ "issuer", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  157|      6|#define SC_ASN1_OCTET_STRING            4
  ------------------
              		{ "issuer", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  206|      6|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              		{ "issuer", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "issuer", SC_ASN1_OCTET_STRING, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, SC_ASN1_ALLOC, NULL, NULL },
  ------------------
  |  |  149|      6|#define SC_ASN1_ALLOC			0x00000004
  ------------------
   82|      6|		{ NULL, 0, 0, 0, NULL, NULL }
   83|      6|	};
   84|       |
   85|      6|	const u8 *obj;
   86|      6|	size_t objlen;
   87|       |
   88|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   89|       |
   90|      6|	memset(cert, 0, sizeof(*cert));
   91|      6|	obj = sc_asn1_verify_tag(ctx, buf, buflen, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &objlen);
  ------------------
  |  |  206|      6|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
              	obj = sc_asn1_verify_tag(ctx, buf, buflen, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, &objlen);
  ------------------
  |  |  141|      6|#define SC_ASN1_CONS			0x20000000
  ------------------
   92|      6|	if (obj == NULL)
  ------------------
  |  Branch (92:6): [True: 2, False: 4]
  ------------------
   93|      6|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "X.509 certificate not found");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   94|       |
   95|      4|	data_len = objlen + (obj - buf);
   96|      4|	cert->data.value = malloc(data_len);
   97|      4|	if (!cert->data.value)
  ------------------
  |  Branch (97:6): [True: 0, False: 4]
  ------------------
   98|      4|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   99|      4|	memcpy(cert->data.value, buf, data_len);
  100|      4|	cert->data.len = data_len;
  101|       |
  102|      4|	r = sc_asn1_decode(ctx, asn1_cert, obj, objlen, NULL, NULL);
  103|      4|	cert->key = pubkey;
  104|      4|	cert->version++;
  105|       |
  106|      4|	LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 parsing of certificate failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|       |
  108|      0|	if (!pubkey)
  ------------------
  |  Branch (108:6): [True: 0, False: 0]
  ------------------
  109|      0|		LOG_TEST_GOTO_ERR(ctx, SC_ERROR_INVALID_ASN1_OBJECT, "Unable to decode subjectPublicKeyInfo from cert");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |
  111|       |
  112|      0|	if (serial && serial_len)   {
  ------------------
  |  Branch (112:6): [True: 0, False: 0]
  |  Branch (112:16): [True: 0, False: 0]
  ------------------
  113|      0|		sc_format_asn1_entry(asn1_serial_number + 0, serial, &serial_len, 1);
  114|      0|		r = sc_asn1_encode(ctx, asn1_serial_number, &cert->serial, &cert->serial_len);
  115|      0|		LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 encoding of serial 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  116|      0|	}
  117|       |
  118|      0|	if (subject && subject_len)   {
  ------------------
  |  Branch (118:6): [True: 0, False: 0]
  |  Branch (118:17): [True: 0, False: 0]
  ------------------
  119|      0|		sc_format_asn1_entry(asn1_subject + 0, subject, &subject_len, 1);
  120|      0|		r = sc_asn1_encode(ctx, asn1_subject, &cert->subject, &cert->subject_len);
  121|      0|		LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 encoding of subject");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  122|      0|	}
  123|       |
  124|      0|	if (issuer && issuer_len)   {
  ------------------
  |  Branch (124:6): [True: 0, False: 0]
  |  Branch (124:16): [True: 0, False: 0]
  ------------------
  125|      0|		sc_format_asn1_entry(asn1_issuer + 0, issuer, &issuer_len, 1);
  126|      0|		r = sc_asn1_encode(ctx, asn1_issuer, &cert->issuer, &cert->issuer_len);
  127|      0|		LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 encoding of issuer");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  128|      0|	}
  129|       |
  130|      4|err:
  131|       |	/* not used for anything */
  132|      4|	sc_asn1_clear_algorithm_id(&sig_alg);
  133|      4|	free(serial);
  134|      4|	free(subject);
  135|      4|	free(issuer);
  136|       |
  137|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  138|      4|}

sc_pkcs15emu_coolkey_init_ex:
  732|  3.37k|{
  733|  3.37k|	sc_card_t      *card = p15card->card;
  734|  3.37k|	sc_context_t    *ctx = card->ctx;
  735|  3.37k|	int rv;
  736|       |
  737|  3.37k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.37k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.37k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.37k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.37k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.37k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  738|       |
  739|  3.37k|	rv = coolkey_detect_card(p15card);
  740|  3.37k|	if (rv)
  ------------------
  |  Branch (740:6): [True: 3.37k, False: 0]
  ------------------
  741|  3.37k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  3.37k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.37k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.37k|	int _ret = r; \
  |  |  |  |  155|  3.37k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.37k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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|  3.37k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.37k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.37k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.37k|	return _ret; \
  |  |  |  |  163|  3.37k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|      0|	rv = sc_pkcs15emu_coolkey_init(p15card);
  743|       |
  744|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  745|      0|}
pkcs15-coolkey.c:coolkey_detect_card:
   60|  3.37k|{
   61|  3.37k|	sc_card_t *card = p15card->card;
   62|       |
   63|  3.37k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.37k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.37k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.37k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.37k]
  |  |  ------------------
  ------------------
   64|  3.37k|	if (card->type < SC_CARD_TYPE_COOLKEY_GENERIC
  ------------------
  |  Branch (64:6): [True: 3.36k, False: 13]
  ------------------
   65|     13|		|| card->type >= SC_CARD_TYPE_COOLKEY_GENERIC+1000)
  ------------------
  |  Branch (65:6): [True: 13, False: 0]
  ------------------
   66|  3.37k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  3.37k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
   67|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
   68|  3.37k|}

sc_pkcs15_decode_dodf_entry:
   95|     12|{
   96|     12|        sc_context_t *ctx = p15card->card->ctx;
   97|     12|	struct sc_pkcs15_data_info info;
   98|     12|	struct sc_asn1_entry	asn1_com_data_attr[3],
   99|     12|				asn1_type_data_attr[2],
  100|     12|				asn1_data[2];
  101|     12|	struct sc_asn1_pkcs15_object data_obj = { obj, asn1_com_data_attr, NULL,
  102|     12|					     asn1_type_data_attr };
  103|     12|	size_t label_len = sizeof(info.app_label) - 1;
  104|     12|	int r;
  105|       |
  106|     12|	memset(info.app_label, 0, sizeof(info.app_label));
  107|       |
  108|     12|	sc_copy_asn1_entry(c_asn1_com_data_attr, asn1_com_data_attr);
  109|     12|	sc_copy_asn1_entry(c_asn1_type_data_attr, asn1_type_data_attr);
  110|     12|	sc_copy_asn1_entry(c_asn1_data, asn1_data);
  111|       |
  112|     12|	sc_format_asn1_entry(asn1_com_data_attr + 0, &info.app_label, &label_len, 0);
  113|     12|	sc_format_asn1_entry(asn1_com_data_attr + 1, &info.app_oid, NULL, 0);
  114|     12|	sc_format_asn1_entry(asn1_type_data_attr + 0, &info.path, NULL, 0);
  115|     12|	sc_format_asn1_entry(asn1_data + 0, &data_obj, NULL, 0);
  116|       |
  117|       |	/* Fill in defaults */
  118|     12|	memset(&info, 0, sizeof(info));
  119|     12|	sc_init_oid(&info.app_oid);
  120|       |
  121|     12|	r = sc_asn1_decode(ctx, asn1_data, *buf, *buflen, buf, buflen);
  122|     12|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|     12|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (122:6): [True: 1, False: 11]
  ------------------
  123|      1|		return r;
  124|     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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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_encode_dodf_entry:
  150|     72|{
  151|     72|	struct sc_asn1_entry	asn1_com_data_attr[4],
  152|     72|				asn1_type_data_attr[2],
  153|     72|				asn1_data[2];
  154|     72|	struct sc_pkcs15_data_info *info;
  155|     72|	struct sc_asn1_pkcs15_object data_obj = { (struct sc_pkcs15_object *) obj,
  156|     72|							asn1_com_data_attr, NULL,
  157|     72|							asn1_type_data_attr };
  158|     72|	size_t label_len;
  159|       |
  160|     72|	info = (struct sc_pkcs15_data_info *) obj->data;
  161|     72|	label_len = strnlen(info->app_label, sizeof info->app_label);
  162|       |
  163|     72|	sc_copy_asn1_entry(c_asn1_com_data_attr, asn1_com_data_attr);
  164|     72|	sc_copy_asn1_entry(c_asn1_type_data_attr, asn1_type_data_attr);
  165|     72|	sc_copy_asn1_entry(c_asn1_data, asn1_data);
  166|       |
  167|     72|	if (label_len)
  ------------------
  |  Branch (167:6): [True: 72, False: 0]
  ------------------
  168|     72|		sc_format_asn1_entry(asn1_com_data_attr + 0, &info->app_label, &label_len, 1);
  169|       |
  170|     72|	if (sc_valid_oid(&info->app_oid))
  ------------------
  |  Branch (170:6): [True: 10, False: 62]
  ------------------
  171|     10|		sc_format_asn1_entry(asn1_com_data_attr + 1, &info->app_oid, NULL, 1);
  172|       |
  173|     72|	sc_format_asn1_entry(asn1_type_data_attr + 0, &info->path, NULL, 1);
  174|     72|	sc_format_asn1_entry(asn1_data + 0, &data_obj, NULL, 1);
  175|       |
  176|     72|	return sc_asn1_encode(ctx, asn1_data, buf, bufsize);
  177|     72|}
sc_pkcs15_free_data_info:
  189|  2.28k|{
  190|  2.28k|	if (info && info->data.value && info->data.len)
  ------------------
  |  Branch (190:6): [True: 2.28k, False: 0]
  |  Branch (190:14): [True: 2.21k, False: 62]
  |  Branch (190:34): [True: 2.21k, False: 0]
  ------------------
  191|  2.21k|		free(info->data.value);
  192|       |
  193|  2.28k|	free(info);
  194|  2.28k|}

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

sc_pkcs15emu_dnie_init_ex:
  281|  3.38k|{
  282|  3.38k|	int r=SC_SUCCESS;
  ------------------
  |  |   28|  3.38k|#define SC_SUCCESS				0
  ------------------
  283|  3.38k|	sc_context_t *ctx = p15card->card->ctx;
  284|  3.38k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.38k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.38k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.38k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.38k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.38k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  285|       |
  286|  3.38k|#if defined(ENABLE_OPENSSL) && defined(ENABLE_SM)
  287|       |	/* check for proper card */
  288|  3.38k|	r = dnie_match_card(p15card->card);
  289|  3.38k|	if (r == 0)
  ------------------
  |  Branch (289:6): [True: 3.38k, False: 0]
  ------------------
  290|  3.38k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  3.38k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.38k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.38k|	int _ret = r; \
  |  |  |  |  155|  3.38k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.38k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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|  3.38k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.38k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.38k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.38k|	return _ret; \
  |  |  |  |  163|  3.38k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  291|       |	/* ok: initialize and return */
  292|      0|	LOG_FUNC_RETURN(ctx, sc_pkcs15emu_dnie_init(p15card));
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} 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|      0|}

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

sc_pkcs15emu_eoi_init_ex:
   35|  2.54k|{
   36|  2.54k|	struct sc_card *card = p15card->card;
   37|  2.54k|	struct eoi_privdata *privdata = (struct eoi_privdata *)card->drv_data;
   38|  2.54k|	struct sc_pkcs15_search_key sk;
   39|  2.54k|	struct sc_pkcs15_object *objs[MAX_OBJECTS];
   40|  2.54k|	int i, j, len;
   41|       |
   42|  2.54k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.54k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.54k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.54k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.54k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.54k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   43|       |
   44|  2.54k|	if (card->type != SC_CARD_TYPE_EOI && card->type != SC_CARD_TYPE_EOI_CONTACTLESS)
  ------------------
  |  Branch (44:6): [True: 2.54k, False: 0]
  |  Branch (44:40): [True: 2.54k, False: 0]
  ------------------
   45|  2.54k|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  2.54k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.54k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.54k|	int _ret = r; \
  |  |  |  |  155|  2.54k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.54k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.54k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.54k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.54k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.54k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.54k|	} else { \
  |  |  |  |  159|      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.54k|	return _ret; \
  |  |  |  |  163|  2.54k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   46|       |
   47|      0|	if (!privdata)
  ------------------
  |  Branch (47:6): [True: 0, False: 0]
  ------------------
   48|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   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 establisahed).
   53|       |	 */
   54|      0|	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: 0]
  |  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|      0|	LOG_TEST_RET(card->ctx, sc_pkcs15_bind_internal(p15card, aid),
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   64|      0|		"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|      0|	memset(&sk, 0, sizeof(sk));
   72|      0|	sk.class_mask = SC_PKCS15_SEARCH_CLASS_AUTH;
  ------------------
  |  |  455|      0|#define SC_PKCS15_SEARCH_CLASS_AUTH		0x0040U
  ------------------
   73|      0|	len = sc_pkcs15_search_objects(p15card, &sk, (struct sc_pkcs15_object **)&objs, MAX_OBJECTS);
  ------------------
  |  |   24|      0|#define MAX_OBJECTS 8
  ------------------
   74|      0|	for (i = 0, j = 0; i < len; i++) {
  ------------------
  |  Branch (74:21): [True: 0, False: 0]
  ------------------
   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|      0|	memset(&sk, 0, sizeof(sk));
  116|      0|	sk.class_mask = SC_PKCS15_SEARCH_CLASS_PRKEY;
  ------------------
  |  |  450|      0|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
  117|      0|	len = sc_pkcs15_search_objects(p15card, &sk, (struct sc_pkcs15_object **)&objs, MAX_OBJECTS);
  ------------------
  |  |   24|      0|#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|      0|	for (j = 0; privdata->prkey_mappings[j][1] != 0; j++) {
  ------------------
  |  Branch (122:14): [True: 0, False: 0]
  ------------------
  123|       |		/* NOP */
  124|      0|	}
  125|      0|	for (i = 0; i < len; i++) {
  ------------------
  |  Branch (125:14): [True: 0, False: 0]
  ------------------
  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) {
  ------------------
  |  Branch (130:7): [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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  137|      0|}

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

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

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

sc_pkcs15emu_gemsafeV1_init_ex:
  453|  3.39k|{
  454|  3.39k|	if (gemsafe_detect_card(p15card))
  ------------------
  |  Branch (454:6): [True: 3.39k, False: 0]
  ------------------
  455|  3.39k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  456|      0|	return sc_pkcs15emu_gemsafeV1_init(p15card);
  457|  3.39k|}
pkcs15-gemsafeV1.c:gemsafe_detect_card:
  300|  3.39k|{
  301|  3.39k|	if (strcmp(p15card->card->name, "GemSAFE V1"))
  ------------------
  |  Branch (301:6): [True: 3.39k, False: 0]
  ------------------
  302|  3.39k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  303|       |
  304|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  305|  3.39k|}

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

sc_pkcs15emu_iasecc_init_ex:
  257|  3.38k|{
  258|  3.38k|	if (iasecc_pkcs15emu_detect_card(p15card))
  ------------------
  |  Branch (258:6): [True: 3.05k, False: 329]
  ------------------
  259|  3.05k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.05k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  260|       |
  261|    329|	return sc_pkcs15emu_iasecc_init(p15card, aid);
  262|  3.38k|}
pkcs15-iasecc.c:iasecc_pkcs15emu_detect_card:
  228|  3.38k|{
  229|  3.38k|	if (p15card->card->type < SC_CARD_TYPE_IASECC_BASE)
  ------------------
  |  Branch (229:6): [True: 2.83k, False: 548]
  ------------------
  230|  2.83k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  2.83k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  231|       |
  232|    548|	if (p15card->card->type > SC_CARD_TYPE_IASECC_BASE + 10)
  ------------------
  |  Branch (232:6): [True: 219, False: 329]
  ------------------
  233|    219|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|    219|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  234|       |
  235|    329|	return SC_SUCCESS;
  ------------------
  |  |   28|    329|#define SC_SUCCESS				0
  ------------------
  236|    548|}
pkcs15-iasecc.c:sc_pkcs15emu_iasecc_init:
  241|    329|{
  242|    329|	struct sc_context *ctx = p15card->card->ctx;
  243|    329|	int rv;
  244|       |
  245|    329|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    329|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    329|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    329|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    329|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 329]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|       |
  247|    329|	rv = sc_pkcs15_bind_internal(p15card, aid);
  248|       |
  249|    329|	p15card->ops.parse_df = _iasecc_parse_df;
  250|       |
  251|    329|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    329|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    329|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    329|	int _ret = r; \
  |  |  |  |  155|    329|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 329, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    329|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    320|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 320, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  157|    329|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    329|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    329|	return _ret; \
  |  |  |  |  163|    329|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  252|    329|}

sc_pkcs15emu_idprime_init_ex:
  358|  3.39k|{
  359|  3.39k|	sc_card_t   *card = p15card->card;
  360|  3.39k|	sc_context_t    *ctx = card->ctx;
  361|       |
  362|  3.39k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.39k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.39k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.39k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.39k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.39k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|       |
  364|  3.39k|	if (idprime_detect_card(p15card))
  ------------------
  |  Branch (364:6): [True: 3.39k, False: 0]
  ------------------
  365|  3.39k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  366|      0|	return sc_pkcs15emu_idprime_init(p15card);
  367|  3.39k|}
pkcs15-idprime.c:idprime_detect_card:
   40|  3.39k|{
   41|  3.39k|	sc_card_t *card = p15card->card;
   42|       |
   43|  3.39k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.39k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.39k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.39k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.39k]
  |  |  ------------------
  ------------------
   44|       |
   45|  3.39k|	if (card->type < SC_CARD_TYPE_IDPRIME_BASE
  ------------------
  |  Branch (45:6): [True: 3.39k, False: 0]
  ------------------
   46|      0|		|| card->type >= SC_CARD_TYPE_IDPRIME_BASE+1000)
  ------------------
  |  Branch (46:6): [True: 0, False: 0]
  ------------------
   47|  3.39k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  3.39k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
   48|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
   49|  3.39k|}

sc_pkcs15emu_itacns_init_ex:
  881|  3.39k|{
  882|  3.39k|	sc_card_t *card = p15card->card;
  883|  3.39k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|  3.39k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.39k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.39k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.39k]
  |  |  ------------------
  ------------------
  884|       |
  885|       |	/* Check card */
  886|  3.39k|	if (! (
  887|  3.39k|			(card->type > SC_CARD_TYPE_ITACNS_BASE &&
  ------------------
  |  Branch (887:5): [True: 548, False: 2.85k]
  ------------------
  888|    548|			card->type < SC_CARD_TYPE_ITACNS_BASE + 1000)
  ------------------
  |  Branch (888:4): [True: 0, False: 548]
  ------------------
  889|  3.39k|		|| card->type == SC_CARD_TYPE_CARDOS_CIE_V1)
  ------------------
  |  Branch (889:6): [True: 0, False: 3.39k]
  ------------------
  890|  3.39k|		)
  891|  3.39k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  892|       |
  893|       |	/* Init card */
  894|      0|	return itacns_init(p15card);
  895|  3.39k|}

sc_pkcs15emu_jpki_init_ex:
  241|  3.37k|{
  242|  3.37k|	if (p15card->card->type != SC_CARD_TYPE_JPKI_BASE)
  ------------------
  |  Branch (242:6): [True: 3.37k, False: 0]
  ------------------
  243|  3.37k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.37k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  244|      0|	return sc_pkcs15emu_jpki_init(p15card);
  245|  3.37k|}

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

sc_pkcs15emu_nqapplet_init_ex:
  179|  2.54k|{
  180|  2.54k|	int rv = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  2.54k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  181|  2.54k|	sc_context_t *ctx;
  182|  2.54k|	sc_card_t *card;
  183|       |
  184|  2.54k|	if (!p15card || !p15card->card || !p15card->card->ctx) {
  ------------------
  |  Branch (184:6): [True: 0, False: 2.54k]
  |  Branch (184:18): [True: 0, False: 2.54k]
  |  Branch (184:36): [True: 0, False: 2.54k]
  ------------------
  185|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  186|      0|	}
  187|       |
  188|  2.54k|	card = p15card->card;
  189|  2.54k|	ctx = card->ctx;
  190|       |
  191|  2.54k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|  2.54k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.54k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.54k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  192|       |
  193|  2.54k|	if (card->type < SC_CARD_TYPE_NQ_APPLET || card->type > SC_CARD_TYPE_NQ_APPLET_RFID) {
  ------------------
  |  Branch (193:6): [True: 2.54k, False: 0]
  |  Branch (193:45): [True: 0, False: 0]
  ------------------
  194|  2.54k|		sc_log(p15card->card->ctx, "Unsupported card type: %d", card->type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  195|  2.54k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  2.54k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  196|  2.54k|	}
  197|       |
  198|      0|	rv = add_nqapplet_objects(p15card);
  199|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "Failed to add PKCS15");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  200|       |
  201|      0|	if (aid != NULL) {
  ------------------
  |  Branch (201:6): [True: 0, False: 0]
  ------------------
  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|      0|	sc_pkcs15_free_tokeninfo(p15card->tokeninfo);
  212|       |
  213|      0|	p15card->tokeninfo = sc_pkcs15_tokeninfo_new();
  214|      0|	if (p15card->tokeninfo == NULL) {
  ------------------
  |  Branch (214:6): [True: 0, False: 0]
  ------------------
  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|      0|	} else {
  218|      0|		char serial_hex[SC_MAX_SERIALNR * 2 + 2];
  219|       |
  220|      0|		sc_bin_to_hex(card->serialnr.value, card->serialnr.len, serial_hex, sizeof(serial_hex), 0);
  221|      0|		set_string(&p15card->tokeninfo->serial_number, serial_hex);
  222|      0|		set_string(&p15card->tokeninfo->label, name_Card);
  223|      0|		set_string(&p15card->tokeninfo->manufacturer_id, name_Vendor);
  224|      0|		p15card->tokeninfo->flags = SC_PKCS15_TOKEN_READONLY;
  ------------------
  |  |  595|      0|#define SC_PKCS15_TOKEN_READONLY			0x01
  ------------------
  225|      0|	}
  226|       |
  227|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  228|      0|err:
  229|      0|	sc_pkcs15_card_clear(p15card);
  230|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|      0|}

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

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

sc_pkcs15_decode_aodf_entry:
   86|    292|{
   87|    292|	sc_context_t *ctx = p15card->card->ctx;
   88|    292|	struct sc_pkcs15_auth_info info;
   89|    292|	int r;
   90|    292|	size_t flags_len = sizeof(info.attrs.pin.flags);
   91|    292|	size_t derived_len = sizeof(info.attrs.authkey.derived);
   92|    292|	size_t padchar_len = 1;
   93|    292|	struct sc_asn1_entry asn1_com_ao_attr[2];
   94|    292|	struct sc_asn1_entry asn1_pin_attr[10], asn1_type_pin_attr[2];
   95|    292|	struct sc_asn1_entry asn1_authkey_attr[3], asn1_type_authkey_attr[2];
   96|    292|	struct sc_asn1_entry asn1_auth_type[2];
   97|    292|	struct sc_asn1_entry asn1_auth_type_choice[4];
   98|    292|	struct sc_asn1_pkcs15_object pin_obj = { obj, asn1_com_ao_attr, NULL, asn1_type_pin_attr };
   99|    292|	struct sc_asn1_pkcs15_object authkey_obj = { obj, asn1_com_ao_attr, NULL, asn1_type_authkey_attr };
  100|       |
  101|    292|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_ASN1);
  ------------------
  |  |  148|    292|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    292|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    292|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 292]
  |  |  ------------------
  ------------------
  102|       |
  103|    292|	sc_copy_asn1_entry(c_asn1_auth_type, asn1_auth_type);
  104|    292|	sc_copy_asn1_entry(c_asn1_auth_type_choice, asn1_auth_type_choice);
  105|       |
  106|    292|	sc_copy_asn1_entry(c_asn1_com_ao_attr, asn1_com_ao_attr);
  107|       |
  108|    292|	sc_copy_asn1_entry(c_asn1_type_pin_attr, asn1_type_pin_attr);
  109|    292|	sc_copy_asn1_entry(c_asn1_pin_attr, asn1_pin_attr);
  110|       |
  111|    292|	sc_copy_asn1_entry(c_asn1_type_authkey_attr, asn1_type_authkey_attr);
  112|    292|	sc_copy_asn1_entry(c_asn1_authkey_attr, asn1_authkey_attr);
  113|       |
  114|    292|	sc_format_asn1_entry(asn1_auth_type + 0, asn1_auth_type_choice, NULL, 0);
  115|    292|	sc_format_asn1_entry(asn1_auth_type_choice + 0, &pin_obj, NULL, 0);	/* 'pin' */
  116|    292|	sc_format_asn1_entry(asn1_auth_type_choice + 2, &authkey_obj, NULL, 0);	/* 'authKey' */
  117|       |
  118|       |	/* pinAttributes */
  119|    292|	sc_format_asn1_entry(asn1_type_pin_attr + 0, asn1_pin_attr, NULL, 0);
  120|    292|	sc_format_asn1_entry(asn1_pin_attr + 0, &info.attrs.pin.flags, &flags_len, 0);
  121|    292|	sc_format_asn1_entry(asn1_pin_attr + 1, &info.attrs.pin.type, NULL, 0);
  122|    292|	sc_format_asn1_entry(asn1_pin_attr + 2, &info.attrs.pin.min_length, NULL, 0);
  123|    292|	sc_format_asn1_entry(asn1_pin_attr + 3, &info.attrs.pin.stored_length, NULL, 0);
  124|    292|	sc_format_asn1_entry(asn1_pin_attr + 4, &info.attrs.pin.max_length, NULL, 0);
  125|    292|	sc_format_asn1_entry(asn1_pin_attr + 5, &info.attrs.pin.reference, NULL, 0);
  126|    292|	sc_format_asn1_entry(asn1_pin_attr + 6, &info.attrs.pin.pad_char, &padchar_len, 0);
  127|       |
  128|       |	/* authKeyAttributes */
  129|    292|	sc_format_asn1_entry(asn1_type_authkey_attr + 0, asn1_authkey_attr, NULL, 0);
  130|    292|	sc_format_asn1_entry(asn1_authkey_attr + 0, &info.attrs.authkey.derived, &derived_len, 0);
  131|    292|	sc_format_asn1_entry(asn1_authkey_attr + 1, &info.attrs.authkey.skey_id, NULL, 0);
  132|       |
  133|       |	/* We don't support lastPinChange yet. */
  134|    292|	sc_format_asn1_entry(asn1_pin_attr + 8, &info.path, NULL, 0);
  135|       |
  136|    292|	sc_format_asn1_entry(asn1_com_ao_attr + 0, &info.auth_id, NULL, 0);
  137|       |
  138|       |	/* Fill in defaults */
  139|    292|	memset(&info, 0, sizeof(info));
  140|    292|	info.tries_left = -1;
  141|    292|	info.logged_in = SC_PIN_STATE_UNKNOWN;
  ------------------
  |  |  437|    292|#define SC_PIN_STATE_UNKNOWN	0
  ------------------
  142|       |
  143|    292|	r = sc_asn1_decode(ctx, asn1_auth_type, *buf, *buflen, buf, buflen);
  144|    292|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|    292|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (144:6): [True: 20, False: 272]
  ------------------
  145|     20|		return r;
  146|    272|	LOG_TEST_RET(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  174|    272|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    272|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    272|	int _ret = (r); \
  |  |  |  |  168|    272|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 157, False: 115]
  |  |  |  |  ------------------
  |  |  |  |  169|    157|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    157|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    157|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    157|		return _ret; \
  |  |  |  |  172|    157|	} \
  |  |  |  |  173|    272|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 115]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  147|       |
  148|    115|	if (asn1_auth_type_choice[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|    115|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (148:6): [True: 100, False: 15]
  ------------------
  149|    100|		sc_log(ctx, "AuthType: PIN");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  150|    100|		obj->type = SC_PKCS15_TYPE_AUTH_PIN;
  ------------------
  |  |  445|    100|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  151|    100|		info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    100|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  152|    100|		info.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|    100|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  153|       |
  154|    100|		if (info.attrs.pin.max_length == 0) {
  ------------------
  |  Branch (154:7): [True: 98, False: 2]
  ------------------
  155|     98|			if (p15card->card->max_pin_len != 0)
  ------------------
  |  Branch (155:8): [True: 0, False: 98]
  ------------------
  156|      0|				info.attrs.pin.max_length = p15card->card->max_pin_len;
  157|     98|			else if (info.attrs.pin.stored_length != 0)
  ------------------
  |  Branch (157:13): [True: 94, False: 4]
  ------------------
  158|     94|				info.attrs.pin.max_length = info.attrs.pin.type != SC_PKCS15_PIN_TYPE_BCD ?
  ------------------
  |  |   88|     94|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
  |  Branch (158:33): [True: 84, False: 10]
  ------------------
  159|     84|					info.attrs.pin.stored_length : 2 * info.attrs.pin.stored_length;
  160|      4|			else
  161|      4|				info.attrs.pin.max_length = 8; /* shouldn't happen */
  162|     98|		}
  163|       |
  164|       |		/* OpenSC 0.11.4 and older encoded "pinReference" as a negative
  165|       |		   value. Fixed in 0.11.5 we need to add a hack, so old cards
  166|       |		   continue to work.
  167|       |		   The same invalid encoding has some models of the proprietary PKCS#15 cards.
  168|       |		*/
  169|    100|		if (info.attrs.pin.reference < 0)
  ------------------
  |  Branch (169:7): [True: 24, False: 76]
  ------------------
  170|     24|			info.attrs.pin.reference += 256;
  171|       |
  172|    100|		if (info.attrs.pin.flags & SC_PKCS15_PIN_FLAG_LOCAL)   {
  ------------------
  |  |   55|    100|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (172:7): [True: 41, False: 59]
  ------------------
  173|       |			/* In OpenSC pkcs#15 framework 'path' is mandatory for the 'Local' PINs.
  174|       |			 * If 'path' do not present in PinAttributes, derive it from the PKCS#15 context. */
  175|     41|			if (!info.path.len)   {
  ------------------
  |  Branch (175:8): [True: 40, False: 1]
  ------------------
  176|       |				/* Give priority to AID defined in the application DDO */
  177|     40|				if (p15card->app && p15card->app->ddo.aid.len)
  ------------------
  |  Branch (177:9): [True: 1, False: 39]
  |  Branch (177:25): [True: 0, False: 1]
  ------------------
  178|      0|					info.path.aid = p15card->app->ddo.aid;
  179|     40|				else if (p15card->file_app && p15card->file_app->path.len)
  ------------------
  |  Branch (179:14): [True: 40, False: 0]
  |  Branch (179:35): [True: 40, False: 0]
  ------------------
  180|     40|					info.path = p15card->file_app->path;
  181|      0|				else
  182|      0|					return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  183|     40|			}
  184|     41|		}
  185|    100|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "decoded PIN(ref:%X,path:%s)", info.attrs.pin.reference, sc_print_path(&info.path));
  ------------------
  |  |   70|    100|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  186|    100|	}
  187|     15|	else if (asn1_auth_type_choice[1].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|     15|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (187:11): [True: 15, False: 0]
  ------------------
  188|     15|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "BIO authentication object not yet supported");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|     15|	}
  190|      0|	else if (asn1_auth_type_choice[2].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (190:11): [True: 0, False: 0]
  ------------------
  191|      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__
  |  |  ------------------
  ------------------
  192|      0|		obj->type = SC_PKCS15_TYPE_AUTH_AUTHKEY;
  ------------------
  |  |  447|      0|#define SC_PKCS15_TYPE_AUTH_AUTHKEY		0x603
  ------------------
  193|      0|		info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_AUTH_KEY;
  ------------------
  |  |   96|      0|#define SC_PKCS15_PIN_AUTH_TYPE_AUTH_KEY		2
  ------------------
  194|      0|		info.auth_method = SC_AC_AUT;
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  195|      0|		if (!(asn1_authkey_attr[0].flags & SC_ASN1_PRESENT))
  ------------------
  |  |  147|      0|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (195:7): [True: 0, False: 0]
  ------------------
  196|      0|			info.attrs.authkey.derived = 1;
  197|      0|	}
  198|      0|	else   {
  199|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  200|      0|	}
  201|       |
  202|    100|	obj->data = malloc(sizeof(info));
  203|    100|	if (obj->data == NULL)
  ------------------
  |  Branch (203:6): [True: 0, False: 100]
  ------------------
  204|    100|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  205|    100|	memcpy(obj->data, &info, sizeof(info));
  206|       |
  207|    100|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_ASN1, SC_SUCCESS);
  ------------------
  |  |  153|    100|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|    100|	int _ret = r; \
  |  |  155|    100|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 100, False: 0]
  |  |  ------------------
  |  |  156|    100|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  ------------------
  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 0, False: 100]
  |  |  ------------------
  |  |  157|    100|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|    100|	} else { \
  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  161|      0|	} \
  |  |  162|    100|	return _ret; \
  |  |  163|    100|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  208|    100|}
sc_pkcs15_encode_aodf_entry:
  213|    279|{
  214|    279|	struct sc_asn1_entry asn1_com_ao_attr[2], asn1_pin_attr[10], asn1_type_pin_attr[2];
  215|    279|	struct sc_asn1_entry asn1_auth_type[2];
  216|    279|	struct sc_asn1_entry asn1_auth_type_choice[4];
  217|    279|	struct sc_pkcs15_auth_info *info = (struct sc_pkcs15_auth_info *) obj->data;
  218|    279|	struct sc_asn1_pkcs15_object pin_obj = { (struct sc_pkcs15_object *) obj,
  219|    279|						 asn1_com_ao_attr, NULL, asn1_type_pin_attr };
  220|    279|	int r;
  221|    279|	size_t flags_len;
  222|    279|	size_t padchar_len = 1;
  223|       |
  224|    279|	if (info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    279|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (224:6): [True: 0, False: 279]
  ------------------
  225|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  226|       |
  227|    279|	sc_copy_asn1_entry(c_asn1_auth_type, asn1_auth_type);
  228|    279|	sc_copy_asn1_entry(c_asn1_auth_type_choice, asn1_auth_type_choice);
  229|    279|	sc_copy_asn1_entry(c_asn1_type_pin_attr, asn1_type_pin_attr);
  230|    279|	sc_copy_asn1_entry(c_asn1_pin_attr, asn1_pin_attr);
  231|    279|	sc_copy_asn1_entry(c_asn1_com_ao_attr, asn1_com_ao_attr);
  232|       |
  233|    279|	sc_format_asn1_entry(asn1_auth_type + 0, asn1_auth_type_choice, NULL, 1);
  234|    279|	sc_format_asn1_entry(asn1_auth_type_choice + 0, &pin_obj, NULL, 1);
  235|       |
  236|    279|	sc_format_asn1_entry(asn1_type_pin_attr + 0, asn1_pin_attr, NULL, 1);
  237|       |
  238|    279|	flags_len = sizeof(info->attrs.pin.flags);
  239|    279|	sc_format_asn1_entry(asn1_pin_attr + 0, &info->attrs.pin.flags, &flags_len, 1);
  240|    279|	sc_format_asn1_entry(asn1_pin_attr + 1, &info->attrs.pin.type, NULL, 1);
  241|    279|	sc_format_asn1_entry(asn1_pin_attr + 2, &info->attrs.pin.min_length, NULL, 1);
  242|    279|	sc_format_asn1_entry(asn1_pin_attr + 3, &info->attrs.pin.stored_length, NULL, 1);
  243|    279|	if (info->attrs.pin.max_length > 0)
  ------------------
  |  Branch (243:6): [True: 189, False: 90]
  ------------------
  244|    189|		sc_format_asn1_entry(asn1_pin_attr + 4, &info->attrs.pin.max_length, NULL, 1);
  245|    279|	if (info->attrs.pin.reference >= 0)
  ------------------
  |  Branch (245:6): [True: 257, False: 22]
  ------------------
  246|    257|		sc_format_asn1_entry(asn1_pin_attr + 5, &info->attrs.pin.reference, NULL, 1);
  247|       |	/* FIXME: check if pad_char present */
  248|    279|	sc_format_asn1_entry(asn1_pin_attr + 6, &info->attrs.pin.pad_char, &padchar_len, 1);
  249|    279|	sc_format_asn1_entry(asn1_pin_attr + 8, &info->path, NULL, info->path.len ? 1 : 0);
  ------------------
  |  Branch (249:61): [True: 154, False: 125]
  ------------------
  250|       |
  251|    279|	sc_format_asn1_entry(asn1_com_ao_attr + 0, &info->auth_id, NULL, 1);
  252|       |
  253|    279|	r = sc_asn1_encode(ctx, asn1_auth_type, buf, buflen);
  254|       |
  255|    279|	return r;
  256|    279|}
sc_pkcs15_verify_pin:
  299|     63|{
  300|     63|	struct sc_context *ctx = p15card->card->ctx;
  301|     63|	struct sc_pkcs15_auth_info *auth_info;
  302|     63|	int r;
  303|       |
  304|     63|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     63|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     63|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     63|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     63|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 63]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  305|       |
  306|     63|	if (!pin_obj || !pin_obj->data)
  ------------------
  |  Branch (306:6): [True: 0, False: 63]
  |  Branch (306:18): [True: 0, False: 63]
  ------------------
  307|     63|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  308|     63|	auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
  309|       |
  310|       |	/* Check the provided pin matches pin requirements */
  311|     63|	r = _validate_pin(p15card, auth_info, pinlen);
  312|       |
  313|     63|	if (r)
  ------------------
  |  Branch (313:6): [True: 49, False: 14]
  ------------------
  314|     63|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  315|       |
  316|     14|	r = _sc_pkcs15_verify_pin(p15card, pin_obj, pincode, pinlen);
  317|       |
  318|     14|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|     14|#define SC_SUCCESS				0
  ------------------
  |  Branch (318:6): [True: 7, False: 7]
  ------------------
  319|      7|		sc_pkcs15_pincache_add(p15card, pin_obj, pincode, pinlen);
  320|       |
  321|     14|	LOG_FUNC_RETURN(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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  322|     14|}
_sc_pkcs15_verify_pin:
  328|     14|{
  329|     14|	return sc_pkcs15_verify_pin_with_session_pin(p15card, pin_obj, pincode,
  330|     14|			pinlen, NULL, NULL);
  331|     14|}
sc_pkcs15_verify_pin_with_session_pin:
  344|     14|{
  345|     14|	struct sc_context *ctx = p15card->card->ctx;
  346|     14|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
  347|     14|	int r;
  348|     14|	sc_card_t *card;
  349|     14|	struct sc_pin_cmd_data data;
  350|       |
  351|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  352|     14|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  353|     14|	       "PIN(type:%X; method:%X; value(%p:%"SC_FORMAT_LEN_SIZE_T"u)",
  354|     14|	       auth_info->auth_type, auth_info->auth_method,
  355|     14|	       pincode, pinlen);
  356|     14|	card = p15card->card;
  357|       |
  358|     14|	if (pinlen > SC_MAX_PIN_SIZE) {
  ------------------
  |  |   40|     14|#define SC_MAX_PIN_SIZE			256 /* OpenPGP card has 254 max */
  ------------------
  |  Branch (358:6): [True: 0, False: 14]
  ------------------
  359|      0|		sc_notify_id(card->ctx, &card->reader->atr, p15card,
  360|      0|				NOTIFY_PIN_BAD);
  361|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  362|      0|	}
  363|       |
  364|       |	/* Initialize arguments */
  365|     14|	memset(&data, 0, sizeof(data));
  366|     14|	data.pin_type = auth_info->auth_method;
  367|       |
  368|     14|	if (auth_info->auth_type == SC_PKCS15_PIN_AUTH_TYPE_PIN)   {
  ------------------
  |  |   94|     14|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (368:6): [True: 14, False: 0]
  ------------------
  369|     14|		data.pin_reference = auth_info->attrs.pin.reference;
  370|     14|		data.pin1.min_length = auth_info->attrs.pin.min_length;
  371|     14|		data.pin1.max_length = auth_info->attrs.pin.max_length;
  372|     14|		data.pin1.pad_length = auth_info->attrs.pin.stored_length;
  373|     14|		data.pin1.pad_char = auth_info->attrs.pin.pad_char;
  374|     14|		data.pin1.data = pincode;
  375|     14|		data.pin1.len = pinlen;
  376|       |
  377|     14|		if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_NEEDS_PADDING)
  ------------------
  |  |   59|     14|#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING		0x0020
  ------------------
  |  Branch (377:7): [True: 14, False: 0]
  ------------------
  378|     14|			data.flags |= SC_PIN_CMD_NEED_PADDING;
  ------------------
  |  |  429|     14|#define SC_PIN_CMD_NEED_PADDING		0x0002
  ------------------
  379|       |
  380|     14|		switch (auth_info->attrs.pin.type) {
  381|      0|		case SC_PKCS15_PIN_TYPE_BCD:
  ------------------
  |  |   88|      0|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
  |  Branch (381:3): [True: 0, False: 14]
  ------------------
  382|      0|			data.pin1.encoding = SC_PIN_ENCODING_BCD;
  ------------------
  |  |  433|      0|#define SC_PIN_ENCODING_BCD	1
  ------------------
  383|      0|			break;
  384|      2|		case SC_PKCS15_PIN_TYPE_ASCII_NUMERIC:
  ------------------
  |  |   89|      2|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  |  Branch (384:3): [True: 2, False: 12]
  ------------------
  385|      2|			data.pin1.encoding = SC_PIN_ENCODING_ASCII;
  ------------------
  |  |  432|      2|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  386|      2|			break;
  387|     12|		default:
  ------------------
  |  Branch (387:3): [True: 12, False: 2]
  ------------------
  388|       |			/* assume/hope the card driver knows how to encode the pin */
  389|     12|			data.pin1.encoding = 0;
  390|     14|		}
  391|     14|	}
  392|      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 (392:11): [True: 0, False: 0]
  ------------------
  393|      0|		struct sc_pkcs15_object *skey_obj = NULL;
  394|      0|		struct sc_pkcs15_id *skey_id =  &auth_info->attrs.authkey.skey_id;
  395|      0|		struct sc_pkcs15_skey_info *skey_info = NULL;
  396|       |
  397|      0|		r = sc_pkcs15_find_skey_by_id(p15card, skey_id, &skey_obj);
  398|      0|		if (r)   {
  ------------------
  |  Branch (398:7): [True: 0, False: 0]
  ------------------
  399|      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__
  |  |  ------------------
  ------------------
  400|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  401|      0|		}
  402|      0|		skey_info = (struct sc_pkcs15_skey_info *)skey_obj->data;
  403|       |
  404|      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__
  |  |  ------------------
  ------------------
  405|      0|		data.pin_reference = skey_info->key_reference;
  406|      0|	}
  407|       |
  408|     14|	if ((p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD
  ------------------
  |  |  383|     28|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (408:7): [True: 0, False: 14]
  ------------------
  409|     14|				|| p15card->card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)) {
  ------------------
  |  |  567|     14|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (409:8): [True: 0, False: 14]
  ------------------
  410|      0|		if (!pincode && !pinlen)
  ------------------
  |  Branch (410:7): [True: 0, False: 0]
  |  Branch (410:19): [True: 0, False: 0]
  ------------------
  411|      0|			data.flags |= SC_PIN_CMD_USE_PINPAD;
  ------------------
  |  |  428|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  412|       |
  413|      0|		if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (413:7): [True: 0, False: 0]
  ------------------
  414|      0|			data.pin1.prompt = "Please enter SO PIN";
  415|      0|		else
  416|      0|			data.pin1.prompt = "Please enter PIN";
  417|      0|	}
  418|       |
  419|     14|	if (card->caps & SC_CARD_CAP_SESSION_PIN && sessionpin && sessionpinlen) {
  ------------------
  |  |  570|     28|#define SC_CARD_CAP_SESSION_PIN	0x00000200
  ------------------
  |  Branch (419:6): [True: 0, False: 14]
  |  Branch (419:46): [True: 0, False: 0]
  |  Branch (419:60): [True: 0, False: 0]
  ------------------
  420|       |		/* session pin is requested and supported with standard verification*/
  421|      0|		data.cmd = SC_PIN_CMD_GET_SESSION_PIN;
  ------------------
  |  |  426|      0|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  422|      0|		memcpy(&data.pin2, &data.pin1, sizeof (data.pin1));
  423|      0|		data.pin2.data = sessionpin;
  424|      0|		data.pin2.len = *sessionpinlen;
  425|     14|	} else {
  426|       |		/* perform a standard verify */
  427|     14|		data.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  422|     14|#define SC_PIN_CMD_VERIFY	0
  ------------------
  428|     14|		if (sessionpinlen)
  ------------------
  |  Branch (428:7): [True: 0, False: 14]
  ------------------
  429|      0|			*sessionpinlen = 0;
  430|     14|	}
  431|       |
  432|     14|	r = sc_lock(card);
  433|     14|	LOG_TEST_RET(ctx, r, "sc_lock() 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|       |
  435|       |	/* the path in the pin object is optional */
  436|     14|	if ((auth_info->path.len > 0) || ((auth_info->path.aid.len > 0))) {
  ------------------
  |  Branch (436:6): [True: 7, False: 7]
  |  Branch (436:35): [True: 4, False: 3]
  ------------------
  437|     11|		r = sc_select_file(card, &auth_info->path, NULL);
  438|     11|		if (r)
  ------------------
  |  Branch (438:7): [True: 4, False: 7]
  ------------------
  439|      4|			goto out;
  440|     11|	}
  441|       |
  442|     10|	r = sc_pin_cmd(card, &data);
  443|     10|	auth_info->tries_left = data.pin1.tries_left;
  444|     10|	sc_log(ctx, "PIN cmd result %i", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  445|     10|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
  |  Branch (445:6): [True: 7, False: 3]
  ------------------
  446|      7|		sc_pkcs15_pincache_add(p15card, pin_obj, pincode, pinlen);
  447|      7|		if (data.cmd == SC_PIN_CMD_GET_SESSION_PIN && sessionpinlen) {
  ------------------
  |  |  426|     14|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (447:7): [True: 0, False: 7]
  |  Branch (447:49): [True: 0, False: 0]
  ------------------
  448|      0|			*sessionpinlen = data.pin2.len;
  449|      0|		}
  450|      7|	} else {
  451|      3|		sc_notify_id(card->ctx, &card->reader->atr, p15card,
  452|      3|				NOTIFY_PIN_BAD);
  453|      3|		if (data.cmd == SC_PIN_CMD_GET_SESSION_PIN && sessionpinlen) {
  ------------------
  |  |  426|      6|#define SC_PIN_CMD_GET_SESSION_PIN	4
  ------------------
  |  Branch (453:7): [True: 0, False: 3]
  |  Branch (453:49): [True: 0, False: 0]
  ------------------
  454|      0|			*sessionpinlen = 0;
  455|      0|		}
  456|      3|	}
  457|       |
  458|     10|	if (auth_info->auth_type == SC_PKCS15_PIN_AUTH_TYPE_PIN
  ------------------
  |  |   94|     20|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (458:6): [True: 10, False: 0]
  ------------------
  459|     10|			&& auth_info->auth_method != SC_AC_SESSION) {
  ------------------
  |  |  159|     10|#define SC_AC_SESSION			0x00000100 /* Session PIN */
  ------------------
  |  Branch (459:7): [True: 10, False: 0]
  ------------------
  460|     10|		sc_notify_id(card->ctx, &card->reader->atr, p15card,
  461|     10|				r == SC_SUCCESS ? NOTIFY_PIN_GOOD : NOTIFY_PIN_BAD);
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
  |  Branch (461:5): [True: 7, False: 3]
  ------------------
  462|     10|	}
  463|       |
  464|     14|out:
  465|     14|	sc_unlock(card);
  466|     14|	LOG_FUNC_RETURN(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|      7|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 7, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|     14|}
sc_pkcs15_get_pin_info:
  691|    159|{
  692|    159|	int r;
  693|    159|	struct sc_pin_cmd_data data;
  694|    159|	struct sc_card *card = p15card->card;
  695|    159|	struct sc_context *ctx = card->ctx;
  696|    159|	struct sc_pkcs15_auth_info *pin_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
  697|       |
  698|    159|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    159|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    159|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    159|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    159|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 159]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  699|       |
  700|    159|	r = sc_lock(card);
  701|    159|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|    159|#define SC_SUCCESS				0
  ------------------
  |  Branch (701:6): [True: 0, False: 159]
  ------------------
  702|      0|		return r;
  703|       |
  704|    159|	if (pin_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)   {
  ------------------
  |  |   94|    159|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (704:6): [True: 0, False: 159]
  ------------------
  705|      0|		r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  706|      0|		goto out;
  707|      0|	}
  708|       |
  709|       |	/* the path in the pin object is optional */
  710|    159|	if ((pin_info->path.len > 0) || ((pin_info->path.aid.len > 0))) {
  ------------------
  |  Branch (710:6): [True: 71, False: 88]
  |  Branch (710:34): [True: 5, False: 83]
  ------------------
  711|     76|		r = sc_select_file(card, &pin_info->path, NULL);
  712|     76|		if (r)
  ------------------
  |  Branch (712:7): [True: 10, False: 66]
  ------------------
  713|     10|			goto out;
  714|     76|	}
  715|       |
  716|       |	/* Try to update PIN info from card */
  717|    149|	memset(&data, 0, sizeof(data));
  718|    149|	data.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  425|    149|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  719|    149|	data.pin_type = pin_info->auth_method;
  720|    149|	data.pin_reference = pin_info->attrs.pin.reference;
  721|       |
  722|    149|	r = sc_pin_cmd(card, &data);
  723|    149|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    149|#define SC_SUCCESS				0
  ------------------
  |  Branch (723:6): [True: 99, False: 50]
  ------------------
  724|     99|		if (data.pin1.max_tries > 0)
  ------------------
  |  Branch (724:7): [True: 0, False: 99]
  ------------------
  725|      0|			pin_info->max_tries = data.pin1.max_tries;
  726|     99|		pin_info->tries_left = data.pin1.tries_left;
  727|     99|		pin_info->logged_in = data.pin1.logged_in;
  728|     99|	}
  729|       |
  730|    159|out:
  731|    159|	sc_unlock(card);
  732|    159|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    159|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    159|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    159|	int _ret = r; \
  |  |  |  |  155|    159|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 159, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    159|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 99]
  |  |  |  |  ------------------
  |  |  |  |  157|    159|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    159|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    159|	return _ret; \
  |  |  |  |  163|    159|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  733|    159|}
sc_pkcs15_free_auth_info:
  737|  3.34k|{
  738|  3.34k|	free(auth_info);
  739|  3.34k|}
sc_pkcs15_pincache_add:
  745|     42|{
  746|     42|	struct sc_context *ctx = p15card->card->ctx;
  747|     42|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
  748|     42|	struct sc_pkcs15_object *obj = NULL;
  749|     42|	int r;
  750|       |
  751|     42|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     42|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     42|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     42|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     42|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 42]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  752|       |
  753|     42|	if (!pin || !pinlen)   {
  ------------------
  |  Branch (753:6): [True: 8, False: 34]
  |  Branch (753:14): [True: 0, False: 34]
  ------------------
  754|      8|		sc_log(ctx, "No cache for zero length PIN");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  755|      8|		return;
  756|      8|	}
  757|     34|	else if (!p15card->opts.use_pin_cache)   {
  ------------------
  |  Branch (757:11): [True: 0, False: 34]
  ------------------
  758|      0|		sc_log(ctx, "PIN caching not enabled");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  759|      0|		return;
  760|      0|	}
  761|     34|	else if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)   {
  ------------------
  |  |   94|     34|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (761:11): [True: 0, False: 34]
  ------------------
  762|      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__
  |  |  ------------------
  ------------------
  763|      0|		return;
  764|      0|	}
  765|       |
  766|       |	/* If the PIN protects an object with user consent, don't cache it */
  767|       |
  768|     34|	obj = p15card->obj_list;
  769|     56|	while (obj != NULL) {
  ------------------
  |  Branch (769:9): [True: 22, False: 34]
  ------------------
  770|       |		/* Compare 'sc_pkcs15_object.auth_id' with 'sc_pkcs15_pin_info.auth_id'.
  771|       |		 * In accordance with PKCS#15 "6.1.8 CommonObjectAttributes" and
  772|       |		 * "6.1.16 CommonAuthenticationObjectAttributes" with the exception that
  773|       |		 * "CommonObjectAttributes.accessControlRules" are not taken into account. */
  774|       |
  775|     22|		if (sc_pkcs15_compare_id(&obj->auth_id, &auth_info->auth_id)) {
  ------------------
  |  Branch (775:7): [True: 4, False: 18]
  ------------------
  776|       |			/* Caching is refused, if the protected object requires user consent */
  777|      4|			if (!p15card->opts.pin_cache_ignore_user_consent) {
  ------------------
  |  Branch (777:8): [True: 4, False: 0]
  ------------------
  778|      4|				if (obj->user_consent > 0) {
  ------------------
  |  Branch (778:9): [True: 0, False: 4]
  ------------------
  779|      0|					sc_log(ctx, "caching refused (user consent)");
  ------------------
  |  |   71|      0|#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|      0|					return;
  781|      0|				}
  782|      4|			}
  783|      4|		}
  784|       |
  785|     22|		obj = obj->next;
  786|     22|	}
  787|       |
  788|     34|	r = sc_pkcs15_allocate_object_content(ctx, pin_obj, pin, pinlen);
  789|     34|	if (r != SC_SUCCESS)   {
  ------------------
  |  |   28|     34|#define SC_SUCCESS				0
  ------------------
  |  Branch (789:6): [True: 0, False: 34]
  ------------------
  790|      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__
  |  |  ------------------
  ------------------
  791|      0|		return;
  792|      0|	}
  793|       |
  794|     34|	pin_obj->usage_counter = 0;
  795|     34|	sc_log(ctx, "PIN(%s) cached", pin_obj->label);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  796|     34|}
sc_pkcs15_pincache_clear:
  849|  2.45k|{
  850|  2.45k|	struct sc_pkcs15_object *objs[32];
  851|  2.45k|	int i, r;
  852|       |
  853|  2.45k|	LOG_FUNC_CALLED(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  854|  2.45k|	r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
  ------------------
  |  |  445|  2.45k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  855|  3.07k|	for (i = 0; i < r; i++)
  ------------------
  |  Branch (855:14): [True: 629, False: 2.45k]
  ------------------
  856|    629|		sc_pkcs15_free_object_content(objs[i]);
  857|  2.45k|}
pkcs15-pin.c:_validate_pin:
  261|     63|{
  262|     63|	size_t max_length;
  263|     63|	if (p15card == NULL) {
  ------------------
  |  Branch (263:6): [True: 0, False: 63]
  ------------------
  264|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  265|      0|	}
  266|       |
  267|       |	/* Ignore validation of the non-PIN authentication objects */
  268|     63|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     63|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (268:6): [True: 0, False: 63]
  ------------------
  269|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  270|       |
  271|       |	/* prevent buffer overflow from hostile card */
  272|     63|	if (auth_info->attrs.pin.stored_length > SC_MAX_PIN_SIZE)
  ------------------
  |  |   40|     63|#define SC_MAX_PIN_SIZE			256 /* OpenPGP card has 254 max */
  ------------------
  |  Branch (272:6): [True: 2, False: 61]
  ------------------
  273|      2|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      2|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  274|       |
  275|       |	/* if we use pinpad, no more checks are needed */
  276|     61|	if ((p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD
  ------------------
  |  |  383|    122|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (276:7): [True: 0, False: 61]
  ------------------
  277|     61|				|| p15card->card->caps & SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH)
  ------------------
  |  |  567|     61|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
  |  Branch (277:8): [True: 0, False: 61]
  ------------------
  278|      0|		   	&& !pinlen)
  ------------------
  |  Branch (278:10): [True: 0, False: 0]
  ------------------
  279|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  280|       |
  281|       |	/* If pin is given, make sure it is within limits */
  282|     61|	max_length = auth_info->attrs.pin.max_length != 0 ? auth_info->attrs.pin.max_length : SC_MAX_PIN_SIZE;
  ------------------
  |  |   40|     73|#define SC_MAX_PIN_SIZE			256 /* OpenPGP card has 254 max */
  ------------------
  |  Branch (282:15): [True: 49, False: 12]
  ------------------
  283|     61|	if (pinlen > max_length || pinlen < auth_info->attrs.pin.min_length)
  ------------------
  |  Branch (283:6): [True: 0, False: 61]
  |  Branch (283:29): [True: 47, False: 14]
  ------------------
  284|     47|		return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|     47|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
  285|       |
  286|     14|	return SC_SUCCESS;
  ------------------
  |  |   28|     14|#define SC_SUCCESS				0
  ------------------
  287|     61|}

sc_pkcs15emu_piv_init_ex:
 1278|  3.39k|{
 1279|  3.39k|	sc_card_t   *card = p15card->card;
 1280|  3.39k|	sc_context_t    *ctx = card->ctx;
 1281|       |
 1282|  3.39k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.39k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.39k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.39k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.39k]
  |  |  ------------------
  ------------------
 1283|       |
 1284|  3.39k|	if (piv_detect_card(p15card))
  ------------------
  |  Branch (1284:6): [True: 3.39k, False: 0]
  ------------------
 1285|  3.39k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
 1286|      0|	return sc_pkcs15emu_piv_init(p15card);
 1287|  3.39k|}
pkcs15-piv.c:piv_detect_card:
  237|  3.39k|{
  238|  3.39k|	sc_card_t *card = p15card->card;
  239|       |
  240|  3.39k|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.39k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.39k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.39k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.39k]
  |  |  ------------------
  ------------------
  241|  3.39k|	if (card->type < SC_CARD_TYPE_PIV_II_BASE
  ------------------
  |  Branch (241:6): [True: 1.69k, False: 1.70k]
  ------------------
  242|  1.70k|		|| card->type >= SC_CARD_TYPE_PIV_II_BASE + 1000)
  ------------------
  |  Branch (242:6): [True: 1.70k, False: 0]
  ------------------
  243|  3.39k|		return SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|  3.39k|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  244|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  245|  3.39k|}

sc_pkcs15_decode_prkdf_entry:
  157|    283|{
  158|    283|	sc_context_t *ctx = p15card->card->ctx;
  159|    283|	struct sc_pkcs15_prkey_info info;
  160|    283|	int r, i, gostr3410_params[3];
  161|    283|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  162|    283|	size_t usage_len = sizeof(info.usage);
  163|    283|	size_t af_len = sizeof(info.access_flags);
  164|    283|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  165|    283|	struct sc_asn1_entry asn1_com_prkey_attr[C_ASN1_COM_PRKEY_ATTR_SIZE];
  166|    283|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  167|    283|	struct sc_asn1_entry asn1_prk_rsa_attr[C_ASN1_PRK_RSA_ATTR_SIZE];
  168|    283|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOSTR3410KEY_ATTR_SIZE];
  169|    283|	struct sc_asn1_entry asn1_prk_gostr3410_attr[C_ASN1_PRK_GOSTR3410_ATTR_SIZE];
  170|    283|	struct sc_asn1_entry asn1_ecckey_attr[C_ASN1_ECCKEY_ATTR];
  171|    283|	struct sc_asn1_entry asn1_prk_ecc_attr[C_ASN1_PRK_ECC_ATTR];
  172|    283|	struct sc_asn1_entry asn1_prkey[C_ASN1_PRKEY_SIZE];
  173|    283|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  174|    283|	struct sc_asn1_pkcs15_object rsa_prkey_obj = {obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_rsa_attr};
  175|    283|	struct sc_asn1_pkcs15_object gostr3410_prkey_obj = {obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_gostr3410_attr};
  176|    283|	struct sc_asn1_pkcs15_object ecc_prkey_obj = { obj, asn1_com_key_attr, asn1_com_prkey_attr, asn1_prk_ecc_attr };
  177|    283|	u8 ec_domain[32];
  178|    283|	size_t ec_domain_len = sizeof(ec_domain);
  179|       |
  180|    283|	sc_copy_asn1_entry(c_asn1_prkey, asn1_prkey);
  181|    283|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  182|       |
  183|    283|	sc_copy_asn1_entry(c_asn1_prk_rsa_attr, asn1_prk_rsa_attr);
  184|    283|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  185|    283|	sc_copy_asn1_entry(c_asn1_prk_gostr3410_attr, asn1_prk_gostr3410_attr);
  186|    283|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  187|    283|	sc_copy_asn1_entry(c_asn1_prk_ecc_attr, asn1_prk_ecc_attr);
  188|    283|	sc_copy_asn1_entry(c_asn1_ecckey_attr, asn1_ecckey_attr);
  189|       |
  190|    283|	sc_copy_asn1_entry(c_asn1_com_prkey_attr, asn1_com_prkey_attr);
  191|    283|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  192|       |
  193|    283|	sc_format_asn1_entry(asn1_prkey + 0, &rsa_prkey_obj, NULL, 0);
  194|    283|	sc_format_asn1_entry(asn1_prkey + 1, &ecc_prkey_obj, NULL, 0);
  195|    283|	sc_format_asn1_entry(asn1_prkey + 2, &gostr3410_prkey_obj, NULL, 0);
  196|       |
  197|    283|	sc_format_asn1_entry(asn1_prk_rsa_attr + 0, asn1_rsakey_attr, NULL, 0);
  198|    283|	sc_format_asn1_entry(asn1_prk_gostr3410_attr + 0, asn1_gostr3410key_attr, NULL, 0);
  199|    283|	sc_format_asn1_entry(asn1_prk_ecc_attr + 0, asn1_ecckey_attr, NULL, 0);
  200|       |
  201|    283|	sc_format_asn1_entry(asn1_rsakey_attr + 0, &info.path, NULL, 0);
  202|    283|	sc_format_asn1_entry(asn1_rsakey_attr + 1, &info.modulus_length, NULL, 0);
  203|       |
  204|    283|	sc_format_asn1_entry(asn1_gostr3410key_attr + 0, &info.path, NULL, 0);
  205|    283|	sc_format_asn1_entry(asn1_gostr3410key_attr + 1, &gostr3410_params[0], NULL, 0);
  206|    283|	sc_format_asn1_entry(asn1_gostr3410key_attr + 2, &gostr3410_params[1], NULL, 0);
  207|    283|	sc_format_asn1_entry(asn1_gostr3410key_attr + 3, &gostr3410_params[2], NULL, 0);
  208|       |
  209|    283|	sc_format_asn1_entry(asn1_ecckey_attr + 0, &info.path, NULL, 0);
  210|    283|	sc_format_asn1_entry(asn1_ecckey_attr + 1, &info.field_length, NULL, 0);
  211|    283|	sc_format_asn1_entry(asn1_ecckey_attr + 3, ec_domain, &ec_domain_len, 0);
  212|       |
  213|    283|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info.id, NULL, 0);
  214|    283|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info.usage, &usage_len, 0);
  215|    283|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info.native, NULL, 0);
  216|    283|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info.access_flags, &af_len, 0);
  217|    283|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info.key_reference, NULL, 0);
  218|       |
  219|  4.81k|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && (asn1_supported_algorithms + i)->name; i++)
  ------------------
  |  |   61|  9.62k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (219:12): [True: 4.52k, False: 283]
  |  Branch (219:45): [True: 4.52k, False: 0]
  ------------------
  220|  4.52k|		sc_format_asn1_entry(asn1_supported_algorithms + i, &info.algo_refs[i], NULL, 0);
  221|    283|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, 0);
  222|       |
  223|    283|	sc_format_asn1_entry(asn1_com_prkey_attr + 0, &info.subject.value, &info.subject.len, 0);
  224|       |
  225|       |	/* Fill in defaults */
  226|    283|	memset(&info, 0, sizeof(info));
  227|    283|	info.key_reference = -1;
  228|    283|	info.native = 1;
  229|    283|	memset(gostr3410_params, 0, sizeof(gostr3410_params));
  230|       |
  231|    283|	r = sc_asn1_decode_choice(ctx, asn1_prkey, *buf, *buflen, buf, buflen);
  232|    283|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|    283|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (232:6): [True: 32, False: 251]
  ------------------
  233|     32|		goto err;
  234|    251|	LOG_TEST_GOTO_ERR(ctx, r, "PrKey DF ASN.1 decoding failed");
  ------------------
  |  |  184|    251|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    251|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    251|	int _ret = (r); \
  |  |  |  |  178|    251|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 147, False: 104]
  |  |  |  |  ------------------
  |  |  |  |  179|    147|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    147|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    147|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    147|		goto err; \
  |  |  |  |  182|    147|	} \
  |  |  |  |  183|    251|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 104]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  235|    104|	if (asn1_prkey[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|    104|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (235:6): [True: 83, False: 21]
  ------------------
  236|     83|		obj->type = SC_PKCS15_TYPE_PRKEY_RSA;
  ------------------
  |  |  419|     83|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  237|     83|	}
  238|     21|	else if (asn1_prkey[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     21|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (238:11): [True: 10, False: 11]
  ------------------
  239|     10|		obj->type = SC_PKCS15_TYPE_PRKEY_EC;
  ------------------
  |  |  421|     10|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  240|     10|#ifdef ENABLE_OPENSSL
  241|     10|		if (!(asn1_ecckey_attr[1].flags & SC_ASN1_PRESENT) && (asn1_ecckey_attr[3].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|     10|#define SC_ASN1_PRESENT			0x00000001
  ------------------
              		if (!(asn1_ecckey_attr[1].flags & SC_ASN1_PRESENT) && (asn1_ecckey_attr[3].flags & SC_ASN1_PRESENT)) {
  ------------------
  |  |  147|      9|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (241:7): [True: 9, False: 1]
  |  Branch (241:57): [True: 1, False: 8]
  ------------------
  242|      1|			const unsigned char *p = ec_domain;
  243|      1|			ASN1_OBJECT *object = d2i_ASN1_OBJECT(NULL, &p, ec_domain_len);
  244|      1|			int nid;
  245|      1|			EC_GROUP *group;
  246|      1|			if (!object) {
  ------------------
  |  Branch (246:8): [True: 1, False: 0]
  ------------------
  247|      1|				r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      1|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  248|      1|				goto err;
  249|      1|			}
  250|      0|			nid = OBJ_obj2nid(object);
  251|      0|			ASN1_OBJECT_free(object);
  252|      0|			if (nid == NID_undef) {
  ------------------
  |  Branch (252:8): [True: 0, False: 0]
  ------------------
  253|      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__
  |  |  ------------------
  ------------------
  254|      0|				r = SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  255|      0|				goto err;
  256|      0|			}
  257|      0|			group = EC_GROUP_new_by_curve_name(nid);
  258|      0|			if (!group) {
  ------------------
  |  Branch (258:8): [True: 0, False: 0]
  ------------------
  259|      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__
  |  |  ------------------
  ------------------
  260|      0|				r = SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  261|      0|				goto err;
  262|      0|			}
  263|      0|			info.field_length = EC_GROUP_order_bits(group);
  264|      0|			EC_GROUP_free(group);
  265|      0|			if (!info.field_length) {
  ------------------
  |  Branch (265:8): [True: 0, False: 0]
  ------------------
  266|      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__
  |  |  ------------------
  ------------------
  267|      0|				r = SC_ERROR_CORRUPTED_DATA;
  ------------------
  |  |   68|      0|#define SC_ERROR_CORRUPTED_DATA			-1218
  ------------------
  268|      0|				goto err;
  269|      0|			}
  270|      0|		}
  271|     10|#endif
  272|     10|	}
  273|     11|	else if (asn1_prkey[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     11|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (273:11): [True: 8, False: 3]
  ------------------
  274|       |		/* FIXME proper handling of gost parameters without the need of
  275|       |		 * allocating data here. this would also make sc_pkcs15_free_key_params
  276|       |		 * obsolete */
  277|      8|		obj->type = SC_PKCS15_TYPE_PRKEY_GOSTR3410;
  ------------------
  |  |  420|      8|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  278|      8|		if (info.modulus_length != 0 || info.params.len != 0) {
  ------------------
  |  Branch (278:7): [True: 0, False: 8]
  |  Branch (278:35): [True: 0, False: 8]
  ------------------
  279|      0|			r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      0|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  280|      0|			goto err;
  281|      0|		}
  282|      8|		info.modulus_length = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      8|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
  283|      8|		info.params.len = sizeof(struct sc_pkcs15_keyinfo_gostparams);
  284|      8|		info.params.data = malloc(info.params.len);
  285|      8|		if (info.params.data == NULL) {
  ------------------
  |  Branch (285:7): [True: 0, False: 8]
  ------------------
  286|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  287|      0|			goto err;
  288|      0|		}
  289|      8|		keyinfo_gostparams = info.params.data;
  290|      8|		keyinfo_gostparams->gostr3410 = gostr3410_params[0];
  291|      8|		keyinfo_gostparams->gostr3411 = gostr3410_params[1];
  292|      8|		keyinfo_gostparams->gost28147 = gostr3410_params[2];
  293|      8|	}
  294|      3|	else {
  295|      3|		r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|      3|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
  296|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  297|      3|	}
  298|       |
  299|    100|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (299:6): [True: 97, False: 3]
  |  Branch (299:23): [True: 3, False: 0]
  ------------------
  300|    100|		if (!p15card->file_app) {
  ------------------
  |  Branch (300:7): [True: 0, False: 100]
  ------------------
  301|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  302|      0|			goto err;
  303|      0|		}
  304|    100|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info.path);
  305|    100|		if (r < 0) {
  ------------------
  |  Branch (305:7): [True: 0, False: 100]
  ------------------
  306|      0|			goto err;
  307|      0|		}
  308|    100|	}
  309|      0|	else   {
  310|      0|		info.path.aid = p15card->app->ddo.aid;
  311|      0|	}
  312|    100|	sc_log(ctx, "PrivKey path '%s'", sc_print_path(&info.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  313|       |
  314|       |	/* OpenSC 0.11.4 and older encoded "keyReference" as a negative value.
  315|       |	 * Fixed in 0.11.5 we need to add a hack, so old cards continue to work. */
  316|    100|	if (info.key_reference < -1)
  ------------------
  |  Branch (316:6): [True: 6, False: 94]
  ------------------
  317|      6|		info.key_reference += 256;
  318|       |
  319|       |	/* Check the auth_id - if not present, try and find it in access rules */
  320|    100|	if ((obj->flags & SC_PKCS15_CO_FLAG_PRIVATE) && (obj->auth_id.len == 0)) {
  ------------------
  |  |   50|    100|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (320:6): [True: 67, False: 33]
  |  Branch (320:50): [True: 54, False: 13]
  ------------------
  321|     54|		sc_log(ctx, "Private key %s has no auth ID - checking AccessControlRules",
  ------------------
  |  |   71|     54|#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|     54|				sc_pkcs15_print_id(&info.id));
  323|       |
  324|       |		/* Search in the access_rules for an appropriate auth ID */
  325|    486|		for (i = 0; i < SC_PKCS15_MAX_ACCESS_RULES; i++) {
  ------------------
  |  |   42|    486|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (325:15): [True: 432, False: 54]
  ------------------
  326|       |			/* If access_mode is one of the private key usage modes */
  327|    432|			if (obj->access_rules[i].access_mode &
  ------------------
  |  Branch (327:8): [True: 0, False: 432]
  ------------------
  328|    432|					(SC_PKCS15_ACCESS_RULE_MODE_EXECUTE |
  ------------------
  |  |  337|    432|#define SC_PKCS15_ACCESS_RULE_MODE_EXECUTE      0x04
  ------------------
  329|    432|					 SC_PKCS15_ACCESS_RULE_MODE_PSO_CDS |
  ------------------
  |  |  340|    432|#define SC_PKCS15_ACCESS_RULE_MODE_PSO_CDS      0x20
  ------------------
  330|    432|					 SC_PKCS15_ACCESS_RULE_MODE_PSO_DECRYPT |
  ------------------
  |  |  342|    432|#define SC_PKCS15_ACCESS_RULE_MODE_PSO_DECRYPT  0x80
  ------------------
  331|    432|					 SC_PKCS15_ACCESS_RULE_MODE_INT_AUTH)) {
  ------------------
  |  |  344|    432|#define SC_PKCS15_ACCESS_RULE_MODE_INT_AUTH     0x200
  ------------------
  332|      0|				if (obj->access_rules[i].auth_id.len != 0) {
  ------------------
  |  Branch (332:9): [True: 0, False: 0]
  ------------------
  333|       |					/* Found an auth ID to use for private key access */
  334|      0|					obj->auth_id = obj->access_rules[i].auth_id;
  335|      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__
  |  |  ------------------
  ------------------
  336|      0|						 sc_pkcs15_print_id(&obj->auth_id));
  337|      0|					break;
  338|      0|				}
  339|      0|			}
  340|    432|		}
  341|       |
  342|       |		/* No auth ID found */
  343|     54|		if (i == SC_PKCS15_MAX_ACCESS_RULES)
  ------------------
  |  |   42|     54|#define SC_PKCS15_MAX_ACCESS_RULES      8
  ------------------
  |  Branch (343:7): [True: 54, False: 0]
  ------------------
  344|     54|			sc_log(ctx, "Warning: No auth ID found");
  ------------------
  |  |   71|     54|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  345|     54|	}
  346|       |
  347|    100|	obj->data = malloc(sizeof(info));
  348|    100|	if (obj->data == NULL) {
  ------------------
  |  Branch (348:6): [True: 0, False: 100]
  ------------------
  349|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  350|      0|		goto err;
  351|      0|	}
  352|    100|	memcpy(obj->data, &info, sizeof(info));
  353|       |
  354|    100|	sc_log(ctx, "Key Subject %s", sc_dump_hex(info.subject.value, info.subject.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__
  |  |  ------------------
  ------------------
  355|    100|	sc_log(ctx, "Key path %s", sc_print_path(&info.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  356|       |
  357|    100|	r = SC_SUCCESS;
  ------------------
  |  |   28|    100|#define SC_SUCCESS				0
  ------------------
  358|       |
  359|    283|err:
  360|    283|	if (r < 0) {
  ------------------
  |  Branch (360:6): [True: 183, False: 100]
  ------------------
  361|       |		/* This might have allocated something. If so, clear it now */
  362|    183|		free(info.subject.value);
  363|    183|		sc_pkcs15_free_key_params(&info.params);
  364|    183|	}
  365|       |
  366|    283|	return r;
  367|    100|}
sc_pkcs15_encode_prkdf_entry:
  371|     64|{
  372|     64|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  373|     64|	struct sc_asn1_entry asn1_com_prkey_attr[C_ASN1_COM_PRKEY_ATTR_SIZE];
  374|     64|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  375|     64|	struct sc_asn1_entry asn1_prk_rsa_attr[C_ASN1_PRK_RSA_ATTR_SIZE];
  376|     64|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOSTR3410KEY_ATTR_SIZE];
  377|     64|	struct sc_asn1_entry asn1_prk_gostr3410_attr[C_ASN1_PRK_GOSTR3410_ATTR_SIZE];
  378|     64|	struct sc_asn1_entry asn1_ecckey_attr[C_ASN1_ECCKEY_ATTR];
  379|     64|	struct sc_asn1_entry asn1_prk_ecc_attr[C_ASN1_PRK_ECC_ATTR];
  380|     64|	struct sc_asn1_entry asn1_prkey[C_ASN1_PRKEY_SIZE];
  381|     64|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  382|     64|	struct sc_asn1_pkcs15_object rsa_prkey_obj = {
  383|     64|		(struct sc_pkcs15_object *) obj, asn1_com_key_attr,
  384|     64|		asn1_com_prkey_attr, asn1_prk_rsa_attr
  385|     64|	};
  386|     64|	struct sc_asn1_pkcs15_object gostr3410_prkey_obj = {
  387|     64|		(struct sc_pkcs15_object *) obj,
  388|     64|		asn1_com_key_attr, asn1_com_prkey_attr,
  389|     64|		asn1_prk_gostr3410_attr
  390|     64|	};
  391|     64|	struct sc_asn1_pkcs15_object ecc_prkey_obj = {
  392|     64|		(struct sc_pkcs15_object *) obj,
  393|     64|		asn1_com_key_attr, asn1_com_prkey_attr,
  394|     64|		asn1_prk_ecc_attr
  395|     64|	};
  396|     64|	struct sc_pkcs15_prkey_info *prkey = (struct sc_pkcs15_prkey_info *) obj->data;
  397|     64|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  398|     64|	int r, i;
  399|     64|	size_t af_len, usage_len;
  400|       |
  401|     64|	sc_copy_asn1_entry(c_asn1_prkey, asn1_prkey);
  402|     64|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  403|       |
  404|     64|	sc_copy_asn1_entry(c_asn1_prk_rsa_attr, asn1_prk_rsa_attr);
  405|     64|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  406|     64|	sc_copy_asn1_entry(c_asn1_prk_gostr3410_attr, asn1_prk_gostr3410_attr);
  407|     64|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  408|     64|	sc_copy_asn1_entry(c_asn1_prk_ecc_attr, asn1_prk_ecc_attr);
  409|     64|	sc_copy_asn1_entry(c_asn1_ecckey_attr, asn1_ecckey_attr);
  410|       |
  411|     64|	sc_copy_asn1_entry(c_asn1_com_prkey_attr, asn1_com_prkey_attr);
  412|     64|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  413|       |
  414|     64|	switch (obj->type) {
  415|     45|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|     45|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (415:2): [True: 45, False: 19]
  ------------------
  416|     45|		sc_format_asn1_entry(asn1_prkey + 0, &rsa_prkey_obj, NULL, 1);
  417|     45|		sc_format_asn1_entry(asn1_prk_rsa_attr + 0, asn1_rsakey_attr, NULL, 1);
  418|     45|		sc_format_asn1_entry(asn1_rsakey_attr + 0, &prkey->path, NULL, 1);
  419|     45|		sc_format_asn1_entry(asn1_rsakey_attr + 1, &prkey->modulus_length, NULL, 1);
  420|     45|		break;
  421|     19|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     19|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (421:2): [True: 19, False: 45]
  ------------------
  422|     19|		sc_format_asn1_entry(asn1_prkey + 1, &ecc_prkey_obj, NULL, 1);
  423|     19|		sc_format_asn1_entry(asn1_prk_ecc_attr + 0, asn1_ecckey_attr, NULL, 1);
  424|     19|		sc_format_asn1_entry(asn1_ecckey_attr + 0, &prkey->path, NULL, 1);
  425|     19|		sc_format_asn1_entry(asn1_ecckey_attr + 1, &prkey->field_length, NULL, 1);
  426|     19|		break;
  427|      0|	case SC_PKCS15_TYPE_PRKEY_GOSTR3410:
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
  |  Branch (427:2): [True: 0, False: 64]
  ------------------
  428|      0|		sc_format_asn1_entry(asn1_prkey + 2, &gostr3410_prkey_obj, NULL, 1);
  429|      0|		sc_format_asn1_entry(asn1_prk_gostr3410_attr + 0, asn1_gostr3410key_attr, NULL, 1);
  430|      0|		sc_format_asn1_entry(asn1_gostr3410key_attr + 0, &prkey->path, NULL, 1);
  431|      0|		if (prkey->params.len == sizeof(*keyinfo_gostparams))   {
  ------------------
  |  Branch (431:7): [True: 0, False: 0]
  ------------------
  432|      0|			keyinfo_gostparams = prkey->params.data;
  433|      0|			sc_format_asn1_entry(asn1_gostr3410key_attr + 1, &keyinfo_gostparams->gostr3410, NULL, 1);
  434|      0|			sc_format_asn1_entry(asn1_gostr3410key_attr + 2, &keyinfo_gostparams->gostr3411, NULL, 1);
  435|      0|			sc_format_asn1_entry(asn1_gostr3410key_attr + 3, &keyinfo_gostparams->gost28147, NULL, 1);
  436|      0|		}
  437|      0|		break;
  438|      0|	default:
  ------------------
  |  Branch (438:2): [True: 0, False: 64]
  ------------------
  439|      0|		sc_log(ctx, "Invalid private key type: %X", 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__
  |  |  ------------------
  ------------------
  440|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|      0|		break;
  442|     64|	}
  443|     64|	sc_format_asn1_entry(asn1_com_key_attr + 0, &prkey->id, NULL, 1);
  444|     64|	usage_len = sizeof(prkey->usage);
  445|     64|	sc_format_asn1_entry(asn1_com_key_attr + 1, &prkey->usage, &usage_len, 1);
  446|     64|	if (prkey->native == 0)
  ------------------
  |  Branch (446:6): [True: 0, False: 64]
  ------------------
  447|      0|		sc_format_asn1_entry(asn1_com_key_attr + 2, &prkey->native, NULL, 1);
  448|     64|	if (prkey->access_flags) {
  ------------------
  |  Branch (448:6): [True: 64, False: 0]
  ------------------
  449|     64|		af_len = sizeof(prkey->access_flags);
  450|     64|		sc_format_asn1_entry(asn1_com_key_attr + 3, &prkey->access_flags, &af_len, 1);
  451|     64|	}
  452|     64|	if (prkey->key_reference >= 0)
  ------------------
  |  Branch (452:6): [True: 64, False: 0]
  ------------------
  453|     64|		sc_format_asn1_entry(asn1_com_key_attr + 4, &prkey->key_reference, NULL, 1);
  454|       |
  455|     64|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && prkey->algo_refs[i]; i++)   {
  ------------------
  |  |   61|    128|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (455:12): [True: 64, False: 0]
  |  Branch (455:45): [True: 0, False: 64]
  ------------------
  456|      0|		sc_log(ctx, "Encode algorithm(%i) %i", i, prkey->algo_refs[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__
  |  |  ------------------
  ------------------
  457|      0|		sc_format_asn1_entry(asn1_supported_algorithms + i, &prkey->algo_refs[i], NULL, 1);
  458|      0|	}
  459|     64|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, prkey->algo_refs[0] != 0);
  460|       |
  461|     64|	if (prkey->subject.value && prkey->subject.len)
  ------------------
  |  Branch (461:6): [True: 0, False: 64]
  |  Branch (461:30): [True: 0, False: 0]
  ------------------
  462|      0|		sc_format_asn1_entry(asn1_com_prkey_attr + 0, prkey->subject.value, &prkey->subject.len, 1);
  463|     64|	else
  464|     64|		memset(asn1_com_prkey_attr, 0, sizeof(asn1_com_prkey_attr));
  465|       |
  466|     64|	r = sc_asn1_encode(ctx, asn1_prkey, buf, buflen);
  467|       |
  468|     64|	sc_log(ctx, "Key path %s", sc_print_path(&prkey->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  469|     64|	return r;
  470|     64|}
sc_pkcs15_erase_prkey:
  555|  4.43k|{
  556|  4.43k|	if (!key)
  ------------------
  |  Branch (556:6): [True: 0, False: 4.43k]
  ------------------
  557|      0|		return;
  558|  4.43k|	switch (key->algorithm) {
  ------------------
  |  Branch (558:10): [True: 4.43k, False: 0]
  ------------------
  559|  2.21k|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   78|  2.21k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (559:2): [True: 2.21k, False: 2.21k]
  ------------------
  560|  2.21k|		free(key->u.rsa.modulus.data);
  561|  2.21k|		free(key->u.rsa.exponent.data);
  562|  2.21k|		free(key->u.rsa.d.data);
  563|  2.21k|		free(key->u.rsa.p.data);
  564|  2.21k|		free(key->u.rsa.q.data);
  565|  2.21k|		free(key->u.rsa.iqmp.data);
  566|  2.21k|		free(key->u.rsa.dmp1.data);
  567|  2.21k|		free(key->u.rsa.dmq1.data);
  568|  2.21k|		break;
  569|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   80|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (569:2): [True: 0, False: 4.43k]
  ------------------
  570|      0|		free(key->u.gostr3410.d.data);
  571|      0|		break;
  572|  2.21k|	case SC_ALGORITHM_EC:
  ------------------
  |  |   79|  2.21k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (572:2): [True: 2.21k, False: 2.21k]
  ------------------
  573|  2.21k|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   81|  2.21k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (573:2): [True: 0, False: 4.43k]
  ------------------
  574|  2.21k|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   82|  2.21k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (574:2): [True: 0, False: 4.43k]
  ------------------
  575|       |		/* EC, Edwards and Montgomery use common ec params */
  576|  2.21k|		sc_clear_ec_params(&key->u.ec.params);
  577|  2.21k|		free(key->u.ec.privateD.data);
  578|  2.21k|		free(key->u.ec.ecpointQ.value);
  579|  2.21k|		break;
  580|  4.43k|	}
  581|  4.43k|	sc_mem_clear(key, sizeof(*key));
  582|  4.43k|}
sc_pkcs15_free_prkey_info:
  594|  2.61k|{
  595|  2.61k|	if (!key)
  ------------------
  |  Branch (595:6): [True: 0, False: 2.61k]
  ------------------
  596|      0|		return;
  597|       |
  598|  2.61k|	if (key->subject.value)
  ------------------
  |  Branch (598:6): [True: 0, False: 2.61k]
  ------------------
  599|      0|		free(key->subject.value);
  600|       |
  601|  2.61k|	sc_pkcs15_free_key_params(&key->params);
  602|       |
  603|  2.61k|	sc_aux_data_free(&key->aux_data);
  604|       |
  605|  2.61k|	free(key);
  606|  2.61k|}

sc_pkcs15emu_pteid_init_ex:
  349|  3.39k|{
  350|  3.39k|	int r=SC_SUCCESS;
  ------------------
  |  |   28|  3.39k|#define SC_SUCCESS				0
  ------------------
  351|  3.39k|	sc_context_t *ctx = p15card->card->ctx;
  352|  3.39k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.39k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.39k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.39k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.39k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.39k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|       |	/* check for proper card */
  355|  3.39k|	r = pteid_detect_card(p15card->card);
  356|  3.39k|	if (r == SC_ERROR_WRONG_CARD)
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  |  Branch (356:6): [True: 3.39k, False: 0]
  ------------------
  357|  3.39k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_CARD);
  ------------------
  |  |  164|  3.39k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.39k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.39k|	int _ret = r; \
  |  |  |  |  155|  3.39k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.39k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.39k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.39k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.39k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.39k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.39k|	} else { \
  |  |  |  |  159|      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.39k|	return _ret; \
  |  |  |  |  163|  3.39k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  358|       |	/* ok: initialize and return */
  359|      0|	LOG_FUNC_RETURN(ctx, sc_pkcs15emu_pteid_init(p15card));
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  360|      0|}
pkcs15-pteid.c:pteid_detect_card:
  342|  3.39k|{
  343|  3.39k|	if (card->type == SC_CARD_TYPE_GEMSAFEV1_PTEID)
  ------------------
  |  Branch (343:6): [True: 0, False: 3.39k]
  ------------------
  344|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  345|  3.39k|	return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  346|  3.39k|}

sc_pkcs15_decode_pubkey_direct_value:
  155|     48|{
  156|     48|	struct sc_context *ctx = p15card->card->ctx;
  157|     48|	struct sc_pkcs15_pubkey_info *info = (struct sc_pkcs15_pubkey_info *) obj->data;
  158|       |
  159|     48|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|     48|	if (obj->content.value == NULL || obj->content.len == 0)
  ------------------
  |  Branch (160:6): [True: 42, False: 6]
  |  Branch (160:36): [True: 0, False: 6]
  ------------------
  161|     48|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|     42|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     42|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     42|	int _ret = r; \
  |  |  |  |  155|     42|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 42, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     42|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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]
  |  |  |  |  ------------------
  |  |  |  |  157|     42|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     42|	} else { \
  |  |  |  |  159|      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|	return _ret; \
  |  |  |  |  163|     42|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  162|       |
  163|      6|	if (*obj->content.value == (SC_ASN1_TAG_CONSTRUCTED | SC_ASN1_TAG_SEQUENCE))   {
  ------------------
  |  |  190|      6|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
              	if (*obj->content.value == (SC_ASN1_TAG_CONSTRUCTED | SC_ASN1_TAG_SEQUENCE))   {
  ------------------
  |  |  206|      6|#define SC_ASN1_TAG_SEQUENCE		16
  ------------------
  |  Branch (163:6): [True: 0, False: 6]
  ------------------
  164|       |		/* RAW direct value */
  165|      0|		sc_log(ctx, "Decoding 'RAW' direct 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__
  |  |  ------------------
  ------------------
  166|      0|		info->direct.raw.value = malloc(obj->content.len);
  167|      0|		if (!info->direct.raw.value)
  ------------------
  |  Branch (167:7): [True: 0, False: 0]
  ------------------
  168|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  169|      0|		memcpy(info->direct.raw.value, obj->content.value, obj->content.len);
  170|      0|		info->direct.raw.len = obj->content.len;
  171|       |
  172|       |		/* TODO: encode 'spki' direct value */
  173|      0|	}
  174|       |
  175|      6|	if (*obj->content.value == (SC_ASN1_TAG_CONTEXT | SC_ASN1_TAG_CONSTRUCTED | 0x01))   {
  ------------------
  |  |  187|      6|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
              	if (*obj->content.value == (SC_ASN1_TAG_CONTEXT | SC_ASN1_TAG_CONSTRUCTED | 0x01))   {
  ------------------
  |  |  190|      6|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  |  Branch (175:6): [True: 1, False: 5]
  ------------------
  176|      1|		struct sc_pkcs15_pubkey *pubkey = NULL;
  177|      1|		int rv;
  178|       |
  179|       |		/* SPKI direct value */
  180|      1|		sc_log(ctx, "Decoding 'SPKI' direct value");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  181|      1|		info->direct.spki.value = malloc(obj->content.len);
  182|      1|		if (!info->direct.spki.value)
  ------------------
  |  Branch (182:7): [True: 0, False: 1]
  ------------------
  183|      1|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  184|      1|		memcpy(info->direct.spki.value, obj->content.value, obj->content.len);
  185|      1|		info->direct.spki.len = obj->content.len;
  186|       |
  187|      1|		rv = sc_pkcs15_pubkey_from_spki_sequence(ctx, info->direct.spki.value, info->direct.spki.len, &pubkey);
  188|      1|		LOG_TEST_RET(ctx, rv, "Failed to decode 'SPKI' direct 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  189|       |
  190|      0|		rv = sc_pkcs15_encode_pubkey(ctx, pubkey, &info->direct.raw.value, &info->direct.raw.len);
  191|      0|		sc_pkcs15_free_pubkey(pubkey);
  192|      0|		LOG_TEST_RET(ctx, rv, "Failed to encode 'RAW' direct 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  193|      0|	}
  194|       |
  195|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|      5|}
sc_pkcs15_decode_pukdf_entry:
  202|    181|{
  203|    181|	struct sc_context *ctx = p15card->card->ctx;
  204|    181|	struct sc_pkcs15_pubkey_info *info;
  205|    181|	int r, gostr3410_params[3];
  206|    181|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  207|    181|	size_t usage_len, af_len;
  208|    181|	struct sc_pkcs15_der *der = &obj->content;
  209|    181|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  210|    181|	struct sc_asn1_entry asn1_com_pubkey_attr[C_ASN1_COM_PUBKEY_ATTR_SIZE];
  211|    181|	struct sc_asn1_entry asn1_rsakey_value_choice[C_ASN1_RSAKEY_VALUE_CHOICE_SIZE];
  212|    181|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  213|    181|	struct sc_asn1_entry asn1_rsa_type_attr[C_ASN1_RSA_TYPE_ATTR_SIZE];
  214|    181|	struct sc_asn1_entry asn1_eckey_value_choice[C_ASN1_ECKEY_VALUE_CHOICE_SIZE];
  215|    181|	struct sc_asn1_entry asn1_eckey_attr[C_ASN1_ECKEY_ATTR_SIZE];
  216|    181|	struct sc_asn1_entry asn1_ec_type_attr[C_ASN1_EC_TYPE_ATTR_SIZE];
  217|    181|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOST3410KEY_ATTR_SIZE];
  218|    181|	struct sc_asn1_entry asn1_gostr3410_type_attr[C_ASN1_GOST3410_TYPE_ATTR_SIZE];
  219|    181|	struct sc_asn1_entry asn1_pubkey_choice[C_ASN1_PUBKEY_CHOICE_SIZE];
  220|    181|	struct sc_asn1_entry asn1_pubkey[C_ASN1_PUBKEY_SIZE];
  221|    181|	struct sc_asn1_pkcs15_object rsakey_obj = { obj, asn1_com_key_attr,
  222|    181|			asn1_com_pubkey_attr, asn1_rsa_type_attr };
  223|    181|	struct sc_asn1_pkcs15_object eckey_obj = { obj, asn1_com_key_attr,
  224|    181|			asn1_com_pubkey_attr, asn1_ec_type_attr };
  225|    181|	struct sc_asn1_pkcs15_object gostr3410key_obj =  { obj, asn1_com_key_attr,
  226|    181|			asn1_com_pubkey_attr, asn1_gostr3410_type_attr };
  227|       |
  228|    181|	info = calloc(1, sizeof *info);
  229|    181|	if (info == NULL) {
  ------------------
  |  Branch (229:6): [True: 0, False: 181]
  ------------------
  230|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  231|      0|		goto err;
  232|      0|	}
  233|    181|	usage_len = sizeof(info->usage);
  234|    181|	af_len = sizeof(info->access_flags);
  235|       |
  236|    181|	sc_copy_asn1_entry(c_asn1_pubkey, asn1_pubkey);
  237|    181|	sc_copy_asn1_entry(c_asn1_pubkey_choice, asn1_pubkey_choice);
  238|    181|	sc_copy_asn1_entry(c_asn1_rsa_type_attr, asn1_rsa_type_attr);
  239|    181|	sc_copy_asn1_entry(c_asn1_rsakey_value_choice, asn1_rsakey_value_choice);
  240|    181|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  241|    181|	sc_copy_asn1_entry(c_asn1_ec_type_attr, asn1_ec_type_attr);
  242|    181|	sc_copy_asn1_entry(c_asn1_eckey_value_choice, asn1_eckey_value_choice);
  243|    181|	sc_copy_asn1_entry(c_asn1_eckey_attr, asn1_eckey_attr);
  244|    181|	sc_copy_asn1_entry(c_asn1_gostr3410_type_attr, asn1_gostr3410_type_attr);
  245|    181|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  246|    181|	sc_copy_asn1_entry(c_asn1_com_pubkey_attr, asn1_com_pubkey_attr);
  247|    181|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  248|       |
  249|    181|	sc_format_asn1_entry(asn1_com_pubkey_attr + 0, &info->subject.value, &info->subject.len, 0);
  250|       |
  251|    181|	sc_format_asn1_entry(asn1_pubkey_choice + 0, &rsakey_obj, NULL, 0);
  252|    181|	sc_format_asn1_entry(asn1_pubkey_choice + 1, &gostr3410key_obj, NULL, 0);
  253|    181|	sc_format_asn1_entry(asn1_pubkey_choice + 2, &eckey_obj, NULL, 0);
  254|       |
  255|    181|	sc_format_asn1_entry(asn1_rsa_type_attr + 0, asn1_rsakey_attr, NULL, 0);
  256|       |
  257|    181|	sc_format_asn1_entry(asn1_rsakey_value_choice + 0, &info->path, NULL, 0);
  258|    181|	sc_format_asn1_entry(asn1_rsakey_value_choice + 1, &der->value, &der->len, 0);
  259|       |
  260|    181|	sc_format_asn1_entry(asn1_rsakey_attr + 0, asn1_rsakey_value_choice, NULL, 0);
  261|    181|	sc_format_asn1_entry(asn1_rsakey_attr + 1, &info->modulus_length, NULL, 0);
  262|       |
  263|    181|	sc_format_asn1_entry(asn1_ec_type_attr + 0, asn1_eckey_attr, NULL, 0);
  264|       |
  265|    181|	sc_format_asn1_entry(asn1_eckey_value_choice + 0, &info->path, NULL, 0);
  266|    181|	sc_format_asn1_entry(asn1_eckey_value_choice + 1, &der->value, &der->len, 0);
  267|       |
  268|    181|	sc_format_asn1_entry(asn1_eckey_attr + 0, asn1_eckey_value_choice, NULL, 0);
  269|       |
  270|    181|	sc_format_asn1_entry(asn1_gostr3410_type_attr + 0, asn1_gostr3410key_attr, NULL, 0);
  271|       |
  272|    181|	sc_format_asn1_entry(asn1_gostr3410key_attr + 0, &info->path, NULL, 0);
  273|    181|	sc_format_asn1_entry(asn1_gostr3410key_attr + 1, &gostr3410_params[0], NULL, 0);
  274|    181|	sc_format_asn1_entry(asn1_gostr3410key_attr + 2, &gostr3410_params[1], NULL, 0);
  275|    181|	sc_format_asn1_entry(asn1_gostr3410key_attr + 3, &gostr3410_params[2], NULL, 0);
  276|       |
  277|    181|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info->id, NULL, 0);
  278|    181|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info->usage, &usage_len, 0);
  279|    181|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info->native, NULL, 0);
  280|    181|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info->access_flags, &af_len, 0);
  281|    181|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info->key_reference, NULL, 0);
  282|       |
  283|    181|	sc_format_asn1_entry(asn1_pubkey + 0, asn1_pubkey_choice, NULL, 0);
  284|       |
  285|       |	/* Fill in defaults */
  286|    181|	info->key_reference = -1;
  287|    181|	info->native = 1;
  288|    181|	memset(gostr3410_params, 0, sizeof(gostr3410_params));
  289|       |
  290|    181|	r = sc_asn1_decode(ctx, asn1_pubkey, *buf, *buflen, buf, buflen);
  291|    181|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|    181|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (291:6): [True: 16, False: 165]
  ------------------
  292|     16|		goto err;
  293|    165|	LOG_TEST_GOTO_ERR(ctx, r, "ASN.1 decoding failed");
  ------------------
  |  |  184|    165|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    165|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    165|	int _ret = (r); \
  |  |  |  |  178|    165|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 117, False: 48]
  |  |  |  |  ------------------
  |  |  |  |  179|    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
  |  |  |  |  ------------------
  |  |  |  |  180|    117|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    117|		goto err; \
  |  |  |  |  182|    117|	} \
  |  |  |  |  183|    165|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 48]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|     48|	if (asn1_pubkey_choice[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     48|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (294:6): [True: 31, False: 17]
  ------------------
  295|     31|		obj->type = SC_PKCS15_TYPE_PUBKEY_RSA;
  ------------------
  |  |  426|     31|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  296|     31|	} else if (asn1_pubkey_choice[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     17|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (296:13): [True: 12, False: 5]
  ------------------
  297|     12|		obj->type = SC_PKCS15_TYPE_PUBKEY_GOSTR3410;
  ------------------
  |  |  427|     12|#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410		0x203
  ------------------
  298|     12|		if (info->modulus_length != 0)
  ------------------
  |  Branch (298:7): [True: 0, False: 12]
  ------------------
  299|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  300|     12|		info->modulus_length = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|     12|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
  301|     12|		if (info->params.len != 0)
  ------------------
  |  Branch (301:7): [True: 0, False: 12]
  ------------------
  302|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  303|     12|		info->params.len = sizeof(struct sc_pkcs15_keyinfo_gostparams);
  304|     12|		info->params.data = malloc(info->params.len);
  305|     12|		if (info->params.data == NULL) {
  ------------------
  |  Branch (305:7): [True: 0, False: 12]
  ------------------
  306|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  307|      0|			goto err;
  308|      0|		}
  309|     12|		if (sizeof(*keyinfo_gostparams) != info->params.len)
  ------------------
  |  Branch (309:7): [True: 0, False: 12]
  ------------------
  310|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  311|     12|		keyinfo_gostparams = info->params.data;
  312|     12|		keyinfo_gostparams->gostr3410 = (unsigned int)gostr3410_params[0];
  313|     12|		keyinfo_gostparams->gostr3411 = (unsigned int)gostr3410_params[1];
  314|     12|		keyinfo_gostparams->gost28147 = (unsigned int)gostr3410_params[2];
  315|     12|	}
  316|      5|	else if (asn1_pubkey_choice[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      5|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (316:11): [True: 5, False: 0]
  ------------------
  317|      5|		obj->type = SC_PKCS15_TYPE_PUBKEY_EC;
  ------------------
  |  |  428|      5|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  318|      5|	}
  319|      0|	else {
  320|      0|		goto err;
  321|      0|	}
  322|       |
  323|     48|	if (!p15card->app || !p15card->app->ddo.aid.len) {
  ------------------
  |  Branch (323:6): [True: 44, False: 4]
  |  Branch (323:23): [True: 4, False: 0]
  ------------------
  324|     48|		if (!p15card->file_app) {
  ------------------
  |  Branch (324:7): [True: 0, False: 48]
  ------------------
  325|      0|			r = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  326|      0|			goto err;
  327|      0|		}
  328|     48|		r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &info->path);
  329|     48|		if (r < 0) {
  ------------------
  |  Branch (329:7): [True: 0, False: 48]
  ------------------
  330|      0|			goto err;
  331|      0|		}
  332|     48|	}
  333|      0|	else   {
  334|      0|		info->path.aid = p15card->app->ddo.aid;
  335|      0|	}
  336|     48|	sc_log(ctx, "PubKey path '%s'", sc_print_path(&info->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  337|       |
  338|       |	/* OpenSC 0.11.4 and older encoded "keyReference" as a negative
  339|       |	   value. Fixed in 0.11.5 we need to add a hack, so old cards
  340|       |	   continue to work. */
  341|     48|	if (info->key_reference < -1)
  ------------------
  |  Branch (341:6): [True: 5, False: 43]
  ------------------
  342|      5|		info->key_reference += 256;
  343|       |
  344|     48|	obj->data = info;
  345|     48|	info = NULL;
  346|       |
  347|     48|	r = sc_pkcs15_decode_pubkey_direct_value(p15card, obj);
  348|     48|	if (r < 0) {
  ------------------
  |  Branch (348:6): [True: 1, False: 47]
  ------------------
  349|      1|		info = obj->data;
  350|      1|		obj->data = NULL;
  351|      1|	}
  352|     48|	LOG_TEST_GOTO_ERR(ctx, r, "Decode public key direct value failed");
  ------------------
  |  |  184|     48|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     48|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     48|	int _ret = (r); \
  |  |  |  |  178|     48|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 47]
  |  |  |  |  ------------------
  |  |  |  |  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|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  353|       |
  354|    181|err:
  355|    181|	if (r < 0) {
  ------------------
  |  Branch (355:6): [True: 134, False: 47]
  ------------------
  356|    134|		sc_pkcs15_free_pubkey_info(info);
  357|    134|		if (der->len) {
  ------------------
  |  Branch (357:7): [True: 3, False: 131]
  ------------------
  358|      3|			free(der->value);
  359|       |			/* der points to obj->content */
  360|      3|			obj->content.value = NULL;
  361|      3|			obj->content.len = 0;
  362|      3|		}
  363|    134|	}
  364|       |
  365|    181|	LOG_FUNC_RETURN(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|    134|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 134, False: 47]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  366|    181|}
sc_pkcs15_encode_pukdf_entry:
  372|      6|{
  373|      6|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  374|      6|	struct sc_asn1_entry asn1_com_pubkey_attr[C_ASN1_COM_PUBKEY_ATTR_SIZE];
  375|      6|	struct sc_asn1_entry asn1_rsakey_value_choice[C_ASN1_RSAKEY_VALUE_CHOICE_SIZE];
  376|      6|	struct sc_asn1_entry asn1_rsakey_attr[C_ASN1_RSAKEY_ATTR_SIZE];
  377|      6|	struct sc_asn1_entry asn1_rsa_type_attr[C_ASN1_RSA_TYPE_ATTR_SIZE];
  378|      6|	struct sc_asn1_entry asn1_eckey_value_choice[C_ASN1_ECKEY_VALUE_CHOICE_SIZE];
  379|      6|	struct sc_asn1_entry asn1_eckey_attr[C_ASN1_ECKEY_ATTR_SIZE];
  380|      6|	struct sc_asn1_entry asn1_ec_type_attr[C_ASN1_EC_TYPE_ATTR_SIZE];
  381|      6|	struct sc_asn1_entry asn1_gostr3410key_attr[C_ASN1_GOST3410KEY_ATTR_SIZE];
  382|      6|	struct sc_asn1_entry asn1_gostr3410_type_attr[C_ASN1_GOST3410_TYPE_ATTR_SIZE];
  383|      6|	struct sc_asn1_entry asn1_pubkey_choice[C_ASN1_PUBKEY_CHOICE_SIZE];
  384|      6|	struct sc_asn1_entry asn1_pubkey[C_ASN1_PUBKEY_SIZE];
  385|       |
  386|      6|	struct sc_pkcs15_pubkey_info *pubkey = (struct sc_pkcs15_pubkey_info *) obj->data;
  387|      6|	struct sc_asn1_pkcs15_object rsakey_obj = {
  388|      6|		(struct sc_pkcs15_object *) obj, asn1_com_key_attr, asn1_com_pubkey_attr, asn1_rsa_type_attr
  389|      6|	};
  390|      6|	struct sc_asn1_pkcs15_object eckey_obj = { (struct sc_pkcs15_object *) obj,
  391|      6|			asn1_com_key_attr,
  392|      6|			asn1_com_pubkey_attr, asn1_ec_type_attr };
  393|      6|	struct sc_asn1_pkcs15_object gostr3410key_obj =  { (struct sc_pkcs15_object *) obj,
  394|      6|			asn1_com_key_attr,
  395|      6|			asn1_com_pubkey_attr, asn1_gostr3410_type_attr };
  396|      6|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
  397|      6|	int r;
  398|      6|	size_t af_len, usage_len;
  399|      6|	unsigned char *spki_value = NULL;
  400|       |
  401|      6|	sc_copy_asn1_entry(c_asn1_pubkey, asn1_pubkey);
  402|      6|	sc_copy_asn1_entry(c_asn1_pubkey_choice, asn1_pubkey_choice);
  403|      6|	sc_copy_asn1_entry(c_asn1_rsa_type_attr, asn1_rsa_type_attr);
  404|      6|	sc_copy_asn1_entry(c_asn1_rsakey_value_choice, asn1_rsakey_value_choice);
  405|      6|	sc_copy_asn1_entry(c_asn1_rsakey_attr, asn1_rsakey_attr);
  406|      6|	sc_copy_asn1_entry(c_asn1_ec_type_attr, asn1_ec_type_attr);
  407|      6|	sc_copy_asn1_entry(c_asn1_eckey_value_choice, asn1_eckey_value_choice);
  408|      6|	sc_copy_asn1_entry(c_asn1_eckey_attr, asn1_eckey_attr);
  409|      6|	sc_copy_asn1_entry(c_asn1_gostr3410_type_attr, asn1_gostr3410_type_attr);
  410|      6|	sc_copy_asn1_entry(c_asn1_gostr3410key_attr, asn1_gostr3410key_attr);
  411|      6|	sc_copy_asn1_entry(c_asn1_com_pubkey_attr, asn1_com_pubkey_attr);
  412|      6|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  413|       |
  414|      6|	switch (obj->type) {
  415|      4|	case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|      4|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (415:2): [True: 4, False: 2]
  ------------------
  416|      4|		sc_format_asn1_entry(asn1_pubkey_choice + 0, &rsakey_obj, NULL, 1);
  417|       |
  418|      4|		sc_format_asn1_entry(asn1_rsa_type_attr + 0, asn1_rsakey_attr, NULL, 1);
  419|      4|		if (pubkey->path.len)   {
  ------------------
  |  Branch (419:7): [True: 4, False: 0]
  ------------------
  420|      4|			sc_format_asn1_entry(asn1_rsakey_value_choice + 0, &pubkey->path, NULL, 1);
  421|      4|		}
  422|      0|		else  if (pubkey->direct.raw.value && pubkey->direct.raw.len)   {
  ------------------
  |  Branch (422:13): [True: 0, False: 0]
  |  Branch (422:41): [True: 0, False: 0]
  ------------------
  423|       |			/* In RSAPublicKeyChoice 'raw' value keep it's SEQUENCE tag */
  424|      0|			sc_log(ctx,  "Encode 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__
  |  |  ------------------
  ------------------
  425|      0|			sc_format_asn1_entry(asn1_rsakey_value_choice + 1, pubkey->direct.raw.value, (void *)&pubkey->direct.raw.len, 1);
  426|      0|		}
  427|      0|		else  if (pubkey->direct.spki.value && pubkey->direct.spki.len)   {
  ------------------
  |  Branch (427:13): [True: 0, False: 0]
  |  Branch (427:42): [True: 0, False: 0]
  ------------------
  428|       |			/* In RSAPublicKeyChoice 'spki' value changes initial SEQUENCE tag for
  429|       |			 * CONTEXT [1] constructed SEQUENCE */
  430|      0|			sc_log(ctx,  "Encode 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__
  |  |  ------------------
  ------------------
  431|      0|			spki_value = malloc(pubkey->direct.spki.len);
  432|      0|			if (!spki_value)
  ------------------
  |  Branch (432:8): [True: 0, False: 0]
  ------------------
  433|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|      0|			memcpy(spki_value, pubkey->direct.spki.value, pubkey->direct.spki.len);
  435|      0|			*spki_value = (SC_ASN1_TAG_CONTEXT | SC_ASN1_TAG_CONSTRUCTED | 0x01);
  ------------------
  |  |  187|      0|#define SC_ASN1_TAG_CONTEXT		0x80
  ------------------
              			*spki_value = (SC_ASN1_TAG_CONTEXT | SC_ASN1_TAG_CONSTRUCTED | 0x01);
  ------------------
  |  |  190|      0|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  436|       |
  437|      0|			sc_format_asn1_entry(asn1_rsakey_value_choice + 1, spki_value, (void *)&pubkey->direct.spki.len, 1);
  438|      0|		}
  439|      0|		else if (obj->content.value && obj->content.len) {
  ------------------
  |  Branch (439:12): [True: 0, False: 0]
  |  Branch (439:34): [True: 0, False: 0]
  ------------------
  440|      0|			sc_log(ctx,  "Encode 'RAW' 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__
  |  |  ------------------
  ------------------
  441|      0|			sc_format_asn1_entry(asn1_rsakey_value_choice + 1, obj->content.value, (void *)&obj->content.len, 1);
  442|      0|		}
  443|      0|		else   {
  444|      0|			sc_log(ctx,  "Use empty 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__
  |  |  ------------------
  ------------------
  445|      0|			sc_format_asn1_entry(asn1_rsakey_value_choice + 0, &pubkey->path, NULL, 1);
  446|      0|		}
  447|       |
  448|      4|		sc_format_asn1_entry(asn1_rsakey_attr + 0, asn1_rsakey_value_choice, NULL, 1);
  449|      4|		sc_format_asn1_entry(asn1_rsakey_attr + 1, &pubkey->modulus_length, NULL, 1);
  450|      4|		break;
  451|      0|	case SC_PKCS15_TYPE_PUBKEY_GOSTR3410:
  ------------------
  |  |  427|      0|#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410		0x203
  ------------------
  |  Branch (451:2): [True: 0, False: 6]
  ------------------
  452|      0|		sc_format_asn1_entry(asn1_pubkey_choice + 1, &gostr3410key_obj, NULL, 1);
  453|       |
  454|      0|		sc_format_asn1_entry(asn1_gostr3410_type_attr + 0, asn1_gostr3410key_attr, NULL, 1);
  455|       |
  456|      0|		sc_format_asn1_entry(asn1_gostr3410key_attr + 0, &pubkey->path, NULL, 1);
  457|      0|		if (pubkey->params.len == sizeof(*keyinfo_gostparams))   {
  ------------------
  |  Branch (457:7): [True: 0, False: 0]
  ------------------
  458|      0|			keyinfo_gostparams = pubkey->params.data;
  459|      0|			sc_format_asn1_entry(asn1_gostr3410key_attr + 1,
  460|      0|					&keyinfo_gostparams->gostr3410, NULL, 1);
  461|      0|			sc_format_asn1_entry(asn1_gostr3410key_attr + 2,
  462|      0|					&keyinfo_gostparams->gostr3411, NULL, 1);
  463|      0|			sc_format_asn1_entry(asn1_gostr3410key_attr + 3,
  464|      0|					&keyinfo_gostparams->gost28147, NULL, 1);
  465|      0|		}
  466|      0|		break;
  467|      2|	case SC_PKCS15_TYPE_PUBKEY_EC:
  ------------------
  |  |  428|      2|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  |  Branch (467:2): [True: 2, False: 4]
  ------------------
  468|      2|		sc_format_asn1_entry(asn1_pubkey_choice + 2, &eckey_obj, NULL, 1);
  469|       |
  470|      2|		sc_format_asn1_entry(asn1_ec_type_attr + 0, asn1_eckey_attr, NULL, 1);
  471|       |
  472|      2|		if (pubkey->path.len)   {
  ------------------
  |  Branch (472:7): [True: 2, False: 0]
  ------------------
  473|      2|			sc_format_asn1_entry(asn1_eckey_value_choice + 0, &pubkey->path, NULL, 1);
  474|      2|		}
  475|      0|		else  if (pubkey->direct.spki.value)   {
  ------------------
  |  Branch (475:13): [True: 0, False: 0]
  ------------------
  476|      0|			sc_format_asn1_entry(asn1_eckey_value_choice + 1, pubkey->direct.spki.value, (void *)&pubkey->direct.spki.len, 1);
  477|      0|		}
  478|      0|		else  if (pubkey->direct.raw.value)   {
  ------------------
  |  Branch (478:13): [True: 0, False: 0]
  ------------------
  479|      0|			sc_format_asn1_entry(asn1_eckey_value_choice + 1, pubkey->direct.raw.value, (void *)&pubkey->direct.raw.len, 1);
  480|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_IMPLEMENTED, "Needs KeyInfo with reference to algorithm in TokenInfo");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  481|      0|		}
  482|      0|		else  if (obj->content.value)   {
  ------------------
  |  Branch (482:13): [True: 0, False: 0]
  ------------------
  483|      0|			sc_format_asn1_entry(asn1_eckey_value_choice + 1, obj->content.value, (void *)&obj->content.len, 1);
  484|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_IMPLEMENTED, "Needs KeyInfo with reference to algorithm in TokenInfo");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  485|      0|		}
  486|       |
  487|      2|		sc_format_asn1_entry(asn1_eckey_attr + 0, asn1_eckey_value_choice, NULL, 1);
  488|       |
  489|      2|		break;
  490|      0|	default:
  ------------------
  |  Branch (490:2): [True: 0, False: 6]
  ------------------
  491|      0|		sc_log(ctx,  "Unsupported public key type: %X", 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__
  |  |  ------------------
  ------------------
  492|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  493|      0|		break;
  494|      6|	}
  495|       |
  496|      6|	sc_format_asn1_entry(asn1_com_key_attr + 0, &pubkey->id, NULL, 1);
  497|      6|	usage_len = sizeof(pubkey->usage);
  498|      6|	sc_format_asn1_entry(asn1_com_key_attr + 1, &pubkey->usage, &usage_len, 1);
  499|      6|	if (pubkey->native == 0)
  ------------------
  |  Branch (499:6): [True: 6, False: 0]
  ------------------
  500|      6|		sc_format_asn1_entry(asn1_com_key_attr + 2, &pubkey->native, NULL, 1);
  501|      6|	if (pubkey->access_flags) {
  ------------------
  |  Branch (501:6): [True: 0, False: 6]
  ------------------
  502|      0|		af_len = sizeof(pubkey->access_flags);
  503|      0|		sc_format_asn1_entry(asn1_com_key_attr + 3, &pubkey->access_flags, &af_len, 1);
  504|      0|	}
  505|      6|	if (pubkey->key_reference >= 0)
  ------------------
  |  Branch (505:6): [True: 6, False: 0]
  ------------------
  506|      6|		sc_format_asn1_entry(asn1_com_key_attr + 4, &pubkey->key_reference, NULL, 1);
  507|      6|	sc_format_asn1_entry(asn1_pubkey + 0, asn1_pubkey_choice, NULL, 1);
  508|       |
  509|      6|	if (pubkey->subject.value && pubkey->subject.len)
  ------------------
  |  Branch (509:6): [True: 0, False: 6]
  |  Branch (509:31): [True: 0, False: 0]
  ------------------
  510|      0|		sc_format_asn1_entry(asn1_com_pubkey_attr + 0, pubkey->subject.value, &pubkey->subject.len, 1);
  511|      6|	else
  512|      6|		memset(asn1_com_pubkey_attr, 0, sizeof(asn1_com_pubkey_attr));
  513|       |
  514|      6|	r = sc_asn1_encode(ctx, asn1_pubkey, buf, buflen);
  515|       |
  516|      6|	sc_log(ctx, "Key path %s", sc_print_path(&pubkey->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  517|       |
  518|      6|	free(spki_value);
  519|      6|	return r;
  520|      6|}
sc_pkcs15_encode_pubkey_rsa:
  586|    293|{
  587|    293|	struct sc_asn1_entry asn1_public_key[C_ASN1_PUBLIC_KEY_SIZE];
  588|    293|	struct sc_asn1_entry asn1_rsa_pub_coefficients[C_ASN1_RSA_PUB_COEFFICIENTS_SIZE];
  589|    293|	int r;
  590|       |
  591|    293|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    293|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    293|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    293|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    293|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 293]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|    293|	sc_copy_asn1_entry(c_asn1_public_key, asn1_public_key);
  593|    293|	sc_format_asn1_entry(asn1_public_key + 0, asn1_rsa_pub_coefficients, NULL, 1);
  594|       |
  595|    293|	sc_copy_asn1_entry(c_asn1_rsa_pub_coefficients, asn1_rsa_pub_coefficients);
  596|    293|	sc_format_asn1_entry(asn1_rsa_pub_coefficients + 0, key->modulus.data, &key->modulus.len, 1);
  597|    293|	sc_format_asn1_entry(asn1_rsa_pub_coefficients + 1, key->exponent.data, &key->exponent.len, 1);
  598|       |
  599|    293|	r = sc_asn1_encode(ctx, asn1_public_key, buf, buflen);
  600|    293|	LOG_TEST_RET(ctx, r, "ASN.1 encoding failed");
  ------------------
  |  |  174|    293|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    293|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    293|	int _ret = (r); \
  |  |  |  |  168|    293|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 79, False: 214]
  |  |  |  |  ------------------
  |  |  |  |  169|     79|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     79|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     79|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     79|		return _ret; \
  |  |  |  |  172|     79|	} \
  |  |  |  |  173|    293|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 214]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  601|       |
  602|    214|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    214|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    214|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    214|	int _ret = r; \
  |  |  |  |  155|    214|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 214, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    214|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 214]
  |  |  |  |  ------------------
  |  |  |  |  157|    214|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    214|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    214|	return _ret; \
  |  |  |  |  163|    214|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  603|    214|}
sc_pkcs15_encode_pubkey_ec:
  692|     39|{
  693|     39|	struct sc_asn1_entry asn1_ec_pointQ[C_ASN1_EC_POINTQ_SIZE];
  694|     39|	size_t key_len;
  695|       |	/*
  696|       |	 * PKCS15 uses RAW vs SPKI for pub key, and in raw uses OCTET STRING
  697|       |	 * PKCS11 does not define CKA_VALUE for a pub key
  698|       |	 * But some PKCS11 modules define a CKA_VALUE for a public key
  699|       |	 * and PKCS11 says ECPOINT is encoded as "DER-encoding of ANSI X9.62 ECPoint value Q"
  700|       |	 * But ANSI X9.62 (early draft at least) says encode as OCTET STRING
  701|       |	 * IETF encodes it in SubjectPublicKeyInfo (SPKI) in BIT STRING
  702|       |	 * For now return as OCTET STRING.
  703|       |	 */
  704|       |
  705|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  706|     39|	sc_copy_asn1_entry(c_asn1_ec_pointQ, asn1_ec_pointQ);
  707|       |
  708|     39|	key_len = key->ecpointQ.len;
  709|     39|	sc_format_asn1_entry(asn1_ec_pointQ + 0, key->ecpointQ.value, &key_len, 1);
  710|       |
  711|     39|	LOG_FUNC_RETURN(ctx,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  712|     39|			sc_asn1_encode(ctx, asn1_ec_pointQ, buf, buflen));
  713|     39|}
sc_pkcs15_encode_pubkey:
  769|    109|{
  770|    109|	if (key->algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   78|    109|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (770:6): [True: 70, False: 39]
  ------------------
  771|     70|		return sc_pkcs15_encode_pubkey_rsa(ctx, &key->u.rsa, buf, len);
  772|     39|	if (key->algorithm == SC_ALGORITHM_GOSTR3410)
  ------------------
  |  |   80|     39|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (772:6): [True: 0, False: 39]
  ------------------
  773|      0|		return sc_pkcs15_encode_pubkey_gostr3410(ctx, &key->u.gostr3410, buf, len);
  774|     39|	if (key->algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   79|     39|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (774:6): [True: 39, False: 0]
  ------------------
  775|     39|		return sc_pkcs15_encode_pubkey_ec(ctx, &key->u.ec, buf, len);
  776|      0|	if (key->algorithm == SC_ALGORITHM_EDDSA || key->algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
              	if (key->algorithm == SC_ALGORITHM_EDDSA || key->algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (776:6): [True: 0, False: 0]
  |  Branch (776:46): [True: 0, False: 0]
  ------------------
  777|      0|		return sc_pkcs15_encode_pubkey_eddsa(ctx, &key->u.ec, buf, len);
  778|       |
  779|      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__
  |  |  ------------------
  ------------------
  780|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  781|      0|}
sc_pkcs15_encode_pubkey_as_spki:
  801|     26|{
  802|     26|	int r = 0;
  803|     26|	struct sc_asn1_entry  asn1_spki_key[2], asn1_spki_key_items[3];
  804|     26|	struct sc_pkcs15_u8 pkey;
  805|     26|	size_t key_len;
  806|       |
  807|     26|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     26|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     26|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     26|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     26|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  808|     26|	pkey.value =  NULL;
  809|     26|	pkey.len = 0;
  810|       |
  811|     26|	sc_log(ctx, "Encoding public key with algorithm %lu", pubkey->algorithm);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  812|     26|	if (!pubkey->alg_id)   {
  ------------------
  |  Branch (812:6): [True: 4, False: 22]
  ------------------
  813|      4|		pubkey->alg_id = calloc(1, sizeof(struct sc_algorithm_id));
  814|      4|		if (!pubkey->alg_id)
  ------------------
  |  Branch (814:7): [True: 0, False: 4]
  ------------------
  815|      4|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  816|       |
  817|      4|		sc_init_oid(&pubkey->alg_id->oid);
  818|      4|		pubkey->alg_id->algorithm = pubkey->algorithm;
  819|      4|	}
  820|       |
  821|     26|	switch (pubkey->algorithm) {
  822|     10|	case SC_ALGORITHM_EC:
  ------------------
  |  |   79|     10|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (822:2): [True: 10, False: 16]
  ------------------
  823|     10|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   81|     10|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (823:2): [True: 0, False: 26]
  ------------------
  824|     10|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   82|     10|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (824:2): [True: 0, False: 26]
  ------------------
  825|       |		/*
  826|       |		 * most keys, but not EC have only one encoding.
  827|       |		 * For a SPKI, the ecpoint is placed directly in the
  828|       |		 * BIT STRING
  829|       |		 */
  830|     10|		key_len = pubkey->u.ec.ecpointQ.len * 8;
  831|     10|		pkey.value = pubkey->u.ec.ecpointQ.value;
  832|     10|		pkey.len = 0; /* flag as do not delete */
  833|       |
  834|     10|		if (pubkey->u.ec.params.named_curve || pubkey->u.ec.params.der.value)   {
  ------------------
  |  Branch (834:7): [True: 10, False: 0]
  |  Branch (834:42): [True: 0, False: 0]
  ------------------
  835|     10|			struct sc_ec_parameters *ec_params = NULL;
  836|       |
  837|     10|			r = sc_pkcs15_fix_ec_parameters(ctx, &pubkey->u.ec.params);
  838|     10|			LOG_TEST_RET(ctx, r, "failed to fix EC parameters");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  839|       |
  840|       |			/* EDDSA and XEDDSA only have algo and no param in SPKI */
  841|     10|			if (pubkey->algorithm == SC_ALGORITHM_EC) {
  ------------------
  |  |   79|     10|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (841:8): [True: 10, False: 0]
  ------------------
  842|     10|				ec_params = calloc(1, sizeof(struct sc_ec_parameters));
  843|     10|				if (!ec_params)
  ------------------
  |  Branch (843:9): [True: 0, False: 10]
  ------------------
  844|     10|					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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|     10|				ec_params->type = 1;
  846|     10|				ec_params->der.value = calloc(1, pubkey->u.ec.params.der.len);
  847|     10|				if (!ec_params->der.value) {
  ------------------
  |  Branch (847:9): [True: 0, False: 10]
  ------------------
  848|      0|					free(ec_params);
  849|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  850|      0|				}
  851|     10|				memcpy(ec_params->der.value, pubkey->u.ec.params.der.value, pubkey->u.ec.params.der.len);
  852|     10|				ec_params->der.len = pubkey->u.ec.params.der.len;
  853|     10|			}
  854|       |			/* This could have been already allocated: avoid memory leak */
  855|     10|			sc_asn1_clear_algorithm_id(pubkey->alg_id);
  856|     10|			pubkey->alg_id->params = ec_params; /* NULL for EDDSA and XEDDSA */
  857|     10|		}
  858|     10|		break;
  859|     10|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   80|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (859:2): [True: 0, False: 26]
  ------------------
  860|       |		/* TODO is this needed?  does it cause mem leak? */
  861|      0|		pubkey->alg_id->params = &pubkey->u.gostr3410.params;
  862|      0|		r = sc_pkcs15_encode_pubkey(ctx, pubkey, &pkey.value, &pkey.len);
  863|      0|		key_len = pkey.len * 8;
  864|      0|		break;
  865|     16|	default:
  ------------------
  |  Branch (865:2): [True: 16, False: 10]
  ------------------
  866|     16|		r = sc_pkcs15_encode_pubkey(ctx, pubkey, &pkey.value, &pkey.len);
  867|     16|		key_len = pkey.len * 8;
  868|     16|		break;
  869|     26|	}
  870|       |
  871|     26|	if (r == 0) {
  ------------------
  |  Branch (871:6): [True: 26, False: 0]
  ------------------
  872|     26|		sc_copy_asn1_entry(c_asn1_spki_key, asn1_spki_key);
  873|     26|		sc_copy_asn1_entry(c_asn1_spki_key_items, asn1_spki_key_items);
  874|     26|		sc_format_asn1_entry(asn1_spki_key + 0, asn1_spki_key_items, NULL, 1);
  875|     26|		sc_format_asn1_entry(asn1_spki_key_items + 0, pubkey->alg_id, NULL, 1);
  876|     26|		sc_format_asn1_entry(asn1_spki_key_items + 1, pkey.value, &key_len, 1);
  877|       |
  878|     26|		r =  sc_asn1_encode(ctx, asn1_spki_key, buf, len);
  879|     26|	}
  880|       |
  881|       |	/*  pkey.len == 0 is flag to not delete */
  882|     26|	if (pkey.len && pkey.value)
  ------------------
  |  Branch (882:6): [True: 16, False: 10]
  |  Branch (882:18): [True: 16, False: 0]
  ------------------
  883|     16|		free(pkey.value);
  884|       |
  885|     26|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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: 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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|     26|}
sc_pkcs15_erase_pubkey:
 1187|  4.46k|{
 1188|  4.46k|	if (key == NULL) {
  ------------------
  |  Branch (1188:6): [True: 0, False: 4.46k]
  ------------------
 1189|      0|		return;
 1190|      0|	}
 1191|  4.46k|	if (key->alg_id) {
  ------------------
  |  Branch (1191:6): [True: 70, False: 4.39k]
  ------------------
 1192|     70|		sc_asn1_clear_algorithm_id(key->alg_id);
 1193|     70|		free(key->alg_id);
 1194|     70|	}
 1195|  4.46k|	switch (key->algorithm) {
  ------------------
  |  Branch (1195:10): [True: 4.46k, False: 0]
  ------------------
 1196|  3.79k|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   78|  3.79k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1196:2): [True: 3.79k, False: 665]
  ------------------
 1197|  3.79k|		free(key->u.rsa.modulus.data);
 1198|  3.79k|		free(key->u.rsa.exponent.data);
 1199|  3.79k|		break;
 1200|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   80|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1200:2): [True: 0, False: 4.46k]
  ------------------
 1201|      0|		free(key->u.gostr3410.xy.data);
 1202|      0|		break;
 1203|    665|	case SC_ALGORITHM_EC:
  ------------------
  |  |   79|    665|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1203:2): [True: 665, False: 3.79k]
  ------------------
 1204|    665|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   81|    665|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1204:2): [True: 0, False: 4.46k]
  ------------------
 1205|    665|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   82|    665|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1205:2): [True: 0, False: 4.46k]
  ------------------
 1206|    665|		free(key->u.ec.params.der.value);
 1207|    665|		free(key->u.ec.params.named_curve);
 1208|    665|		free(key->u.ec.ecpointQ.value);
 1209|    665|		break;
 1210|  4.46k|	}
 1211|  4.46k|	sc_mem_clear(key, sizeof(*key));
 1212|  4.46k|}
sc_pkcs15_free_pubkey:
 1217|      6|{
 1218|      6|	if (!key)
  ------------------
  |  Branch (1218:6): [True: 6, False: 0]
  ------------------
 1219|      6|		return;
 1220|      0|	sc_pkcs15_erase_pubkey(key);
 1221|      0|	free(key);
 1222|      0|}
sc_pkcs15_free_pubkey_info:
 1227|    212|{
 1228|    212|	if (info) {
  ------------------
  |  Branch (1228:6): [True: 212, False: 0]
  ------------------
 1229|    212|		free(info->subject.value);
 1230|    212|		free(info->direct.spki.value);
 1231|    212|		free(info->direct.raw.value);
 1232|    212|		sc_pkcs15_free_key_params(&info->params);
 1233|    212|		free(info);
 1234|    212|	}
 1235|    212|}
sc_pkcs15_pubkey_from_spki_sequence:
 1456|      1|{
 1457|      1|	struct sc_pkcs15_pubkey * pubkey = NULL;
 1458|      1|	struct sc_asn1_entry asn1_spki[] = {
 1459|      1|			{ "subjectPublicKeyInfo", SC_ASN1_CALLBACK, SC_ASN1_TAG_SEQUENCE | SC_ASN1_CONS, 0, sc_pkcs15_pubkey_from_spki_fields, &pubkey},
  ------------------
  |  |  181|      1|#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|      1|#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|      1|#define SC_ASN1_CONS			0x20000000
  ------------------
 1460|      1|			{ NULL, 0, 0, 0, NULL, NULL } };
 1461|      1|	int r;
 1462|       |
 1463|      1|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1464|       |
 1465|      1|	r = sc_asn1_decode(ctx, asn1_spki, buf, buflen, NULL, NULL);
 1466|      1|	LOG_TEST_RET(ctx, r, "ASN.1 cannot parse subjectPublicKeyInfo");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1467|       |
 1468|      0|	if(outpubkey) {
  ------------------
  |  Branch (1468:5): [True: 0, False: 0]
  ------------------
 1469|      0|		free(*outpubkey);
 1470|      0|		*outpubkey = pubkey;
 1471|      0|	} else
 1472|      0|		free(pubkey);
 1473|       |
 1474|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1475|      0|}
sc_pkcs15_fix_ec_parameters:
 1564|  7.40k|{
 1565|  7.40k|	int rv, ii;
 1566|  7.40k|	int mapped_string = 0; /* der is printable string that can be replaced with der of OID */
 1567|       |
 1568|  7.40k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  7.40k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  7.40k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  7.40k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  7.40k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 7.40k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1569|       |
 1570|       |	/* In PKCS#11 EC parameters arrives in DER encoded form */
 1571|  7.40k|	if (ecparams->der.value && ecparams->der.len && ecparams->der.len > 2) {
  ------------------
  |  Branch (1571:6): [True: 5.16k, False: 2.23k]
  |  Branch (1571:29): [True: 5.16k, False: 0]
  |  Branch (1571:50): [True: 5.16k, False: 0]
  ------------------
 1572|       |
 1573|  5.16k|		switch (ecparams->der.value[0]) {
 1574|  5.16k|		case 0x06: /* der.value is an OID */
  ------------------
  |  Branch (1574:3): [True: 5.16k, False: 0]
  ------------------
 1575|  82.2k|			for (ii = 0; ec_curve_infos[ii].name; ii++) {
  ------------------
  |  Branch (1575:17): [True: 82.2k, False: 0]
  ------------------
 1576|  82.2k|				size_t len = ec_curve_infos[ii].oid_der.len;
 1577|       |
 1578|  82.2k|				if (ecparams->der.len == len &&
  ------------------
  |  Branch (1578:9): [True: 15.8k, False: 66.4k]
  ------------------
 1579|  15.8k|						memcmp(ecparams->der.value, ec_curve_infos[ii].oid_der.value, len) == 0)
  ------------------
  |  Branch (1579:7): [True: 5.16k, False: 10.6k]
  ------------------
 1580|  5.16k|					break; /* found ec_curve_infos[ii] */
 1581|  82.2k|			}
 1582|  5.16k|			break;
 1583|       |
 1584|      0|		case 0x13:
  ------------------
  |  Branch (1584:3): [True: 0, False: 5.16k]
  ------------------
 1585|       |			/* printable string as per PKCS11 V 3.0 for experimental curves */
 1586|      0|			{
 1587|      0|				int r_tag;
 1588|      0|				const u8 *body = ecparams->der.value;
 1589|      0|				size_t len = ecparams->der.len;
 1590|      0|				unsigned int cla_out, tag_out;
 1591|      0|				size_t bodylen;
 1592|       |
 1593|      0|				r_tag = sc_asn1_read_tag(&body, len, &cla_out, &tag_out, &bodylen);
 1594|      0|				if (r_tag != SC_SUCCESS || tag_out != 0x13) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1594:9): [True: 0, False: 0]
  |  Branch (1594:32): [True: 0, False: 0]
  ------------------
 1595|      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__
  |  |  ------------------
  ------------------
 1596|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1597|      0|				}
 1598|      0|				for (ii = 0; ec_curve_infos[ii].name; ii++) {
  ------------------
  |  Branch (1598:18): [True: 0, False: 0]
  ------------------
 1599|      0|					size_t len = strlen(ec_curve_infos[ii].name);
 1600|      0|					if (bodylen != len || memcmp(ec_curve_infos[ii].name, body, len) != 0)
  ------------------
  |  Branch (1600:10): [True: 0, False: 0]
  |  Branch (1600:28): [True: 0, False: 0]
  ------------------
 1601|      0|						continue;
 1602|       |					/* found replacement of printable string to OID */
 1603|      0|					mapped_string = 1;
 1604|      0|					break;
 1605|      0|				}
 1606|      0|			}
 1607|      0|			break;
 1608|       |
 1609|      0|		default:
  ------------------
  |  Branch (1609:3): [True: 0, False: 5.16k]
  ------------------
 1610|      0|			sc_log(ctx, "Unsupported ec params");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1611|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1612|  5.16k|		}
 1613|       |
 1614|  5.16k|		if (ec_curve_infos[ii].name == NULL) /* end of ec_curve_info */
  ------------------
  |  Branch (1614:7): [True: 0, False: 5.16k]
  ------------------
 1615|  5.16k|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Unsupported named curve");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1616|       |
 1617|       |		/* ii points to entry with matching oid_der or a mapped entry with replacement oid_der */
 1618|  5.16k|		sc_log(ctx, "Found known curve '%s'", ec_curve_infos[ii].name);
  ------------------
  |  |   71|  5.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__
  |  |  ------------------
  ------------------
 1619|  5.16k|		if (mapped_string) { /* free previous name if any replace below with new name */
  ------------------
  |  Branch (1619:7): [True: 0, False: 5.16k]
  ------------------
 1620|      0|			free(ecparams->named_curve);
 1621|      0|			ecparams->named_curve = NULL;
 1622|      0|		}
 1623|       |
 1624|  5.16k|		if (!ecparams->named_curve) { /* if present,keep the name as some curves have multiple names */
  ------------------
  |  Branch (1624:7): [True: 5.14k, False: 20]
  ------------------
 1625|  5.14k|			ecparams->named_curve = strdup(ec_curve_infos[ii].name);
 1626|  5.14k|			if (!ecparams->named_curve)
  ------------------
  |  Branch (1626:8): [True: 0, False: 5.14k]
  ------------------
 1627|  5.14k|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1628|       |
 1629|  5.14k|			sc_log(ctx, "Curve name: '%s'", ecparams->named_curve);
  ------------------
  |  |   71|  5.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__
  |  |  ------------------
  ------------------
 1630|  5.14k|		}
 1631|       |
 1632|       |		/* fill in object_id based on oid_der */
 1633|  5.16k|		sc_format_oid(&ecparams->id, ec_curve_infos[ii].oid_str);
 1634|       |
 1635|  5.16k|		ecparams->field_length = ec_curve_infos[ii].size;
 1636|  5.16k|		ecparams->key_type = ec_curve_infos[ii].key_type;
 1637|  5.16k|		sc_log(ctx, "Curve length %" SC_FORMAT_LEN_SIZE_T "u key_type %d",
  ------------------
  |  |   71|  5.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__
  |  |  ------------------
  ------------------
 1638|  5.16k|				ecparams->field_length, ecparams->key_type);
 1639|  5.16k|		if (mapped_string) {
  ------------------
  |  Branch (1639:7): [True: 0, False: 5.16k]
  ------------------
 1640|       |			/* replace the printable string version with the oid */
 1641|      0|			if (ecparams->der.value)
  ------------------
  |  Branch (1641:8): [True: 0, False: 0]
  ------------------
 1642|      0|				free(ecparams->der.value);
 1643|      0|			ecparams->der.len = ec_curve_infos[ii].oid_der.len;
 1644|      0|			ecparams->der.value = malloc(ecparams->der.len);
 1645|      0|			if (ecparams->der.value == NULL) {
  ------------------
  |  Branch (1645:8): [True: 0, False: 0]
  ------------------
 1646|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1647|      0|			}
 1648|      0|			memcpy(ecparams->der.value, ec_curve_infos[ii].oid_der.value, ecparams->der.len);
 1649|      0|		}
 1650|  5.16k|	} else if (ecparams->named_curve) { /* it can be name of curve or OID in ASCII form */
  ------------------
  |  Branch (1650:13): [True: 2.23k, False: 0]
  ------------------
 1651|       |		/* caller did not provide an OID, look for a name or oid_string */
 1652|  15.6k|		for (ii = 0; ec_curve_infos[ii].name; ii++) {
  ------------------
  |  Branch (1652:16): [True: 15.6k, False: 0]
  ------------------
 1653|  15.6k|			if (!strcmp(ec_curve_infos[ii].name, ecparams->named_curve))
  ------------------
  |  Branch (1653:8): [True: 2.23k, False: 13.4k]
  ------------------
 1654|  2.23k|				break;
 1655|  13.4k|			if (!strcmp(ec_curve_infos[ii].oid_str, ecparams->named_curve))
  ------------------
  |  Branch (1655:8): [True: 0, False: 13.4k]
  ------------------
 1656|      0|				break;
 1657|  13.4k|		}
 1658|  2.23k|		if (!ec_curve_infos[ii].name) {
  ------------------
  |  Branch (1658:7): [True: 0, False: 2.23k]
  ------------------
 1659|      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__
  |  |  ------------------
  ------------------
 1660|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1661|      0|		}
 1662|       |
 1663|  2.23k|		rv = sc_format_oid(&ecparams->id, ec_curve_infos[ii].oid_str);
 1664|  2.23k|		LOG_TEST_RET(ctx, rv, "Invalid OID format");
  ------------------
  |  |  174|  2.23k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.23k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.23k|	int _ret = (r); \
  |  |  |  |  168|  2.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.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|  2.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1665|       |
 1666|  2.23k|		ecparams->field_length = ec_curve_infos[ii].size;
 1667|  2.23k|		ecparams->key_type = ec_curve_infos[ii].key_type;
 1668|  2.23k|		sc_log(ctx, "Curve length %" SC_FORMAT_LEN_SIZE_T "u key_type %d",
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 1669|  2.23k|				ecparams->field_length, ecparams->key_type);
 1670|       |
 1671|  2.23k|		if (ecparams->der.value == NULL || ecparams->der.len == 0) {
  ------------------
  |  Branch (1671:7): [True: 2.23k, False: 0]
  |  Branch (1671:38): [True: 0, False: 0]
  ------------------
 1672|  2.23k|			free(ecparams->der.value); /* just in case */
 1673|  2.23k|			ecparams->der.value = NULL;
 1674|  2.23k|			ecparams->der.len = 0;
 1675|       |			/* if caller did not provide valid der OID, fill in */
 1676|  2.23k|			rv = sc_encode_oid (ctx, &ecparams->id, &ecparams->der.value, &ecparams->der.len);
 1677|  2.23k|			LOG_TEST_RET(ctx, rv, "Cannot encode object ID");
  ------------------
  |  |  174|  2.23k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.23k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.23k|	int _ret = (r); \
  |  |  |  |  168|  2.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.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|  2.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1678|  2.23k|		}
 1679|  2.23k|	} else
 1680|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1681|       |
 1682|  7.40k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  7.40k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  7.40k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  7.40k|	int _ret = r; \
  |  |  |  |  155|  7.40k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7.40k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  7.40k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.40k]
  |  |  |  |  ------------------
  |  |  |  |  157|  7.40k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  7.40k|	} else { \
  |  |  |  |  159|      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.40k|	return _ret; \
  |  |  |  |  163|  7.40k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1683|  7.40k|}

sc_pkcs15emu_sc_hsm_decode_cvc:
  433|     94|{
  434|     94|	sc_card_t *card = p15card->card;
  435|     94|	struct sc_asn1_entry asn1_req[C_ASN1_REQ_SIZE];
  436|     94|	struct sc_asn1_entry asn1_authreq[C_ASN1_AUTHREQ_SIZE];
  437|     94|	struct sc_asn1_entry asn1_cvc[C_ASN1_CVC_SIZE];
  438|     94|	struct sc_asn1_entry asn1_cvcert[C_ASN1_CVCERT_SIZE];
  439|     94|	struct sc_asn1_entry asn1_cvc_body[C_ASN1_CVC_BODY_SIZE];
  440|     94|	struct sc_asn1_entry asn1_cvc_pubkey[C_ASN1_CVC_PUBKEY_SIZE];
  441|     94|	unsigned int cla = 0, tag = 0;
  442|     94|	size_t taglen;
  443|     94|	const u8 *tbuf;
  444|     94|	int r;
  445|       |
  446|     94|	memset(cvc, 0, sizeof(*cvc));
  447|     94|	sc_copy_asn1_entry(c_asn1_req, asn1_req);
  448|     94|	sc_copy_asn1_entry(c_asn1_cvc, asn1_cvc);
  449|       |
  450|     94|	r = sc_pkcs15emu_sc_hsm_format_asn1_cvcert(
  451|     94|			asn1_cvcert, C_ASN1_CVCERT_SIZE,
  ------------------
  |  |  242|     94|#define C_ASN1_CVCERT_SIZE 3
  ------------------
  452|     94|			asn1_cvc_body, C_ASN1_CVC_BODY_SIZE,
  ------------------
  |  |  233|     94|#define C_ASN1_CVC_BODY_SIZE 5
  ------------------
  453|     94|			asn1_cvc_pubkey, C_ASN1_CVC_PUBKEY_SIZE,
  ------------------
  |  |  219|     94|#define C_ASN1_CVC_PUBKEY_SIZE 10
  ------------------
  454|     94|			cvc);
  455|     94|	LOG_TEST_RET(card->ctx, r, "sc_asn1_entry array too small");
  ------------------
  |  |  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: 0, False: 94]
  |  |  |  |  ------------------
  |  |  |  |  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|     94|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  456|       |
  457|     94|	sc_format_asn1_entry(asn1_cvc, asn1_cvcert, NULL, 0);
  458|       |
  459|     94|	r = sc_pkcs15emu_sc_hsm_format_asn1_req(
  460|     94|			asn1_authreq, C_ASN1_AUTHREQ_SIZE,
  ------------------
  |  |  255|     94|#define C_ASN1_AUTHREQ_SIZE 4
  ------------------
  461|     94|			asn1_cvcert, cvc);
  462|     94|	LOG_TEST_RET(card->ctx, r, "sc_asn1_entry array too small");
  ------------------
  |  |  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: 0, False: 94]
  |  |  |  |  ------------------
  |  |  |  |  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|     94|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 94]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  463|       |
  464|     94|	sc_format_asn1_entry(asn1_req, asn1_authreq, NULL, 0);
  465|       |
  466|       |/*	sc_asn1_print_tags(*buf, *buflen); */
  467|       |
  468|     94|	tbuf = *buf;
  469|     94|	r = sc_asn1_read_tag(&tbuf, *buflen, &cla, &tag, &taglen);
  470|     94|	LOG_TEST_RET(card->ctx, r, "Could not decode card verifiable certificate");
  ------------------
  |  |  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: 78, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     94|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  471|       |
  472|       |	/*  Determine if we deal with an authenticated request, plain request or certificate */
  473|     16|	if ((cla == (SC_ASN1_TAG_APPLICATION|SC_ASN1_TAG_CONSTRUCTED)) && (tag == 7)) {
  ------------------
  |  |  186|     16|#define SC_ASN1_TAG_APPLICATION		0x40
  ------------------
              	if ((cla == (SC_ASN1_TAG_APPLICATION|SC_ASN1_TAG_CONSTRUCTED)) && (tag == 7)) {
  ------------------
  |  |  190|     16|#define SC_ASN1_TAG_CONSTRUCTED		0x20
  ------------------
  |  Branch (473:6): [True: 6, False: 10]
  |  Branch (473:68): [True: 2, False: 4]
  ------------------
  474|      2|		r = sc_asn1_decode(card->ctx, asn1_req, *buf, *buflen, buf, buflen);
  475|     14|	} else {
  476|     14|		r = sc_asn1_decode(card->ctx, asn1_cvc, *buf, *buflen, buf, buflen);
  477|     14|	}
  478|       |
  479|     16|	LOG_TEST_RET(card->ctx, r, "Could not decode card verifiable certificate");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  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_encode_cvc:
  819|    258|{
  820|    258|	sc_card_t *card = p15card->card;
  821|    258|	struct sc_asn1_entry asn1_cvc[C_ASN1_CVC_SIZE];
  822|    258|	struct sc_asn1_entry asn1_cvcert[C_ASN1_CVCERT_SIZE];
  823|    258|	struct sc_asn1_entry asn1_cvc_body[C_ASN1_CVC_BODY_SIZE];
  824|    258|	struct sc_asn1_entry asn1_cvc_pubkey[C_ASN1_CVC_PUBKEY_SIZE];
  825|    258|	int r;
  826|       |
  827|    258|	sc_copy_asn1_entry(c_asn1_cvc, asn1_cvc);
  828|    258|	sc_copy_asn1_entry(c_asn1_cvcert, asn1_cvcert);
  829|    258|	sc_copy_asn1_entry(c_asn1_cvc_body, asn1_cvc_body);
  830|    258|	sc_copy_asn1_entry(c_asn1_cvc_pubkey, asn1_cvc_pubkey);
  831|       |
  832|    258|	asn1_cvc_pubkey[1].flags = SC_ASN1_OPTIONAL;
  ------------------
  |  |  148|    258|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  833|    258|	asn1_cvcert[1].flags = SC_ASN1_OPTIONAL;
  ------------------
  |  |  148|    258|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
  834|       |
  835|    258|	sc_format_asn1_entry(asn1_cvc_pubkey    , &cvc->pukoid, NULL, 1);
  836|    258|	if (cvc->primeOrModulus && (cvc->primeOrModuluslen > 0)) {
  ------------------
  |  Branch (836:6): [True: 130, False: 128]
  |  Branch (836:29): [True: 130, False: 0]
  ------------------
  837|    130|		sc_format_asn1_entry(asn1_cvc_pubkey + 1, cvc->primeOrModulus, &cvc->primeOrModuluslen, 1);
  838|    130|	}
  839|    258|	sc_format_asn1_entry(asn1_cvc_pubkey + 2, cvc->coefficientAorExponent, &cvc->coefficientAorExponentlen, 1);
  840|    258|	if (cvc->coefficientB && (cvc->coefficientBlen > 0)) {
  ------------------
  |  Branch (840:6): [True: 130, False: 128]
  |  Branch (840:27): [True: 130, False: 0]
  ------------------
  841|    130|		sc_format_asn1_entry(asn1_cvc_pubkey + 3, cvc->coefficientB, &cvc->coefficientBlen, 1);
  842|    130|		sc_format_asn1_entry(asn1_cvc_pubkey + 4, cvc->basePointG, &cvc->basePointGlen, 1);
  843|    130|		sc_format_asn1_entry(asn1_cvc_pubkey + 5, cvc->order, &cvc->orderlen, 1);
  844|    130|		if (cvc->publicPoint && (cvc->publicPointlen > 0)) {
  ------------------
  |  Branch (844:7): [True: 0, False: 130]
  |  Branch (844:27): [True: 0, False: 0]
  ------------------
  845|      0|			sc_format_asn1_entry(asn1_cvc_pubkey + 6, cvc->publicPoint, &cvc->publicPointlen, 1);
  846|      0|		}
  847|    130|		sc_format_asn1_entry(asn1_cvc_pubkey + 7, cvc->cofactor, &cvc->cofactorlen, 1);
  848|    130|	}
  849|    258|	if (cvc->modulusSize > 0) {
  ------------------
  |  Branch (849:6): [True: 128, False: 130]
  ------------------
  850|    128|		sc_format_asn1_entry(asn1_cvc_pubkey + 8, &cvc->modulusSize, NULL, 1);
  851|    128|	}
  852|       |
  853|    258|	sc_format_asn1_entry(asn1_cvc_body    , &cvc->cpi, NULL, 1);
  854|    258|	sc_format_asn1_entry(asn1_cvc_body + 1, &cvc->car, &cvc->carLen, 1);
  855|    258|	sc_format_asn1_entry(asn1_cvc_body + 2, &asn1_cvc_pubkey, NULL, 1);
  856|    258|	sc_format_asn1_entry(asn1_cvc_body + 3, &cvc->chr, &cvc->chrLen, 1);
  857|       |
  858|    258|	sc_format_asn1_entry(asn1_cvcert    , &asn1_cvc_body, NULL, 1);
  859|    258|	if (cvc->signature && (cvc->signatureLen > 0)) {
  ------------------
  |  Branch (859:6): [True: 0, False: 258]
  |  Branch (859:24): [True: 0, False: 0]
  ------------------
  860|      0|		sc_format_asn1_entry(asn1_cvcert + 1, cvc->signature, &cvc->signatureLen, 1);
  861|      0|	}
  862|       |
  863|    258|	sc_format_asn1_entry(asn1_cvc , &asn1_cvcert, NULL, 1);
  864|       |
  865|    258|	r = sc_asn1_encode(card->ctx, asn1_cvc, buf, buflen);
  866|    258|	LOG_TEST_RET(card->ctx, r, "Could not encode card verifiable certificate");
  ------------------
  |  |  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: 0, False: 258]
  |  |  |  |  ------------------
  |  |  |  |  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|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|       |
  868|    258|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    258|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    258|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    258|	int _ret = r; \
  |  |  |  |  155|    258|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 258, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    258|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 258]
  |  |  |  |  ------------------
  |  |  |  |  157|    258|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    258|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    258|	return _ret; \
  |  |  |  |  163|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  869|    258|}
sc_pkcs15emu_sc_hsm_get_curve:
  874|    130|{
  875|    130|	int i;
  876|       |
  877|    260|	for (i = 0; curves[i].oid.value; i++) {
  ------------------
  |  Branch (877:14): [True: 260, False: 0]
  ------------------
  878|    260|		if ((curves[i].oid.len == oidlen) && !memcmp(curves[i].oid.value, oid, oidlen)) {
  ------------------
  |  Branch (878:7): [True: 260, False: 0]
  |  Branch (878:40): [True: 130, False: 130]
  ------------------
  879|    130|			*curve = &curves[i];
  880|    130|			return SC_SUCCESS;
  ------------------
  |  |   28|    130|#define SC_SUCCESS				0
  ------------------
  881|    130|		}
  882|    260|	}
  883|      0|	return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  884|    130|}
sc_pkcs15emu_sc_hsm_free_cvc:
 1015|    516|{
 1016|    516|	if (cvc->outerSignature) {
  ------------------
  |  Branch (1016:6): [True: 0, False: 516]
  ------------------
 1017|      0|		free(cvc->outerSignature);
 1018|      0|		cvc->outerSignature = NULL;
 1019|      0|	}
 1020|    516|	if (cvc->signature) {
  ------------------
  |  Branch (1020:6): [True: 0, False: 516]
  ------------------
 1021|      0|		free(cvc->signature);
 1022|      0|		cvc->signature = NULL;
 1023|      0|	}
 1024|    516|	if (cvc->primeOrModulus) {
  ------------------
  |  Branch (1024:6): [True: 130, False: 386]
  ------------------
 1025|    130|		free(cvc->primeOrModulus);
 1026|    130|		cvc->primeOrModulus = NULL;
 1027|    130|	}
 1028|    516|	if (cvc->coefficientAorExponent) {
  ------------------
  |  Branch (1028:6): [True: 258, False: 258]
  ------------------
 1029|    258|		free(cvc->coefficientAorExponent);
 1030|    258|		cvc->coefficientAorExponent = NULL;
 1031|    258|	}
 1032|    516|	if (cvc->coefficientB) {
  ------------------
  |  Branch (1032:6): [True: 130, False: 386]
  ------------------
 1033|    130|		free(cvc->coefficientB);
 1034|    130|		cvc->coefficientB = NULL;
 1035|    130|	}
 1036|    516|	if (cvc->basePointG) {
  ------------------
  |  Branch (1036:6): [True: 130, False: 386]
  ------------------
 1037|    130|		free(cvc->basePointG);
 1038|    130|		cvc->basePointG = NULL;
 1039|    130|	}
 1040|    516|	if (cvc->order) {
  ------------------
  |  Branch (1040:6): [True: 130, False: 386]
  ------------------
 1041|    130|		free(cvc->order);
 1042|    130|		cvc->order = NULL;
 1043|    130|	}
 1044|    516|	if (cvc->publicPoint) {
  ------------------
  |  Branch (1044:6): [True: 0, False: 516]
  ------------------
 1045|      0|		free(cvc->publicPoint);
 1046|      0|		cvc->publicPoint = NULL;
 1047|      0|	}
 1048|    516|	if (cvc->cofactor) {
  ------------------
  |  Branch (1048:6): [True: 130, False: 386]
  ------------------
 1049|    130|		free(cvc->cofactor);
 1050|       |		cvc->cofactor = NULL;
 1051|    130|	}
 1052|    516|}
sc_pkcs15emu_sc_hsm_init_ex:
 1602|  3.38k|{
 1603|  3.38k|	if (p15card->card->type != SC_CARD_TYPE_SC_HSM
  ------------------
  |  Branch (1603:6): [True: 3.38k, False: 0]
  ------------------
 1604|  3.38k|			&& p15card->card->type != SC_CARD_TYPE_SC_HSM_SOC
  ------------------
  |  Branch (1604:7): [True: 3.38k, False: 0]
  ------------------
 1605|  3.38k|			&& p15card->card->type != SC_CARD_TYPE_SC_HSM_GOID) {
  ------------------
  |  Branch (1605:7): [True: 3.21k, False: 168]
  ------------------
 1606|  3.21k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.21k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
 1607|  3.21k|	}
 1608|    168|	return sc_pkcs15emu_sc_hsm_init(p15card);
 1609|  3.38k|}
pkcs15-sc-hsm.c:sc_pkcs15emu_sc_hsm_format_asn1_cvcert:
  365|     94|{
  366|     94|	if ((asn1_cvc_pubkey_len < C_ASN1_CVC_PUBKEY_SIZE) ||
  ------------------
  |  |  219|     94|#define C_ASN1_CVC_PUBKEY_SIZE 10
  ------------------
  |  Branch (366:6): [True: 0, False: 94]
  ------------------
  367|     94|		(asn1_cvc_body_len < C_ASN1_CVC_BODY_SIZE) ||
  ------------------
  |  |  233|     94|#define C_ASN1_CVC_BODY_SIZE 5
  ------------------
  |  Branch (367:3): [True: 0, False: 94]
  ------------------
  368|     94|		(asn1_cvcert_len < C_ASN1_CVCERT_SIZE)) {
  ------------------
  |  |  242|     94|#define C_ASN1_CVCERT_SIZE 3
  ------------------
  |  Branch (368:3): [True: 0, False: 94]
  ------------------
  369|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  370|      0|	}
  371|       |
  372|     94|	sc_copy_asn1_entry(c_asn1_cvc_pubkey, asn1_cvc_pubkey);
  373|     94|	sc_copy_asn1_entry(c_asn1_cvc_body, asn1_cvc_body);
  374|     94|	sc_copy_asn1_entry(c_asn1_cvcert, asn1_cvcert);
  375|       |
  376|     94|	sc_format_asn1_entry(asn1_cvc_pubkey    , &cvc->pukoid, NULL, 0);
  377|     94|	sc_format_asn1_entry(asn1_cvc_pubkey + 1, &cvc->primeOrModulus, &cvc->primeOrModuluslen, 0);
  378|     94|	sc_format_asn1_entry(asn1_cvc_pubkey + 2, &cvc->coefficientAorExponent, &cvc->coefficientAorExponentlen, 0);
  379|     94|	sc_format_asn1_entry(asn1_cvc_pubkey + 3, &cvc->coefficientB, &cvc->coefficientBlen, 0);
  380|     94|	sc_format_asn1_entry(asn1_cvc_pubkey + 4, &cvc->basePointG, &cvc->basePointGlen, 0);
  381|     94|	sc_format_asn1_entry(asn1_cvc_pubkey + 5, &cvc->order, &cvc->orderlen, 0);
  382|     94|	sc_format_asn1_entry(asn1_cvc_pubkey + 6, &cvc->publicPoint, &cvc->publicPointlen, 0);
  383|     94|	sc_format_asn1_entry(asn1_cvc_pubkey + 7, &cvc->cofactor, &cvc->cofactorlen, 0);
  384|     94|	sc_format_asn1_entry(asn1_cvc_pubkey + 8, &cvc->modulusSize, NULL, 0);
  385|       |
  386|     94|	sc_format_asn1_entry(asn1_cvc_body    , &cvc->cpi, NULL, 0);
  387|     94|	cvc->carLen = sizeof(cvc->car);
  388|     94|	sc_format_asn1_entry(asn1_cvc_body + 1, &cvc->car, &cvc->carLen, 0);
  389|     94|	sc_format_asn1_entry(asn1_cvc_body + 2, asn1_cvc_pubkey, NULL, 0);
  390|     94|	cvc->chrLen = sizeof(cvc->chr);
  391|     94|	sc_format_asn1_entry(asn1_cvc_body + 3, &cvc->chr, &cvc->chrLen, 0);
  392|       |
  393|     94|	sc_format_asn1_entry(asn1_cvcert    , asn1_cvc_body, NULL, 0);
  394|     94|	sc_format_asn1_entry(asn1_cvcert + 1, &cvc->signature, &cvc->signatureLen, 0);
  395|     94|	return SC_SUCCESS;
  ------------------
  |  |   28|     94|#define SC_SUCCESS				0
  ------------------
  396|     94|}
pkcs15-sc-hsm.c:sc_pkcs15emu_sc_hsm_format_asn1_req:
  413|     94|{
  414|     94|	if (asn1_authreq_len < C_ASN1_AUTHREQ_SIZE) {
  ------------------
  |  |  255|     94|#define C_ASN1_AUTHREQ_SIZE 4
  ------------------
  |  Branch (414:6): [True: 0, False: 94]
  ------------------
  415|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  416|      0|	}
  417|       |
  418|     94|	sc_copy_asn1_entry(c_asn1_authreq, asn1_authreq);
  419|       |
  420|     94|	sc_format_asn1_entry(asn1_authreq    , asn1_cvcert, NULL, 0);
  421|     94|	cvc->outerCARLen = sizeof(cvc->outer_car);
  422|     94|	sc_format_asn1_entry(asn1_authreq + 1, &cvc->outer_car, &cvc->outerCARLen, 0);
  423|     94|	sc_format_asn1_entry(asn1_authreq + 2, &cvc->outerSignature, &cvc->outerSignatureLen, 0);
  424|     94|	return SC_SUCCESS;
  ------------------
  |  |   28|     94|#define SC_SUCCESS				0
  ------------------
  425|     94|}
pkcs15-sc-hsm.c:sc_pkcs15emu_sc_hsm_init:
 1340|    168|{
 1341|    168|	sc_card_t *card = p15card->card;
 1342|    168|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
 1343|    168|	sc_file_t *file = NULL;
 1344|    168|	sc_path_t path;
 1345|    168|	u8 filelist[MAX_EXT_APDU_LENGTH];
 1346|    168|	int filelistlength;
 1347|    168|	int r, i;
 1348|    168|	sc_cvc_t devcert;
 1349|    168|	struct sc_app_info *appinfo;
 1350|    168|	struct sc_pkcs15_auth_info pin_info;
 1351|    168|	struct sc_pkcs15_object pin_obj;
 1352|    168|	struct sc_pin_cmd_data pindata;
 1353|    168|	u8 efbin[1024];
 1354|    168|	u8 *ptr;
 1355|    168|	size_t len;
 1356|       |
 1357|    168|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    168|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    168|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    168|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    168|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 168]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1358|       |
 1359|    168|	appinfo = calloc(1, sizeof(struct sc_app_info));
 1360|       |
 1361|    168|	if (appinfo == NULL) {
  ------------------
  |  Branch (1361:6): [True: 0, False: 168]
  ------------------
 1362|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1363|      0|	}
 1364|       |
 1365|    168|	appinfo->aid = sc_hsm_aid;
 1366|       |
 1367|    168|	appinfo->ddo.aid = sc_hsm_aid;
 1368|    168|	p15card->app = appinfo;
 1369|       |
 1370|    168|	sc_path_set(&path, SC_PATH_TYPE_DF_NAME, sc_hsm_aid.value, sc_hsm_aid.len, 0, 0);
  ------------------
  |  |  118|    168|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 1371|    168|	r = sc_select_file(card, &path, &file);
 1372|    168|	LOG_TEST_RET(card->ctx, r, "Could not select SmartCard-HSM application");
  ------------------
  |  |  174|    168|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    168|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    168|	int _ret = (r); \
  |  |  |  |  168|    168|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 87, False: 81]
  |  |  |  |  ------------------
  |  |  |  |  169|     87|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     87|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     87|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     87|		return _ret; \
  |  |  |  |  172|     87|	} \
  |  |  |  |  173|    168|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 81]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1373|       |
 1374|     81|	p15card->card->version.hw_major = 24;	/* JCOP 2.4.1r3 */
 1375|     81|	p15card->card->version.hw_minor = 13;
 1376|     81|	if (file && file->prop_attr && file->prop_attr_len >= 2) {
  ------------------
  |  Branch (1376:6): [True: 81, False: 0]
  |  Branch (1376:14): [True: 5, False: 76]
  |  Branch (1376:33): [True: 3, False: 2]
  ------------------
 1377|      3|		p15card->card->version.fw_major = file->prop_attr[file->prop_attr_len - 2];
 1378|      3|		p15card->card->version.fw_minor = file->prop_attr[file->prop_attr_len - 1];
 1379|      3|	}
 1380|       |
 1381|     81|	sc_file_free(file);
 1382|       |
 1383|       |	/* Read device certificate to determine serial number */
 1384|     81|	if (priv->EF_C_DevAut && priv->EF_C_DevAut_len) {
  ------------------
  |  Branch (1384:6): [True: 3, False: 78]
  |  Branch (1384:27): [True: 3, False: 0]
  ------------------
 1385|      3|		ptr = priv->EF_C_DevAut;
 1386|      3|		len = priv->EF_C_DevAut_len;
 1387|     78|	} else {
 1388|     78|		len = sizeof efbin;
 1389|     78|		r = read_file(p15card, (u8 *) "\x2F\x02", efbin, &len, 1);
 1390|     78|		LOG_TEST_RET(card->ctx, r, "Skipping optional EF.C_DevAut");
  ------------------
  |  |  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: 0, False: 78]
  |  |  |  |  ------------------
  |  |  |  |  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|     78|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 78]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1391|       |
 1392|     78|		if (len > 0) {
  ------------------
  |  Branch (1392:7): [True: 7, False: 71]
  ------------------
 1393|       |			/* save EF_C_DevAut for further use */
 1394|      7|			ptr = realloc(priv->EF_C_DevAut, len);
 1395|      7|			if (ptr) {
  ------------------
  |  Branch (1395:8): [True: 7, False: 0]
  ------------------
 1396|      7|				memcpy(ptr, efbin, len);
 1397|      7|				priv->EF_C_DevAut = ptr;
 1398|      7|				priv->EF_C_DevAut_len = len;
 1399|      7|			}
 1400|      7|		}
 1401|       |
 1402|     78|		ptr = efbin;
 1403|     78|	}
 1404|       |
 1405|     81|	memset(&devcert, 0 ,sizeof(devcert));
 1406|     81|	r = sc_pkcs15emu_sc_hsm_decode_cvc(p15card, (const u8 **)&ptr, &len, &devcert);
 1407|     81|	LOG_TEST_RET(card->ctx, r, "Could not decode EF.C_DevAut");
  ------------------
  |  |  174|     81|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     81|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     81|	int _ret = (r); \
  |  |  |  |  168|     81|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 81, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     81|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     81|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     81|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     81|		return _ret; \
  |  |  |  |  172|     81|	} \
  |  |  |  |  173|     81|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1408|       |
 1409|      0|	sc_pkcs15emu_sc_hsm_read_tokeninfo(p15card);
 1410|       |
 1411|      0|	if (p15card->tokeninfo->label == NULL) {
  ------------------
  |  Branch (1411:6): [True: 0, False: 0]
  ------------------
 1412|      0|		if (p15card->card->type == SC_CARD_TYPE_SC_HSM_GOID
  ------------------
  |  Branch (1412:7): [True: 0, False: 0]
  ------------------
 1413|      0|				|| p15card->card->type == SC_CARD_TYPE_SC_HSM_SOC) {
  ------------------
  |  Branch (1413:8): [True: 0, False: 0]
  ------------------
 1414|      0|			p15card->tokeninfo->label = strdup("GoID");
 1415|      0|		} else {
 1416|      0|			p15card->tokeninfo->label = strdup("SmartCard-HSM");
 1417|      0|		}
 1418|      0|		if (p15card->tokeninfo->label == NULL)
  ------------------
  |  Branch (1418:7): [True: 0, False: 0]
  ------------------
 1419|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1420|      0|	}
 1421|       |
 1422|      0|	if ((p15card->tokeninfo->manufacturer_id != NULL) && !strcmp("(unknown)", p15card->tokeninfo->manufacturer_id)) {
  ------------------
  |  Branch (1422:6): [True: 0, False: 0]
  |  Branch (1422:55): [True: 0, False: 0]
  ------------------
 1423|      0|		free(p15card->tokeninfo->manufacturer_id);
 1424|      0|		p15card->tokeninfo->manufacturer_id = NULL;
 1425|      0|	}
 1426|       |
 1427|      0|	if (p15card->tokeninfo->manufacturer_id == NULL) {
  ------------------
  |  Branch (1427:6): [True: 0, False: 0]
  ------------------
 1428|      0|		if (p15card->card->type == SC_CARD_TYPE_SC_HSM_GOID
  ------------------
  |  Branch (1428:7): [True: 0, False: 0]
  ------------------
 1429|      0|				|| p15card->card->type == SC_CARD_TYPE_SC_HSM_SOC) {
  ------------------
  |  Branch (1429:8): [True: 0, False: 0]
  ------------------
 1430|      0|			p15card->tokeninfo->manufacturer_id = strdup("Bundesdruckerei GmbH");
 1431|      0|		} else {
 1432|      0|			p15card->tokeninfo->manufacturer_id = strdup("www.CardContact.de");
 1433|      0|		}
 1434|      0|		if (p15card->tokeninfo->manufacturer_id == NULL) {
  ------------------
  |  Branch (1434:7): [True: 0, False: 0]
  ------------------
 1435|      0|			sc_pkcs15_card_clear(p15card);
 1436|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1437|      0|		}
 1438|      0|	}
 1439|       |
 1440|      0|	appinfo->label = strdup(p15card->tokeninfo->label);
 1441|      0|	if (appinfo->label == NULL) {
  ------------------
  |  Branch (1441:6): [True: 0, False: 0]
  ------------------
 1442|      0|		sc_pkcs15_card_clear(p15card);
 1443|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1444|      0|	}
 1445|       |
 1446|      0|	len = strnlen(devcert.chr, sizeof devcert.chr);		/* Strip last 5 digit sequence number from CHR */
 1447|      0|	if (len < 8)
  ------------------
  |  Branch (1447:6): [True: 0, False: 0]
  ------------------
 1448|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 1449|      0|	len -= 5;
 1450|       |
 1451|      0|	free(p15card->tokeninfo->serial_number);
 1452|      0|	p15card->tokeninfo->serial_number = calloc(1, len + 1);
 1453|      0|	if (p15card->tokeninfo->serial_number == NULL) {
  ------------------
  |  Branch (1453:6): [True: 0, False: 0]
  ------------------
 1454|      0|		sc_pkcs15_card_clear(p15card);
 1455|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1456|      0|	}
 1457|       |
 1458|      0|	memcpy(p15card->tokeninfo->serial_number, devcert.chr, len);
 1459|      0|	*(p15card->tokeninfo->serial_number + len) = 0;
 1460|       |
 1461|      0|	sc_hsm_set_serialnr(card, p15card->tokeninfo->serial_number);
 1462|       |
 1463|      0|	sc_pkcs15emu_sc_hsm_free_cvc(&devcert);
 1464|       |
 1465|      0|	memset(&pin_info, 0, sizeof(pin_info));
 1466|      0|	memset(&pin_obj, 0, sizeof(pin_obj));
 1467|       |
 1468|      0|	pin_info.auth_id.len = 1;
 1469|      0|	pin_info.auth_id.value[0] = 1;
 1470|      0|	pin_info.path.aid = sc_hsm_aid;
 1471|      0|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1472|      0|	pin_info.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1473|      0|	pin_info.attrs.pin.reference = 0x81;
 1474|      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
  ------------------
 1475|      0|	pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|      0|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
 1476|      0|	pin_info.attrs.pin.min_length = 6;
 1477|      0|	pin_info.attrs.pin.stored_length = 0;
 1478|      0|	pin_info.attrs.pin.max_length = 15;
 1479|      0|	pin_info.attrs.pin.pad_char = '\0';
 1480|      0|	pin_info.tries_left = 3;
 1481|      0|	pin_info.max_tries = 3;
 1482|       |
 1483|      0|	pin_obj.auth_id.len = 1;
 1484|      0|	pin_obj.auth_id.value[0] = 2;
 1485|      0|	strlcpy(pin_obj.label, "UserPIN", sizeof(pin_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1486|      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
  ------------------
 1487|       |
 1488|      0|	pin_obj.data = &pin_info;
 1489|       |
 1490|      0|	r = sc_pkcs15_get_pin_info(p15card, &pin_obj);
 1491|       |
 1492|      0|	if (r != SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (1492:6): [True: 0, False: 0]
  ------------------
 1493|      0|		if (r < 0) {
  ------------------
  |  Branch (1493:7): [True: 0, False: 0]
  ------------------
 1494|      0|			sc_pkcs15_card_clear(p15card);
 1495|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1496|      0|		}
 1497|       |
 1498|      0|		r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
 1499|      0|		if (r < 0) {
  ------------------
  |  Branch (1499:7): [True: 0, False: 0]
  ------------------
 1500|      0|			sc_pkcs15_card_clear(p15card);
 1501|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1502|      0|		}
 1503|      0|	}
 1504|       |
 1505|      0|	memset(&pin_info, 0, sizeof(pin_info));
 1506|      0|	memset(&pin_obj, 0, sizeof(pin_obj));
 1507|       |
 1508|      0|	pin_info.auth_id.len = 1;
 1509|      0|	pin_info.auth_id.value[0] = 2;
 1510|      0|	pin_info.path.aid = sc_hsm_aid;
 1511|      0|	pin_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1512|      0|	pin_info.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1513|      0|	pin_info.attrs.pin.reference = 0x88;
 1514|      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
  ------------------
 1515|      0|	pin_info.attrs.pin.type = SC_PKCS15_PIN_TYPE_BCD;
  ------------------
  |  |   88|      0|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
 1516|      0|	pin_info.attrs.pin.min_length = 16;
 1517|      0|	pin_info.attrs.pin.stored_length = 0;
 1518|      0|	pin_info.attrs.pin.max_length = 16;
 1519|      0|	pin_info.attrs.pin.pad_char = '\0';
 1520|      0|	pin_info.tries_left = 15;
 1521|      0|	pin_info.max_tries = 15;
 1522|       |
 1523|      0|	strlcpy(pin_obj.label, "SOPIN", sizeof(pin_obj.label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 1524|      0|	pin_obj.flags = SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 1525|       |
 1526|      0|	pin_obj.data = &pin_info;
 1527|       |
 1528|      0|	r = sc_pkcs15_get_pin_info(p15card, &pin_obj);
 1529|       |
 1530|      0|	if (r != SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (1530:6): [True: 0, False: 0]
  ------------------
 1531|      0|		pin_info.attrs.pin.flags |= SC_PKCS15_PIN_FLAG_INITIALIZED;
  ------------------
  |  |   58|      0|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  ------------------
 1532|      0|	} else {
 1533|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1534|      0|	}
 1535|       |
 1536|      0|	if (r < 0) {
  ------------------
  |  Branch (1536:6): [True: 0, False: 0]
  ------------------
 1537|      0|		sc_pkcs15_card_clear(p15card);
 1538|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1539|      0|	}
 1540|       |
 1541|      0|	r = sc_pkcs15emu_add_pin_obj(p15card, &pin_obj, &pin_info);
 1542|      0|	if (r < 0) {
  ------------------
  |  Branch (1542:6): [True: 0, False: 0]
  ------------------
 1543|      0|		sc_pkcs15_card_clear(p15card);
 1544|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1545|      0|	}
 1546|       |
 1547|       |
 1548|      0|	if (card->type == SC_CARD_TYPE_SC_HSM_SOC
  ------------------
  |  Branch (1548:6): [True: 0, False: 0]
  ------------------
 1549|      0|			|| card->type == SC_CARD_TYPE_SC_HSM_GOID) {
  ------------------
  |  Branch (1549:7): [True: 0, False: 0]
  ------------------
 1550|       |		/* SC-HSM of this type always has a PIN-Pad */
 1551|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1552|      0|	} else {
 1553|      0|		memset(&pindata, 0, sizeof(pindata));
 1554|      0|		pindata.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  425|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
 1555|      0|		pindata.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1556|      0|		pindata.pin_reference = 0x85;
 1557|       |
 1558|      0|		r = sc_pin_cmd(card, &pindata);
 1559|      0|	}
 1560|      0|	if (r == SC_ERROR_DATA_OBJECT_NOT_FOUND) {
  ------------------
  |  |   66|      0|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (1560:6): [True: 0, False: 0]
  ------------------
 1561|      0|		memset(&pindata, 0, sizeof(pindata));
 1562|      0|		pindata.cmd = SC_PIN_CMD_GET_INFO;
  ------------------
  |  |  425|      0|#define SC_PIN_CMD_GET_INFO	3
  ------------------
 1563|      0|		pindata.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1564|      0|		pindata.pin_reference = 0x86;
 1565|       |
 1566|      0|		r = sc_pin_cmd(card, &pindata);
 1567|      0|	}
 1568|       |
 1569|      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 (1569:6): [True: 0, False: 0]
  |  Branch (1569:47): [True: 0, False: 0]
  |  Branch (1569:87): [True: 0, False: 0]
  ------------------
 1570|      0|		card->caps |= SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH;
  ------------------
  |  |  567|      0|#define SC_CARD_CAP_PROTECTED_AUTHENTICATION_PATH	0x00000100
  ------------------
 1571|       |
 1572|       |
 1573|      0|	filelistlength = sc_list_files(card, filelist, sizeof(filelist));
 1574|      0|	if (filelistlength < 0)
  ------------------
  |  Branch (1574:6): [True: 0, False: 0]
  ------------------
 1575|      0|		sc_pkcs15_card_clear(p15card);
 1576|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1577|       |
 1578|      0|	for (i = 0; i < filelistlength; i += 2) {
  ------------------
  |  Branch (1578:14): [True: 0, False: 0]
  ------------------
 1579|      0|		switch(filelist[i]) {
  ------------------
  |  Branch (1579:10): [True: 0, False: 0]
  ------------------
 1580|      0|		case KEY_PREFIX:
  ------------------
  |  |   33|      0|#define KEY_PREFIX				0xCC		/* Hi byte in file identifier for key objects */
  ------------------
  |  Branch (1580:3): [True: 0, False: 0]
  ------------------
 1581|      0|			r = sc_pkcs15emu_sc_hsm_add_prkd(p15card, filelist[i + 1]);
 1582|      0|			break;
 1583|      0|		case DCOD_PREFIX:
  ------------------
  |  |   31|      0|#define DCOD_PREFIX				0xC9		/* Hi byte in file identifier for PKCS#15 DCOD objects */
  ------------------
  |  Branch (1583:3): [True: 0, False: 0]
  ------------------
 1584|      0|			r = sc_pkcs15emu_sc_hsm_add_dcod(p15card, filelist[i + 1]);
 1585|      0|			break;
 1586|      0|		case CD_PREFIX:
  ------------------
  |  |   30|      0|#define CD_PREFIX				0xC8		/* Hi byte in file identifier for PKCS#15 CD objects */
  ------------------
  |  Branch (1586:3): [True: 0, False: 0]
  ------------------
 1587|      0|			r = sc_pkcs15emu_sc_hsm_add_cd(p15card, filelist[i + 1]);
 1588|      0|			break;
 1589|      0|		}
 1590|      0|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (1590:7): [True: 0, False: 0]
  ------------------
 1591|      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__
  |  |  ------------------
  ------------------
 1592|      0|		}
 1593|      0|	}
 1594|       |
 1595|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1596|      0|}
pkcs15-sc-hsm.c:read_file:
  293|     78|{
  294|     78|	sc_path_t path;
  295|     78|	int r;
  296|       |
  297|     78|	sc_path_set(&path, SC_PATH_TYPE_FILE_ID, fid, 2, 0, 0);
  ------------------
  |  |  117|     78|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  298|       |	/* look this up with our AID */
  299|     78|	path.aid = sc_hsm_aid;
  300|       |	/* we don't have a pre-known size of the file */
  301|     78|	path.count = -1;
  302|     78|	if (!p15card->opts.use_file_cache || !efbin
  ------------------
  |  Branch (302:6): [True: 78, False: 0]
  |  Branch (302:39): [True: 0, False: 0]
  ------------------
  303|     78|			|| 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|     78|		path.aid.len = 0;
  306|     78|		r = sc_select_file(p15card->card, &path, NULL);
  307|     78|		if (r < 0) {
  ------------------
  |  Branch (307:7): [True: 71, False: 7]
  ------------------
  308|     71|			sc_log(p15card->card->ctx, "Could not select EF");
  ------------------
  |  |   71|     71|#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|     71|		} else {
  310|      7|			r = sc_read_binary(p15card->card, 0, efbin, *len, 0);
  311|      7|		}
  312|       |
  313|     78|		if (r < 0) {
  ------------------
  |  Branch (313:7): [True: 71, False: 7]
  ------------------
  314|     71|			sc_log(p15card->card->ctx, "Could not read EF");
  ------------------
  |  |   71|     71|#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|     71|			if (!optional) {
  ------------------
  |  Branch (315:8): [True: 0, False: 71]
  ------------------
  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|     71|			*len = 0;
  322|     71|		} else {
  323|      7|			*len = r;
  324|      7|		}
  325|       |
  326|     78|		if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (326:7): [True: 0, False: 78]
  ------------------
  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|     78|	}
  332|       |
  333|     78|	return SC_SUCCESS;
  ------------------
  |  |   28|     78|#define SC_SUCCESS				0
  ------------------
  334|     78|}

sc_pkcs15emu_skeid_init_ex:
  181|  2.61k|{
  182|  2.61k|	int r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  2.61k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  183|       |
  184|  2.61k|	if (p15card->card->type == SC_CARD_TYPE_SKEID_V3
  ------------------
  |  Branch (184:6): [True: 0, False: 2.61k]
  ------------------
  185|      0|		&& (aid == NULL || (aid->len == skeid_aid_qes.len && !memcmp(aid->value, &skeid_aid_qes.value, skeid_aid_qes.len))))
  ------------------
  |  Branch (185:7): [True: 0, False: 0]
  |  Branch (185:23): [True: 0, False: 0]
  |  Branch (185:56): [True: 0, False: 0]
  ------------------
  186|      0|		r = sc_pkcs15emu_skeid_init(p15card);
  187|       |
  188|  2.61k|	return r;
  189|  2.61k|}

sc_pkcs15_decode_skdf_entry:
  102|     70|{
  103|     70|        struct sc_context *ctx = p15card->card->ctx;
  104|     70|        struct sc_pkcs15_skey_info info;
  105|     70|	int r, i, ii;
  106|     70|	size_t usage_len = sizeof(info.usage);
  107|     70|	size_t af_len = sizeof(info.access_flags);
  108|     70|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  109|     70|	struct sc_asn1_entry asn1_com_skey_attr[C_ASN1_COM_SKEY_ATTR_SIZE];
  110|     70|	struct sc_asn1_entry asn1_generic_skey_attr[C_ASN1_COM_SKEY_GENERIC_ATTR_SIZE];
  111|     70|	struct sc_asn1_entry asn1_generic_skey_value_attr[C_ASN1_COM_SKEY_GENERIC_VALUE_ATTR_SIZE];
  112|     70|	struct sc_asn1_entry asn1_skey_choice[C_ASN1_SKEY_CHOICE_SIZE];
  113|     70|	struct sc_asn1_entry asn1_skey[C_ASN1_SKEY_SIZE];
  114|     70|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  115|     70|	struct sc_asn1_pkcs15_object skey_des_obj = {
  116|     70|		obj, asn1_com_key_attr, asn1_com_skey_attr, asn1_generic_skey_attr
  117|     70|	};
  118|     70|	static const struct sc_object_id id_aes = { { 2, 16, 840, 1, 101, 3, 4, 1, -1 } };
  119|     70|	struct sc_object_id temp_oid;
  120|       |
  121|     70|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_ASN1);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  122|       |
  123|     70|	sc_copy_asn1_entry(c_asn1_skey, asn1_skey);
  124|     70|	sc_copy_asn1_entry(c_asn1_skey_choice, asn1_skey_choice);
  125|     70|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  126|       |
  127|     70|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  128|     70|	sc_copy_asn1_entry(c_asn1_com_skey_attr, asn1_com_skey_attr);
  129|     70|	sc_copy_asn1_entry(c_asn1_generic_skey_attr, asn1_generic_skey_attr);
  130|     70|	sc_copy_asn1_entry(c_asn1_generic_skey_value_attr, asn1_generic_skey_value_attr);
  131|       |
  132|     70|	sc_format_asn1_entry(asn1_skey + 0, asn1_skey_choice, NULL, 0);
  133|     70|	sc_format_asn1_entry(asn1_skey_choice + 0, &skey_des_obj, NULL, 0);
  134|     70|	sc_format_asn1_entry(asn1_skey_choice + 1, &skey_des_obj, NULL, 0);
  135|     70|	sc_format_asn1_entry(asn1_skey_choice + 2, &skey_des_obj, NULL, 0);
  136|     70|	sc_format_asn1_entry(asn1_skey_choice + 3, &skey_des_obj, NULL, 0);
  137|       |
  138|     70|	sc_format_asn1_entry(asn1_com_key_attr + 0, &info.id, NULL, 0);
  139|     70|	sc_format_asn1_entry(asn1_com_key_attr + 1, &info.usage, &usage_len, 0);
  140|     70|	sc_format_asn1_entry(asn1_com_key_attr + 2, &info.native, NULL, 0);
  141|     70|	sc_format_asn1_entry(asn1_com_key_attr + 3, &info.access_flags, &af_len, 0);
  142|     70|	sc_format_asn1_entry(asn1_com_key_attr + 4, &info.key_reference, NULL, 0);
  143|  1.19k|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && (asn1_supported_algorithms + i)->name; i++)
  ------------------
  |  |   61|  2.38k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (143:12): [True: 1.12k, False: 70]
  |  Branch (143:45): [True: 1.12k, False: 0]
  ------------------
  144|  1.12k|		sc_format_asn1_entry(asn1_supported_algorithms + i, &info.algo_refs[i], NULL, 0);
  145|     70|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, 0);
  146|       |
  147|     70|	sc_format_asn1_entry(asn1_com_skey_attr + 0, &info.value_len, NULL, 0);
  148|       |
  149|     70|	sc_format_asn1_entry(asn1_generic_skey_attr + 0, asn1_generic_skey_value_attr, NULL, 0);
  150|     70|	sc_format_asn1_entry(asn1_generic_skey_value_attr + 0, &info.path, NULL, 0);
  151|       |
  152|       |        /* Fill in defaults */
  153|     70|	memset(&info, 0, sizeof(info));
  154|     70|	info.native = 1;
  155|       |
  156|     70|	r = sc_asn1_decode(ctx, asn1_skey, *buf, *buflen, buf, buflen);
  157|     70|	if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|     70|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (157:6): [True: 4, False: 66]
  ------------------
  158|      4|		return r;
  159|     66|	LOG_TEST_RET(ctx, r, "ASN.1 decoding 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: 42, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     66|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 24]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  160|     24|	if (asn1_skey_choice[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|     24|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (160:6): [True: 20, False: 4]
  ------------------
  161|     20|		obj->type = SC_PKCS15_TYPE_SKEY_GENERIC;
  ------------------
  |  |  433|     20|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  162|       |
  163|       |		/* Check key type. framework-pkcs15 recognizes one type per key, and AES is the only algorithm supported for
  164|       |		* SKEY_GENERIC type keys, so just check if this key is AES compatible. */
  165|       |
  166|     20|		for (i = 0; i < SC_MAX_SUPPORTED_ALGORITHMS && info.algo_refs[i] != 0 && info.key_type == 0; i++) {
  ------------------
  |  |   61|     40|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (166:15): [True: 20, False: 0]
  |  Branch (166:50): [True: 0, False: 20]
  |  Branch (166:76): [True: 0, False: 0]
  ------------------
  167|      0|			for (ii = 0; ii < SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo != 0; ii++) {
  ------------------
  |  |   61|      0|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (167:17): [True: 0, False: 0]
  |  Branch (167:53): [True: 0, False: 0]
  ------------------
  168|      0|				if (info.algo_refs[i] == p15card->tokeninfo->supported_algos[ii].reference) {
  ------------------
  |  Branch (168:9): [True: 0, False: 0]
  ------------------
  169|      0|					temp_oid = p15card->tokeninfo->supported_algos[ii].algo_id;
  170|      0|					temp_oid.value[8] = -1; /* strip off AES subtype octet*/
  171|       |
  172|      0|					if (sc_compare_oid(&id_aes, &temp_oid)) {
  ------------------
  |  Branch (172:10): [True: 0, False: 0]
  ------------------
  173|      0|						info.key_type = CKK_AES;
  ------------------
  |  |  485|      0|#define CKK_AES 0x0000001FUL
  ------------------
  174|      0|						break;
  175|      0|					}
  176|      0|				}
  177|      0|			}
  178|      0|		}
  179|     20|	}
  180|      4|	else if (asn1_skey_choice[1].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      4|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (180:11): [True: 1, False: 3]
  ------------------
  181|      1|		obj->type = SC_PKCS15_TYPE_SKEY_DES;
  ------------------
  |  |  434|      1|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
  182|      3|	else if (asn1_skey_choice[2].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      3|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (182:11): [True: 1, False: 2]
  ------------------
  183|      1|		obj->type = SC_PKCS15_TYPE_SKEY_2DES;
  ------------------
  |  |  435|      1|#define SC_PKCS15_TYPE_SKEY_2DES		0x303
  ------------------
  184|      2|	else if (asn1_skey_choice[3].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|      2|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (184:11): [True: 2, False: 0]
  ------------------
  185|      2|		obj->type = SC_PKCS15_TYPE_SKEY_3DES;
  ------------------
  |  |  436|      2|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
  186|      0|	else
  187|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|       |
  189|     24|	obj->data = malloc(sizeof(info));
  190|     24|	if (obj->data == NULL)
  ------------------
  |  Branch (190:6): [True: 0, False: 24]
  ------------------
  191|     24|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|     24|	memcpy(obj->data, &info, sizeof(info));
  193|       |
  194|     24|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|     24|}
sc_pkcs15_encode_skdf_entry:
  201|     51|{
  202|     51|	struct sc_pkcs15_skey_info *skey = (struct sc_pkcs15_skey_info *) obj->data;
  203|     51|	int r, i;
  204|     51|	size_t usage_len = sizeof(skey->usage);
  205|     51|	size_t af_len = sizeof(skey->access_flags);
  206|     51|	struct sc_asn1_entry asn1_com_key_attr[C_ASN1_COM_KEY_ATTR_SIZE];
  207|     51|	struct sc_asn1_entry asn1_com_skey_attr[C_ASN1_COM_SKEY_ATTR_SIZE];
  208|     51|	struct sc_asn1_entry asn1_generic_skey_attr[C_ASN1_COM_SKEY_GENERIC_ATTR_SIZE];
  209|     51|	struct sc_asn1_entry asn1_generic_skey_value_attr[C_ASN1_COM_SKEY_GENERIC_VALUE_ATTR_SIZE];
  210|     51|	struct sc_asn1_entry asn1_skey_choice[C_ASN1_SKEY_CHOICE_SIZE];
  211|     51|	struct sc_asn1_entry asn1_skey[C_ASN1_SKEY_SIZE];
  212|     51|	struct sc_asn1_entry asn1_supported_algorithms[C_ASN1_SUPPORTED_ALGORITHMS_SIZE];
  213|     51|	struct sc_asn1_pkcs15_object skey_obj = {
  214|     51|		(struct sc_pkcs15_object *) obj, asn1_com_key_attr,
  215|     51|		asn1_com_skey_attr, asn1_generic_skey_attr
  216|     51|	};
  217|       |
  218|     51|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_ASN1);
  ------------------
  |  |  148|     51|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|     51|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|     51|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 51]
  |  |  ------------------
  ------------------
  219|       |
  220|     51|	sc_copy_asn1_entry(c_asn1_skey, asn1_skey);
  221|     51|	sc_copy_asn1_entry(c_asn1_skey_choice, asn1_skey_choice);
  222|     51|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  223|       |
  224|     51|	sc_copy_asn1_entry(c_asn1_com_key_attr, asn1_com_key_attr);
  225|     51|	sc_copy_asn1_entry(c_asn1_com_skey_attr, asn1_com_skey_attr);
  226|     51|	sc_copy_asn1_entry(c_asn1_generic_skey_attr, asn1_generic_skey_attr);
  227|     51|	sc_copy_asn1_entry(c_asn1_generic_skey_value_attr, asn1_generic_skey_value_attr);
  228|       |
  229|     51|	sc_format_asn1_entry(asn1_skey + 0, asn1_skey_choice, NULL, 1);
  230|     51|	switch (obj->type) {
  231|     21|	case SC_PKCS15_TYPE_SKEY_GENERIC:
  ------------------
  |  |  433|     21|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  |  Branch (231:2): [True: 21, False: 30]
  ------------------
  232|     21|		sc_format_asn1_entry(asn1_skey_choice + 0, &skey_obj, NULL, 1);
  233|     21|		break;
  234|     18|	case SC_PKCS15_TYPE_SKEY_DES:
  ------------------
  |  |  434|     18|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
  |  Branch (234:2): [True: 18, False: 33]
  ------------------
  235|     18|		sc_format_asn1_entry(asn1_skey_choice + 1, &skey_obj, NULL, 1);
  236|     18|		break;
  237|      0|	case SC_PKCS15_TYPE_SKEY_2DES:
  ------------------
  |  |  435|      0|#define SC_PKCS15_TYPE_SKEY_2DES		0x303
  ------------------
  |  Branch (237:2): [True: 0, False: 51]
  ------------------
  238|      0|		sc_format_asn1_entry(asn1_skey_choice + 2, &skey_obj, NULL, 1);
  239|      0|		break;
  240|     12|	case SC_PKCS15_TYPE_SKEY_3DES:
  ------------------
  |  |  436|     12|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
  |  Branch (240:2): [True: 12, False: 39]
  ------------------
  241|     12|		sc_format_asn1_entry(asn1_skey_choice + 3, &skey_obj, NULL, 1);
  242|     12|		break;
  243|      0|	default:
  ------------------
  |  Branch (243:2): [True: 0, False: 51]
  ------------------
  244|      0|		sc_log(ctx, "Invalid secret key type: %X", 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__
  |  |  ------------------
  ------------------
  245|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  246|      0|		break;
  247|     51|	}
  248|       |
  249|     51|	sc_format_asn1_entry(asn1_com_key_attr + 0, &skey->id, NULL, 1);
  250|     51|	sc_format_asn1_entry(asn1_com_key_attr + 1, &skey->usage, &usage_len, 1);
  251|     51|	if (skey->native == 0)
  ------------------
  |  Branch (251:6): [True: 0, False: 51]
  ------------------
  252|      0|		sc_format_asn1_entry(asn1_com_key_attr + 2, &skey->native, NULL, 1);
  253|     51|	if (skey->access_flags)
  ------------------
  |  Branch (253:6): [True: 51, False: 0]
  ------------------
  254|     51|		sc_format_asn1_entry(asn1_com_key_attr + 3, &skey->access_flags, &af_len, 1);
  255|     51|	if (skey->key_reference >= 0)
  ------------------
  |  Branch (255:6): [True: 51, False: 0]
  ------------------
  256|     51|		sc_format_asn1_entry(asn1_com_key_attr + 4, &skey->key_reference, NULL, 1);
  257|     93|	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && i<C_ASN1_SUPPORTED_ALGORITHMS_SIZE && skey->algo_refs[i]; i++)
  ------------------
  |  |   61|    186|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
              	for (i=0; i<SC_MAX_SUPPORTED_ALGORITHMS && i<C_ASN1_SUPPORTED_ALGORITHMS_SIZE && skey->algo_refs[i]; i++)
  ------------------
  |  |   33|    186|#define C_ASN1_SUPPORTED_ALGORITHMS_SIZE (SC_MAX_SUPPORTED_ALGORITHMS + 1)
  |  |  ------------------
  |  |  |  |   61|     93|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  |  |  ------------------
  ------------------
  |  Branch (257:12): [True: 93, False: 0]
  |  Branch (257:45): [True: 93, False: 0]
  |  Branch (257:83): [True: 42, False: 51]
  ------------------
  258|     42|		sc_format_asn1_entry(asn1_supported_algorithms + i, &skey->algo_refs[i], NULL, 1);
  259|     51|	sc_format_asn1_entry(asn1_com_key_attr + 5, asn1_supported_algorithms, NULL, skey->algo_refs[0] != 0);
  260|       |
  261|     51|	sc_format_asn1_entry(asn1_com_skey_attr + 0, &skey->value_len, NULL, 1);
  262|       |
  263|     51|	sc_format_asn1_entry(asn1_generic_skey_attr + 0, asn1_generic_skey_value_attr, NULL, 1);
  264|       |
  265|     51|	sc_format_asn1_entry(asn1_generic_skey_value_attr + 0, &skey->path, NULL, 1);
  266|       |
  267|     51|	r = sc_asn1_encode(ctx, asn1_skey, buf, buflen);
  268|       |
  269|     51|	sc_log(ctx, "Key path %s", sc_print_path(&skey->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  270|     51|	LOG_FUNC_RETURN(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|      8|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 8, False: 43]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|     51|}
sc_pkcs15_free_skey_info:
  275|  4.32k|{
  276|  4.32k|	if (info) {
  ------------------
  |  Branch (276:6): [True: 4.32k, False: 0]
  ------------------
  277|  4.32k|		free(info->data.value);
  278|  4.32k|		free(info);
  279|  4.32k|	}
  280|  4.32k|}

sc_pkcs15emu_srbeid_init_ex:
  570|  2.54k|{
  571|  2.54k|	(void)aid;
  572|       |
  573|  2.54k|	if (p15card->card->type != SC_CARD_TYPE_SRBEID_BASE)
  ------------------
  |  Branch (573:6): [True: 2.54k, False: 0]
  ------------------
  574|  2.54k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  2.54k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  575|       |
  576|      0|	return sc_pkcs15emu_srbeid_init(p15card);
  577|  2.54k|}

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

sc_pkcs15emu_starcos_esign_init_ex:
  355|  2.54k|{
  356|  2.54k|	int r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  2.54k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  357|       |
  358|  2.54k|	if (!p15card || !p15card->card || !p15card->card->ctx)
  ------------------
  |  Branch (358:6): [True: 0, False: 2.54k]
  |  Branch (358:18): [True: 0, False: 2.54k]
  |  Branch (358:36): [True: 0, False: 2.54k]
  ------------------
  359|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  360|       |
  361|  2.54k|	r = starcos_esign_init(p15card, aid);
  362|  2.54k|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  164|  2.54k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.54k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.54k|	int _ret = r; \
  |  |  |  |  155|  2.54k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.54k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.54k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.54k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.54k, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.54k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.54k|	} else { \
  |  |  |  |  159|      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.54k|	return _ret; \
  |  |  |  |  163|  2.54k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  363|  2.54k|}
pkcs15-starcos-esign.c:starcos_esign_init:
  286|  2.54k|{
  287|  2.54k|	sc_card_t *card = p15card->card;
  288|  2.54k|	sc_context_t *ctx = card->ctx;
  289|  2.54k|	const char *label = name_Card;
  290|  2.54k|	int r;
  291|  2.54k|	int apps_added = 0;
  292|       |
  293|  2.54k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_NORMAL);
  ------------------
  |  |  148|  2.54k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  2.54k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  2.54k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 2.54k]
  |  |  ------------------
  ------------------
  294|       |
  295|  2.54k|	if (card->type != SC_CARD_TYPE_STARCOS_V3_4_ESIGN && card->type != SC_CARD_TYPE_STARCOS_V3_5_ESIGN) {
  ------------------
  |  Branch (295:6): [True: 2.49k, False: 57]
  |  Branch (295:55): [True: 2.49k, False: 0]
  ------------------
  296|  2.49k|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  2.49k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  297|  2.49k|	}
  298|       |
  299|     57|	if (aid == NULL) {
  ------------------
  |  Branch (299:6): [True: 57, False: 0]
  ------------------
  300|       |		// no aid: in this case all emulated apps are added, currently only the esign_app
  301|     57|		r = starcos_add_esign_app(p15card);
  302|     57|		if (r == SC_SUCCESS)
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  |  Branch (302:7): [True: 20, False: 37]
  ------------------
  303|     20|			apps_added++;
  304|     57|	} 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|     57|	if (apps_added == 0) {
  ------------------
  |  Branch (327:6): [True: 37, False: 20]
  ------------------
  328|     37|		LOG_TEST_RET(ctx, SC_ERROR_WRONG_CARD, "No supported app found on this card");
  ------------------
  |  |  174|     37|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     37|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     37|	int _ret = (r); \
  |  |  |  |  168|     37|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 37, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     37|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     37|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     37|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     37|		return _ret; \
  |  |  |  |  172|     37|	} \
  |  |  |  |  173|     37|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  329|     37|	}
  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: 12, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|     20|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|      8|		r = sc_bin_to_hex(serial.value, serial.len, serial_hex, sizeof serial_hex, 0);
  343|      8|		LOG_TEST_RET(ctx, r, "Failed to convert S/N to hex");
  ------------------
  |  |  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: 0, False: 8]
  |  |  |  |  ------------------
  |  |  |  |  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|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 8]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  344|      8|		p15card->tokeninfo->serial_number = strdup(serial_hex);
  345|      8|		p15card->tokeninfo->label = strdup(label);
  346|      8|		p15card->tokeninfo->manufacturer_id = strdup(name_Vendor);
  347|      8|		p15card->tokeninfo->flags = SC_PKCS15_TOKEN_READONLY;
  ------------------
  |  |  595|      8|#define SC_PKCS15_TOKEN_READONLY			0x01
  ------------------
  348|      8|	}
  349|       |
  350|      8|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|      8|}
pkcs15-starcos-esign.c:starcos_add_esign_app:
  253|     57|{
  254|     57|	static cdata auth_cert = {"C.CH.AUT", 0, "3F00060843F1", "1", 0};
  255|     57|	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|     57|	static prdata auth_key = {"1", "PrK.CH.AUT", 2048, USAGE_AUT, "3F000608", 0x81, "1", SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   89|     57|#define USAGE_AUT SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
  |  |  ------------------
  |  |  |  |  305|     57|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  |  |  ------------------
  |  |   90|     57|				  SC_PKCS15_PRKEY_USAGE_DECRYPT | \
  |  |  ------------------
  |  |  |  |  306|     57|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |   91|     57|				  SC_PKCS15_PRKEY_USAGE_WRAP | \
  |  |  ------------------
  |  |  |  |  309|     57|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  |  |  ------------------
  |  |   92|     57|				  SC_PKCS15_PRKEY_USAGE_UNWRAP | \
  |  |  ------------------
  |  |  |  |  310|     57|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  |  |   93|     57|				  SC_PKCS15_PRKEY_USAGE_SIGN
  |  |  ------------------
  |  |  |  |  307|     57|#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|     57|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  262|     57|	static prdata encr_key = {"2", "PrK.CH.ENC", 2048, USAGE_KE, "3F000608", 0x83, "1", SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   85|     57|#define USAGE_KE     SC_PKCS15_PRKEY_USAGE_ENCRYPT | \
  |  |  ------------------
  |  |  |  |  305|     57|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  |  |  ------------------
  |  |   86|     57|				 SC_PKCS15_PRKEY_USAGE_DECRYPT | \
  |  |  ------------------
  |  |  |  |  306|     57|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |   87|     57|				 SC_PKCS15_PRKEY_USAGE_WRAP | \
  |  |  ------------------
  |  |  |  |  309|     57|#define SC_PKCS15_PRKEY_USAGE_WRAP		0x10
  |  |  ------------------
  |  |   88|     57|				 SC_PKCS15_PRKEY_USAGE_UNWRAP
  |  |  ------------------
  |  |  |  |  310|     57|#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|     57|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  263|       |
  264|     57|	static pindata auth_pin = {"1", "UserPIN", "3F00", 0x01, SC_PKCS15_PIN_TYPE_UTF8, 16, 6, 0,
  ------------------
  |  |   90|     57|#define SC_PKCS15_PIN_TYPE_UTF8				2
  ------------------
  265|     57|			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   94|     57|#define USER_PIN  SC_PKCS15_PIN_FLAG_INITIALIZED | \
  |  |  ------------------
  |  |  |  |   58|     57|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   95|     57|				SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | \
  |  |  ------------------
  |  |  |  |   54|     57|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  |  |  ------------------
  |  |   96|     57|				SC_PKCS15_PIN_TYPE_FLAGS_PIN_GLOBAL | \
  |  |  ------------------
  |  |  |  |   75|     57|	( SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|     57|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   97|     57|				SC_PKCS15_PIN_AUTH_TYPE_PIN
  |  |  ------------------
  |  |  |  |   94|     57|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  |  |  ------------------
  ------------------
              			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   51|     57|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   50|     57|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  266|       |
  267|     57|	static pindata auth_pin_v35 = {"1", "UserPIN", "3F00", 0x06, SC_PKCS15_PIN_TYPE_UTF8, 16, 6, 0,
  ------------------
  |  |   90|     57|#define SC_PKCS15_PIN_TYPE_UTF8				2
  ------------------
  268|     57|			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   94|     57|#define USER_PIN  SC_PKCS15_PIN_FLAG_INITIALIZED | \
  |  |  ------------------
  |  |  |  |   58|     57|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  ------------------
  |  |   95|     57|				SC_PKCS15_PIN_FLAG_CASE_SENSITIVE | \
  |  |  ------------------
  |  |  |  |   54|     57|#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE		0x0001
  |  |  ------------------
  |  |   96|     57|				SC_PKCS15_PIN_TYPE_FLAGS_PIN_GLOBAL | \
  |  |  ------------------
  |  |  |  |   75|     57|	( SC_PKCS15_PIN_FLAG_INITIALIZED )
  |  |  |  |  ------------------
  |  |  |  |  |  |   58|     57|#define SC_PKCS15_PIN_FLAG_INITIALIZED			0x0010
  |  |  |  |  ------------------
  |  |  ------------------
  |  |   97|     57|				SC_PKCS15_PIN_AUTH_TYPE_PIN
  |  |  ------------------
  |  |  |  |   94|     57|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  |  |  ------------------
  ------------------
              			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   51|     57|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  ------------------
              			USER_PIN, -1, 3, 0x00, SC_PKCS15_CO_FLAG_MODIFIABLE | SC_PKCS15_CO_FLAG_PRIVATE};
  ------------------
  |  |   50|     57|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  269|       |
  270|     57|	ppindata auth = (p15card->card->type == SC_CARD_TYPE_STARCOS_V3_5_ESIGN) ? &auth_pin_v35 : &auth_pin;
  ------------------
  |  Branch (270:18): [True: 0, False: 57]
  ------------------
  271|       |
  272|     57|	const container containers[] = {
  273|     57|			{"1", &auth_cert, auth, &auth_key},
  274|     57|			{"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|     57|	};
  280|       |
  281|     57|	return add_app(p15card, containers, sizeof(containers) / sizeof(container));
  282|     57|}
pkcs15-starcos-esign.c:add_app:
  116|     57|{
  117|     57|	int i, containers_added = 0, r = SC_SUCCESS;
  ------------------
  |  |   28|     57|#define SC_SUCCESS				0
  ------------------
  118|     57|	ppindata installed_pins[4];
  119|     57|	size_t installed_pin_count = 0;
  120|     57|	sc_card_t *card = p15card->card;
  121|       |
  122|     57|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     57|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     57|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     57|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     57|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 57]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  123|       |
  124|    171|	for (i = 0; i < container_count; i++) {
  ------------------
  |  Branch (124:14): [True: 114, False: 57]
  ------------------
  125|    114|		struct sc_pkcs15_cert_info cert_info;
  126|    114|		struct sc_pkcs15_object cert_obj;
  127|    114|		size_t cert_size;
  128|       |
  129|    114|		memset(&cert_info, 0, sizeof(cert_info));
  130|    114|		memset(&cert_obj, 0, sizeof(cert_obj));
  131|       |
  132|    114|		sc_pkcs15_format_id(containers[i].id, &cert_info.id);
  133|    114|		cert_info.authority = containers[i].certdata->authority;
  134|    114|		sc_format_path(containers[i].certdata->path, &cert_info.path);
  135|       |
  136|    114|		r = get_cert_size(card, &cert_info.path, &cert_size);
  137|    114|		if ( r != SC_SUCCESS ) {
  ------------------
  |  |   28|    114|#define SC_SUCCESS				0
  ------------------
  |  Branch (137:8): [True: 89, False: 25]
  ------------------
  138|     89|			sc_log(card->ctx, "Failed to determine size of certificate %s, ignoring container", containers[i].certdata->label);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  139|     89|			continue;
  140|     89|		}
  141|       |
  142|     25|		strlcpy(cert_obj.label, containers[i].certdata->label, sizeof(cert_obj.label));
  ------------------
  |  |   43|     25|#define strlcpy _strlcpy
  ------------------
  143|     25|		cert_obj.flags = containers[i].certdata->obj_flags;
  144|       |
  145|     25|		r = sc_pkcs15emu_add_x509_cert(p15card, &cert_obj, &cert_info);
  146|     25|		LOG_TEST_RET(card->ctx, r, "Failed to add certificate");
  ------------------
  |  |  174|     25|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     25|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     25|	int _ret = (r); \
  |  |  |  |  168|     25|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  147|       |
  148|     25|		if (containers[i].pindata != 0) {
  ------------------
  |  Branch (148:7): [True: 25, False: 0]
  ------------------
  149|     25|			size_t j;
  150|     25|			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|     25|			for (j = 0; j < installed_pin_count; j++) {
  ------------------
  |  Branch (153:16): [True: 5, False: 20]
  ------------------
  154|      5|				if (installed_pins[j] == containers[i].pindata) {
  ------------------
  |  Branch (154:9): [True: 5, False: 0]
  ------------------
  155|      5|					is_pin_installed = 1;
  156|      5|					break;
  157|      5|				}
  158|      5|			}
  159|       |
  160|     25|			if (!is_pin_installed) {
  ------------------
  |  Branch (160:8): [True: 20, False: 5]
  ------------------
  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|     25|		}
  195|       |
  196|     25|		if (containers[i].prdata != 0) {
  ------------------
  |  Branch (196:7): [True: 25, False: 0]
  ------------------
  197|     25|			struct sc_pkcs15_prkey_info prkey_info;
  198|     25|			struct sc_pkcs15_object prkey_obj;
  199|     25|			int modulus_len = containers[i].prdata->modulus_len;
  200|     25|			memset(&prkey_info, 0, sizeof(prkey_info));
  201|     25|			memset(&prkey_obj, 0, sizeof(prkey_obj));
  202|       |
  203|     25|			sc_pkcs15_format_id(containers[i].id, &prkey_info.id);
  204|     25|			prkey_info.usage = containers[i].prdata->usage;
  205|     25|			prkey_info.native = 1;
  206|     25|			prkey_info.key_reference = containers[i].prdata->ref;
  207|     25|			prkey_info.modulus_length = modulus_len;
  208|     25|			sc_format_path(containers[i].prdata->path, &prkey_info.path);
  209|       |
  210|     25|			strlcpy(prkey_obj.label, containers[i].prdata->label, sizeof(prkey_obj.label));
  ------------------
  |  |   43|     25|#define strlcpy _strlcpy
  ------------------
  211|     25|			prkey_obj.flags = containers[i].prdata->obj_flags;
  212|     25|			if (containers[i].prdata->auth_id) {
  ------------------
  |  Branch (212:8): [True: 25, False: 0]
  ------------------
  213|     25|				sc_pkcs15_format_id(containers[i].prdata->auth_id, &prkey_obj.auth_id);
  214|     25|			}
  215|       |
  216|     25|			r = sc_pkcs15emu_add_rsa_prkey(p15card, &prkey_obj, &prkey_info);
  217|     25|			LOG_TEST_RET(card->ctx, r, "Failed to add RSA prkey");
  ------------------
  |  |  174|     25|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     25|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     25|	int _ret = (r); \
  |  |  |  |  168|     25|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|     25|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  218|     25|		}
  219|       |
  220|     25|		containers_added++;
  221|     25|	}
  222|       |
  223|     57|	if (containers_added == 0) {
  ------------------
  |  Branch (223:6): [True: 37, False: 20]
  ------------------
  224|     37|		r = SC_ERROR_INVALID_CARD;
  ------------------
  |  |   60|     37|#define SC_ERROR_INVALID_CARD			-1210
  ------------------
  225|     37|	} else {
  226|     20|		r = SC_SUCCESS;
  ------------------
  |  |   28|     20|#define SC_SUCCESS				0
  ------------------
  227|     20|	}
  228|       |
  229|     57|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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|     37|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 37, False: 20]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  230|     57|}
pkcs15-starcos-esign.c:get_cert_size:
  101|    114|{
  102|    114|	int r;
  103|    114|	sc_file_t *file = NULL;
  104|       |
  105|    114|	r = sc_select_file(card, path, &file);
  106|    114|	LOG_TEST_RET(card->ctx, r, "Failed to select EF certificate");
  ------------------
  |  |  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: 89, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  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|    114|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  107|       |
  108|     25|	*psize = file->size;
  109|     25|	sc_file_free(file);
  110|       |
  111|     25|	return SC_SUCCESS;
  ------------------
  |  |   28|     25|#define SC_SUCCESS				0
  ------------------
  112|    114|}

sc_pkcs15_is_emulation_only:
   89|  4.96k|{
   90|  4.96k|	switch (card->type) {
   91|      0|		case SC_CARD_TYPE_GEMSAFEV1_PTEID:
  ------------------
  |  Branch (91:3): [True: 0, False: 4.96k]
  ------------------
   92|      4|		case SC_CARD_TYPE_OPENPGP_V1:
  ------------------
  |  Branch (92:3): [True: 4, False: 4.96k]
  ------------------
   93|     12|		case SC_CARD_TYPE_OPENPGP_V2:
  ------------------
  |  Branch (93:3): [True: 8, False: 4.96k]
  ------------------
   94|     12|		case SC_CARD_TYPE_OPENPGP_GNUK:
  ------------------
  |  Branch (94:3): [True: 0, False: 4.96k]
  ------------------
   95|     50|		case SC_CARD_TYPE_OPENPGP_V3:
  ------------------
  |  Branch (95:3): [True: 38, False: 4.93k]
  ------------------
   96|     50|		case SC_CARD_TYPE_SC_HSM:
  ------------------
  |  Branch (96:3): [True: 0, False: 4.96k]
  ------------------
   97|     50|		case SC_CARD_TYPE_SC_HSM_SOC:
  ------------------
  |  Branch (97:3): [True: 0, False: 4.96k]
  ------------------
   98|     50|		case SC_CARD_TYPE_DNIE_BASE:
  ------------------
  |  Branch (98:3): [True: 0, False: 4.96k]
  ------------------
   99|     50|		case SC_CARD_TYPE_DNIE_BLANK:
  ------------------
  |  Branch (99:3): [True: 0, False: 4.96k]
  ------------------
  100|     50|		case SC_CARD_TYPE_DNIE_ADMIN:
  ------------------
  |  Branch (100:3): [True: 0, False: 4.96k]
  ------------------
  101|     50|		case SC_CARD_TYPE_DNIE_USER:
  ------------------
  |  Branch (101:3): [True: 0, False: 4.96k]
  ------------------
  102|     50|		case SC_CARD_TYPE_DNIE_TERMINATED:
  ------------------
  |  Branch (102:3): [True: 0, False: 4.96k]
  ------------------
  103|    251|		case SC_CARD_TYPE_IASECC_GEMALTO:
  ------------------
  |  Branch (103:3): [True: 201, False: 4.76k]
  ------------------
  104|    253|		case SC_CARD_TYPE_IASECC_CPX:
  ------------------
  |  Branch (104:3): [True: 2, False: 4.96k]
  ------------------
  105|    274|		case SC_CARD_TYPE_IASECC_CPXCL:
  ------------------
  |  Branch (105:3): [True: 21, False: 4.94k]
  ------------------
  106|    274|		case SC_CARD_TYPE_PIV_II_GENERIC:
  ------------------
  |  Branch (106:3): [True: 0, False: 4.96k]
  ------------------
  107|    274|		case SC_CARD_TYPE_PIV_II_HIST:
  ------------------
  |  Branch (107:3): [True: 0, False: 4.96k]
  ------------------
  108|    274|		case SC_CARD_TYPE_PIV_II_NEO:
  ------------------
  |  Branch (108:3): [True: 0, False: 4.96k]
  ------------------
  109|    274|		case SC_CARD_TYPE_PIV_II_YUBIKEY4:
  ------------------
  |  Branch (109:3): [True: 0, False: 4.96k]
  ------------------
  110|    274|		case SC_CARD_TYPE_PIV_II_SWISSBIT:
  ------------------
  |  Branch (110:3): [True: 0, False: 4.96k]
  ------------------
  111|    274|		case SC_CARD_TYPE_ESTEID_2018:
  ------------------
  |  Branch (111:3): [True: 0, False: 4.96k]
  ------------------
  112|    274|		case SC_CARD_TYPE_CARDOS_V5_0:
  ------------------
  |  Branch (112:3): [True: 0, False: 4.96k]
  ------------------
  113|    472|		case SC_CARD_TYPE_CARDOS_V5_3:
  ------------------
  |  Branch (113:3): [True: 198, False: 4.77k]
  ------------------
  114|    472|		case SC_CARD_TYPE_NQ_APPLET:
  ------------------
  |  Branch (114:3): [True: 0, False: 4.96k]
  ------------------
  115|    472|		case SC_CARD_TYPE_NQ_APPLET_RFID:
  ------------------
  |  Branch (115:3): [True: 0, False: 4.96k]
  ------------------
  116|    564|		case SC_CARD_TYPE_STARCOS_V3_4_ESIGN:
  ------------------
  |  Branch (116:3): [True: 92, False: 4.87k]
  ------------------
  117|    564|		case SC_CARD_TYPE_STARCOS_V3_5_ESIGN:
  ------------------
  |  Branch (117:3): [True: 0, False: 4.96k]
  ------------------
  118|    564|		case SC_CARD_TYPE_SKEID_V3:
  ------------------
  |  Branch (118:3): [True: 0, False: 4.96k]
  ------------------
  119|    564|		case SC_CARD_TYPE_EOI:
  ------------------
  |  Branch (119:3): [True: 0, False: 4.96k]
  ------------------
  120|    564|		case SC_CARD_TYPE_EOI_CONTACTLESS:
  ------------------
  |  Branch (120:3): [True: 0, False: 4.96k]
  ------------------
  121|    564|		case SC_CARD_TYPE_DTRUST_V4_1_STD:
  ------------------
  |  Branch (121:3): [True: 0, False: 4.96k]
  ------------------
  122|    564|		case SC_CARD_TYPE_DTRUST_V4_4_STD:
  ------------------
  |  Branch (122:3): [True: 0, False: 4.96k]
  ------------------
  123|    564|		case SC_CARD_TYPE_DTRUST_V4_1_MULTI:
  ------------------
  |  Branch (123:3): [True: 0, False: 4.96k]
  ------------------
  124|    564|		case SC_CARD_TYPE_DTRUST_V4_1_M100:
  ------------------
  |  Branch (124:3): [True: 0, False: 4.96k]
  ------------------
  125|    564|		case SC_CARD_TYPE_DTRUST_V4_4_MULTI:
  ------------------
  |  Branch (125:3): [True: 0, False: 4.96k]
  ------------------
  126|    564|		case SC_CARD_TYPE_DTRUST_V5_1_STD:
  ------------------
  |  Branch (126:3): [True: 0, False: 4.96k]
  ------------------
  127|    564|		case SC_CARD_TYPE_DTRUST_V5_4_STD:
  ------------------
  |  Branch (127:3): [True: 0, False: 4.96k]
  ------------------
  128|    564|		case SC_CARD_TYPE_DTRUST_V5_1_MULTI:
  ------------------
  |  Branch (128:3): [True: 0, False: 4.96k]
  ------------------
  129|    564|		case SC_CARD_TYPE_DTRUST_V5_1_M100:
  ------------------
  |  Branch (129:3): [True: 0, False: 4.96k]
  ------------------
  130|    564|		case SC_CARD_TYPE_DTRUST_V5_4_MULTI:
  ------------------
  |  Branch (130:3): [True: 0, False: 4.96k]
  ------------------
  131|    564|		case SC_CARD_TYPE_LTEID:
  ------------------
  |  Branch (131:3): [True: 0, False: 4.96k]
  ------------------
  132|    564|			return 1;
  133|  4.40k|		default:
  ------------------
  |  Branch (133:3): [True: 4.40k, False: 564]
  ------------------
  134|  4.40k|			return 0;
  135|  4.96k|	}
  136|  4.96k|}
sc_pkcs15_bind_synthetic:
  140|  3.40k|{
  141|  3.40k|	sc_context_t		*ctx = p15card->card->ctx;
  142|  3.40k|	scconf_block		*conf_block, **blocks, *blk;
  143|  3.40k|	int			i, r = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.40k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  144|       |
  145|  3.40k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  3.40k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  3.40k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  3.40k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 3.40k]
  |  |  ------------------
  ------------------
  146|  3.40k|	conf_block = NULL;
  147|       |
  148|  3.40k|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
  149|       |
  150|  3.40k|	if (!conf_block) {
  ------------------
  |  Branch (150:6): [True: 3.40k, False: 0]
  ------------------
  151|       |		/* no conf file found => try builtin drivers  */
  152|  3.40k|		sc_log(ctx, "no conf file (or section), trying all builtin emulators");
  ------------------
  |  |   71|  3.40k|#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|  89.2k|		for (i = 0; builtin_emulators[i].name; i++) {
  ------------------
  |  Branch (153:15): [True: 86.7k, False: 2.54k]
  ------------------
  154|  86.7k|			sc_log(ctx, "trying %s", builtin_emulators[i].name);
  ------------------
  |  |   71|  86.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__
  |  |  ------------------
  ------------------
  155|  86.7k|			r = builtin_emulators[i].handler(p15card, aid);
  156|  86.7k|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|  86.7k|#define SC_SUCCESS				0
  ------------------
  |  Branch (156:8): [True: 862, False: 85.8k]
  ------------------
  157|       |				/* we got a hit */
  158|    862|				goto out;
  159|  86.7k|		}
  160|  3.40k|	} else {
  161|       |		/* we have a conf file => let's use it */
  162|      0|		int builtin_enabled;
  163|      0|		const scconf_list *list;
  164|       |
  165|      0|		builtin_enabled = scconf_get_bool(conf_block, "enable_builtin_emulation", 1);
  166|      0|		list = scconf_find_list(conf_block, "builtin_emulators"); /* FIXME: rename to enabled_emulators */
  167|       |
  168|      0|		if (builtin_enabled && list) {
  ------------------
  |  Branch (168:7): [True: 0, False: 0]
  |  Branch (168:26): [True: 0, False: 0]
  ------------------
  169|       |			/* filter enabled emulation drivers from conf file */
  170|      0|			struct _sc_pkcs15_emulators filtered_emulators;
  171|      0|			struct sc_pkcs15_emulator_handler** lst;
  172|      0|			int ret;
  173|       |
  174|      0|			filtered_emulators.ccount = 0;
  175|      0|			ret = set_emulators(ctx, &filtered_emulators, list, builtin_emulators, old_emulators);
  176|      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 (176:8): [True: 0, False: 0]
  |  Branch (176:29): [True: 0, False: 0]
  ------------------
  177|      0|				lst = filtered_emulators.list_of_handlers;
  178|       |
  179|      0|				if (ret == SC_ERROR_TOO_MANY_OBJECTS)
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  |  Branch (179:9): [True: 0, False: 0]
  ------------------
  180|      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)
  |  |  ------------------
  |  |  |  |  180|      0|					sc_log(ctx, "trying first %d emulators from conf file", SC_MAX_PKCS15_EMULATORS);
  |  |  |  |  ------------------
  |  |  |  |  |  |   52|      0|#define SC_MAX_PKCS15_EMULATORS	48
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  181|       |
  182|      0|				for (i = 0; lst[i]; i++) {
  ------------------
  |  Branch (182:17): [True: 0, False: 0]
  ------------------
  183|      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__
  |  |  ------------------
  ------------------
  184|      0|					r = lst[i]->handler(p15card, aid);
  185|      0|					if (r == SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (185:10): [True: 0, False: 0]
  ------------------
  186|       |						/* we got a hit */
  187|      0|						goto out;
  188|      0|				}
  189|      0|			} else {
  190|      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__
  |  |  ------------------
  ------------------
  191|      0|			}
  192|      0|		}
  193|      0|		else if (builtin_enabled) {
  ------------------
  |  Branch (193:12): [True: 0, False: 0]
  ------------------
  194|      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__
  |  |  ------------------
  ------------------
  195|      0|			for (i = 0; builtin_emulators[i].name; i++) {
  ------------------
  |  Branch (195:16): [True: 0, False: 0]
  ------------------
  196|      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__
  |  |  ------------------
  ------------------
  197|      0|				r = builtin_emulators[i].handler(p15card, aid);
  198|      0|				if (r == SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (198:9): [True: 0, False: 0]
  ------------------
  199|       |					/* we got a hit */
  200|      0|					goto out;
  201|      0|			}
  202|      0|		}
  203|       |
  204|       |		/* search for 'emulate foo { ... }' entries in the conf file */
  205|      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__
  |  |  ------------------
  ------------------
  206|      0|		blocks = scconf_find_blocks(ctx->conf, conf_block, "emulate", NULL);
  207|      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__
  |  |  ------------------
  ------------------
  208|      0|		for (i = 0; blocks && (blk = blocks[i]) != NULL; i++) {
  ------------------
  |  Branch (208:15): [True: 0, False: 0]
  |  Branch (208:25): [True: 0, False: 0]
  ------------------
  209|      0|			const char *name = blk->name->data;
  210|      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__
  |  |  ------------------
  ------------------
  211|      0|			r = parse_emu_block(p15card, aid, blk);
  212|      0|			if (r == SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (212:8): [True: 0, False: 0]
  ------------------
  213|      0|				free(blocks);
  214|      0|				goto out;
  215|      0|			}
  216|      0|		}
  217|      0|		if (blocks)
  ------------------
  |  Branch (217:7): [True: 0, False: 0]
  ------------------
  218|      0|			free(blocks);
  219|      0|	}
  220|       |
  221|  3.40k|out:
  222|  3.40k|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|  3.40k|#define SC_SUCCESS				0
  ------------------
  |  Branch (222:6): [True: 862, False: 2.54k]
  ------------------
  223|    862|		p15card->magic  = SC_PKCS15_CARD_MAGIC;
  ------------------
  |  |  519|    862|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  224|    862|		p15card->flags |= SC_PKCS15_CARD_FLAG_EMULATED;
  ------------------
  |  |  601|    862|#define SC_PKCS15_CARD_FLAG_EMULATED			0x02000000
  ------------------
  225|  2.54k|	} else {
  226|  2.54k|		if (r != SC_ERROR_WRONG_CARD)
  ------------------
  |  |   94|  2.54k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  |  Branch (226:7): [True: 0, False: 2.54k]
  ------------------
  227|      0|			sc_log(ctx, "Failed to load card emulator: %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__
  |  |  ------------------
  ------------------
  228|  2.54k|	}
  229|       |
  230|  3.40k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  3.40k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.40k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.40k|	int _ret = r; \
  |  |  |  |  155|  3.40k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.40k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.40k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.54k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.54k, False: 862]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.40k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.40k|	} else { \
  |  |  |  |  159|      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.40k|	return _ret; \
  |  |  |  |  163|  3.40k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|  3.40k|}
sc_pkcs15emu_add_pin_obj:
  367|    693|{
  368|    693|	sc_pkcs15_auth_info_t pin = *in_pin;
  369|       |
  370|    693|	pin.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    693|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  371|    693|	if(!pin.auth_method) /* or SC_AC_NONE */
  ------------------
  |  Branch (371:5): [True: 508, False: 185]
  ------------------
  372|    508|		pin.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|    508|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  373|       |
  374|    693|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_AUTH_PIN, obj, &pin);
  ------------------
  |  |  445|    693|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  375|    693|}
sc_pkcs15emu_add_rsa_prkey:
  379|    285|{
  380|    285|	sc_pkcs15_prkey_info_t key = *in_key;
  381|       |
  382|    285|	if (key.access_flags == 0)
  ------------------
  |  Branch (382:6): [True: 285, False: 0]
  ------------------
  383|    285|		key.access_flags = SC_PKCS15_PRKEY_ACCESS_SENSITIVE
  ------------------
  |  |  316|    285|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
  384|    285|				| SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE
  ------------------
  |  |  318|    285|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
  385|    285|				| SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE
  ------------------
  |  |  319|    285|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
  386|    285|				| SC_PKCS15_PRKEY_ACCESS_LOCAL;
  ------------------
  |  |  320|    285|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  387|       |
  388|    285|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_PRKEY_RSA, obj, &key);
  ------------------
  |  |  419|    285|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  389|    285|}
sc_pkcs15emu_add_rsa_pubkey:
  393|      9|{
  394|      9|	sc_pkcs15_pubkey_info_t key = *in_key;
  395|       |
  396|      9|	if (key.access_flags == 0)
  ------------------
  |  Branch (396:6): [True: 9, False: 0]
  ------------------
  397|      9|		key.access_flags = SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE;
  ------------------
  |  |  317|      9|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  398|       |
  399|      9|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_PUBKEY_RSA, obj, &key);
  ------------------
  |  |  426|      9|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  400|      9|}
sc_pkcs15emu_add_x509_cert:
  479|    243|{
  480|    243|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_CERT_X509, obj, cert);
  ------------------
  |  |  439|    243|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  481|    243|}
sc_pkcs15emu_add_data_object:
  485|     62|{
  486|     62|	return sc_pkcs15emu_object_add(p15card, SC_PKCS15_TYPE_DATA_OBJECT, obj, data);
  ------------------
  |  |  442|     62|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  487|     62|}
sc_pkcs15emu_object_add:
  491|  1.29k|{
  492|  1.29k|	sc_pkcs15_object_t *obj;
  493|  1.29k|	unsigned int	df_type;
  494|  1.29k|	size_t		data_len;
  495|       |
  496|  1.29k|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.29k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.29k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.29k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.29k]
  |  |  ------------------
  ------------------
  497|       |
  498|  1.29k|	obj = calloc(1, sizeof(*obj));
  499|  1.29k|	if (!obj) {
  ------------------
  |  Branch (499:6): [True: 0, False: 1.29k]
  ------------------
  500|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  501|      0|	}
  502|       |
  503|  1.29k|	memcpy(obj, in_obj, sizeof(*obj));
  504|  1.29k|	obj->type = type;
  505|       |
  506|  1.29k|	switch (type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  1.29k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  507|    693|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|    693|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (507:2): [True: 693, False: 599]
  ------------------
  508|    693|		df_type  = SC_PKCS15_AODF;
  ------------------
  |  |  496|    693|#define SC_PKCS15_AODF			8
  ------------------
  509|    693|		data_len = sizeof(struct sc_pkcs15_auth_info);
  510|    693|		break;
  511|    285|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|    285|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (511:2): [True: 285, False: 1.00k]
  ------------------
  512|    285|		df_type  = SC_PKCS15_PRKDF;
  ------------------
  |  |  488|    285|#define SC_PKCS15_PRKDF			0
  ------------------
  513|    285|		data_len = sizeof(struct sc_pkcs15_prkey_info);
  514|    285|		break;
  515|      9|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      9|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (515:2): [True: 9, False: 1.28k]
  ------------------
  516|      9|		df_type = SC_PKCS15_PUKDF;
  ------------------
  |  |  489|      9|#define SC_PKCS15_PUKDF			1
  ------------------
  517|      9|		data_len = sizeof(struct sc_pkcs15_pubkey_info);
  518|      9|		break;
  519|    243|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|    243|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (519:2): [True: 243, False: 1.04k]
  ------------------
  520|    243|		df_type = SC_PKCS15_CDF;
  ------------------
  |  |  492|    243|#define SC_PKCS15_CDF			4
  ------------------
  521|    243|		data_len = sizeof(struct sc_pkcs15_cert_info);
  522|    243|		break;
  523|     62|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|     62|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (523:2): [True: 62, False: 1.23k]
  ------------------
  524|     62|		df_type = SC_PKCS15_DODF;
  ------------------
  |  |  495|     62|#define SC_PKCS15_DODF			7
  ------------------
  525|     62|		data_len = sizeof(struct sc_pkcs15_data_info);
  526|     62|		break;
  527|      0|	default:
  ------------------
  |  Branch (527:2): [True: 0, False: 1.29k]
  ------------------
  528|      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__
  |  |  ------------------
  ------------------
  529|      0|		free(obj);
  530|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  531|  1.29k|	}
  532|       |
  533|  1.29k|	obj->data = calloc(1, data_len);
  534|  1.29k|	if (obj->data == NULL) {
  ------------------
  |  Branch (534:6): [True: 0, False: 1.29k]
  ------------------
  535|      0|		free(obj);
  536|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  537|      0|	}
  538|  1.29k|	memcpy(obj->data, data, data_len);
  539|       |
  540|  1.29k|	obj->df = sc_pkcs15emu_get_df(p15card, df_type);
  541|  1.29k|	sc_pkcs15_add_object(p15card, obj);
  542|       |
  543|  1.29k|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.29k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.29k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.29k|	int _ret = r; \
  |  |  |  |  155|  1.29k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.29k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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: 1.29k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.29k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.29k|	return _ret; \
  |  |  |  |  163|  1.29k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|  1.29k|}
pkcs15-syn.c:sc_pkcs15emu_get_df:
  338|  1.29k|{
  339|  1.29k|	sc_pkcs15_df_t	*df;
  340|  1.29k|	sc_file_t	*file;
  341|  1.29k|	int		created = 0;
  342|       |
  343|  2.18k|	while (1) {
  ------------------
  |  Branch (343:9): [True: 2.18k, Folded]
  ------------------
  344|  3.63k|		for (df = p15card->df_list; df; df = df->next) {
  ------------------
  |  Branch (344:31): [True: 2.75k, False: 888]
  ------------------
  345|  2.75k|			if (df->type == type) {
  ------------------
  |  Branch (345:8): [True: 1.29k, False: 1.45k]
  ------------------
  346|  1.29k|				if (created)
  ------------------
  |  Branch (346:9): [True: 888, False: 404]
  ------------------
  347|    888|					df->enumerated = 1;
  348|  1.29k|				return df;
  349|  1.29k|			}
  350|  2.75k|		}
  351|       |
  352|    888|		if (created != 0)
  ------------------
  |  Branch (352:7): [True: 0, False: 888]
  ------------------
  353|      0|			return NULL;
  354|       |
  355|    888|		file = sc_file_new();
  356|    888|		if (!file)
  ------------------
  |  Branch (356:7): [True: 0, False: 888]
  ------------------
  357|      0|			return NULL;
  358|    888|		sc_format_path("11001101", &file->path);
  359|    888|		sc_pkcs15_add_df(p15card, type, &file->path);
  360|    888|		sc_file_free(file);
  361|    888|		created++;
  362|    888|	}
  363|  1.29k|}

sc_pkcs15emu_tcos_init_ex:
  522|  3.39k|){
  523|  3.39k|	sc_card_t         *card = p15card->card;
  524|  3.39k|	sc_context_t      *ctx = p15card->card->ctx;
  525|  3.39k|	sc_serial_number_t serialnr;
  526|  3.39k|	char               serial[30];
  527|  3.39k|	int r;
  528|       |
  529|       |	/* check if we have the correct card OS unless SC_PKCS15EMU_FLAGS_NO_CHECK */
  530|  3.39k|	if (card->type!=SC_CARD_TYPE_TCOS_V2 && card->type!=SC_CARD_TYPE_TCOS_V3) return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|  3.39k|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  |  Branch (530:6): [True: 3.39k, False: 0]
  |  Branch (530:42): [True: 3.39k, False: 0]
  ------------------
  531|       |
  532|       |	/* get the card serial number */
  533|      0|	r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serialnr);
  534|      0|	if (r < 0) {
  ------------------
  |  Branch (534:6): [True: 0, False: 0]
  ------------------
  535|      0|		sc_log(ctx, "unable to get ICCSN");
  ------------------
  |  |   71|      0|#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|      0|		return SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|      0|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
  537|      0|	}
  538|      0|	r = sc_bin_to_hex(serialnr.value, serialnr.len, serial, sizeof(serial), 0);
  539|      0|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (539:6): [True: 0, False: 0]
  ------------------
  540|      0|		sc_log(ctx, "serial number invalid");
  ------------------
  |  |   71|      0|#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|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  542|      0|	}
  543|       |
  544|      0|	serial[19] = '\0';
  545|      0|	set_string(&p15card->tokeninfo->serial_number, serial);
  546|       |
  547|      0|	if(!detect_netkey(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (547:5): [True: 0, False: 0]
  ------------------
  548|      0|	if(!detect_idkey(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (548:5): [True: 0, False: 0]
  ------------------
  549|      0|	if(!detect_unicard(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (549:5): [True: 0, False: 0]
  ------------------
  550|      0|	if(!detect_signtrust(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (550:5): [True: 0, False: 0]
  ------------------
  551|      0|	if(!detect_datev(p15card)) return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (551:5): [True: 0, False: 0]
  ------------------
  552|       |
  553|      0|	sc_pkcs15_card_clear(p15card);
  554|      0|	return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  555|      0|}

sc_pkcs15_parse_tokeninfo:
  145|  1.20k|{
  146|  1.20k|	int r;
  147|  1.20k|	size_t ii;
  148|  1.20k|	u8 serial[128];
  149|  1.20k|	size_t serial_len = sizeof(serial);
  150|  1.20k|	u8 mnfid[SC_PKCS15_MAX_LABEL_SIZE];
  151|  1.20k|	size_t mnfid_len  = sizeof(mnfid) - 1;
  152|  1.20k|	u8 label[SC_PKCS15_MAX_LABEL_SIZE];
  153|  1.20k|	size_t label_len = sizeof(label) - 1;
  154|  1.20k|	u8 last_update[32], profile_indication[SC_PKCS15_MAX_LABEL_SIZE];
  155|  1.20k|	size_t lupdate_len = sizeof(last_update) - 1, pi_len = sizeof(profile_indication) - 1;
  156|  1.20k|	size_t flags_len   = sizeof(ti->flags);
  157|  1.20k|	u8 preferred_language[3];
  158|  1.20k|	size_t lang_length = sizeof(preferred_language);
  159|  1.20k|	struct sc_asn1_entry asn1_supported_algorithms[SC_MAX_SUPPORTED_ALGORITHMS + 1],
  160|  1.20k|			asn1_algo_infos[SC_MAX_SUPPORTED_ALGORITHMS][7],
  161|  1.20k|			asn1_algo_infos_parameters[SC_MAX_SUPPORTED_ALGORITHMS][3];
  162|  1.20k|	size_t reference_len = sizeof(ti->supported_algos[0].reference);
  163|  1.20k|	size_t mechanism_len = sizeof(ti->supported_algos[0].mechanism);
  164|  1.20k|	size_t parameter_len = sizeof(ti->supported_algos[0].parameters);
  165|  1.20k|	size_t operations_len = sizeof(ti->supported_algos[0].operations);
  166|  1.20k|	size_t algo_ref_len = sizeof(ti->supported_algos[0].algo_ref);
  167|       |
  168|  1.20k|	struct sc_asn1_entry asn1_last_update[C_ASN1_LAST_UPDATE_SIZE];
  169|  1.20k|	struct sc_asn1_entry asn1_profile_indication[C_ASN1_PROFILE_INDICATION_SIZE];
  170|  1.20k|	struct sc_asn1_entry asn1_toki_attrs[C_ASN1_TOKI_ATTRS_SIZE], asn1_tokeninfo[3], asn1_twlabel[3];
  171|       |
  172|  1.20k|	memset(last_update, 0, sizeof(last_update));
  173|  1.20k|	memset(label, 0, sizeof(label));
  174|  1.20k|	memset(profile_indication, 0, sizeof(profile_indication));
  175|  1.20k|	memset(mnfid, 0, sizeof(mnfid));
  176|       |
  177|  1.20k|	sc_copy_asn1_entry(c_asn1_twlabel, asn1_twlabel);
  178|  1.20k|	sc_copy_asn1_entry(c_asn1_toki_attrs, asn1_toki_attrs);
  179|  1.20k|	sc_copy_asn1_entry(c_asn1_tokeninfo, asn1_tokeninfo);
  180|  1.20k|	sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
  181|  1.20k|	sc_format_asn1_entry(asn1_twlabel, label, &label_len, 0);
  182|  1.20k|	sc_copy_asn1_entry(c_asn1_profile_indication, asn1_profile_indication);
  183|       |
  184|  20.5k|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS; ii++) {
  ------------------
  |  |   61|  20.5k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (184:13): [True: 19.3k, False: 1.20k]
  ------------------
  185|  19.3k|		sc_copy_asn1_entry(c_asn1_algorithm_info, asn1_algo_infos[ii]);
  186|  19.3k|		sc_copy_asn1_entry(c_asn1_algorithm_info_parameters,
  187|  19.3k|			asn1_algo_infos_parameters[ii]);
  188|  19.3k|	}
  189|  1.20k|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  190|       |
  191|  20.5k|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS; ii++)   {
  ------------------
  |  |   61|  20.5k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (191:13): [True: 19.3k, False: 1.20k]
  ------------------
  192|  19.3k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 0, &ti->supported_algos[ii].reference, &reference_len, 0);
  193|  19.3k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 1, &ti->supported_algos[ii].mechanism, &mechanism_len, 0);
  194|  19.3k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 2,
  195|  19.3k|			asn1_algo_infos_parameters[ii], NULL, 0);
  196|  19.3k|		sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 0,
  197|  19.3k|			NULL, NULL, 0);
  198|  19.3k|		sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 1,
  199|  19.3k|			&ti->supported_algos[ii].parameters, &parameter_len, 0);
  200|  19.3k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 3, &ti->supported_algos[ii].operations, &operations_len, 0);
  201|  19.3k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 4, &ti->supported_algos[ii].algo_id, NULL, 1);
  202|  19.3k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 5, &ti->supported_algos[ii].algo_ref, &algo_ref_len, 0);
  203|  19.3k|		sc_format_asn1_entry(asn1_supported_algorithms + ii, asn1_algo_infos[ii], NULL, 0);
  204|  19.3k|	}
  205|       |
  206|  1.20k|	sc_format_asn1_entry(asn1_last_update + 0, last_update, &lupdate_len, 0);
  207|  1.20k|	sc_format_asn1_entry(asn1_last_update + 1, &ti->last_update.path, NULL, 0);
  208|       |
  209|  1.20k|	sc_format_asn1_entry(asn1_profile_indication + 0, &ti->profile_indication.oid, NULL, 0);
  210|  1.20k|	sc_format_asn1_entry(asn1_profile_indication + 1, profile_indication, &pi_len, 0);
  211|       |
  212|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 0, &ti->version, NULL, 0);
  213|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 1, serial, &serial_len, 0);
  214|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 2, mnfid, &mnfid_len, 0);
  215|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 3, label, &label_len, 0);
  216|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 4, asn1_twlabel, NULL, 0);
  217|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 5, &ti->flags, &flags_len, 0);
  218|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 6, &ti->seInfo, &ti->num_seInfo, 0);
  219|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 7, NULL, NULL, 0);
  220|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 8, asn1_supported_algorithms, NULL, 0);
  221|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 9, NULL, NULL, 0);
  222|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 10, NULL, NULL, 0);
  223|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 11, asn1_last_update, NULL, 0);
  224|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 12, preferred_language, &lang_length, 0);
  225|  1.20k|	sc_format_asn1_entry(asn1_toki_attrs + 13, asn1_profile_indication, NULL, 0);
  226|  1.20k|	sc_format_asn1_entry(asn1_tokeninfo, asn1_toki_attrs, NULL, 0);
  227|       |
  228|  1.20k|	r = sc_asn1_decode(ctx, asn1_tokeninfo, buf, blen, NULL, NULL);
  229|  1.20k|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|  1.20k|#define SC_SUCCESS				0
  ------------------
  |  Branch (229:6): [True: 69, False: 1.13k]
  ------------------
  230|       |		/* The decoding could have allocated something we need to free */
  231|     69|		sc_pkcs15_clear_tokeninfo(ti);
  232|     69|		LOG_TEST_RET(ctx, r, "ASN.1 parsing of EF(TokenInfo) failed");
  ------------------
  |  |  174|     69|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     69|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     69|	int _ret = (r); \
  |  |  |  |  168|     69|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 69, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     69|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|     69|	}
  234|       |
  235|  1.13k|	if (asn1_toki_attrs[1].flags & SC_ASN1_PRESENT && serial_len > 0)   {
  ------------------
  |  |  147|  2.27k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (235:6): [True: 1.06k, False: 73]
  |  Branch (235:52): [True: 1.06k, False: 0]
  ------------------
  236|  1.06k|		free(ti->serial_number);
  237|  1.06k|		ti->serial_number = malloc(serial_len * 2 + 1);
  238|  1.06k|		if (ti->serial_number == NULL)
  ------------------
  |  Branch (238:7): [True: 0, False: 1.06k]
  ------------------
  239|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  240|  1.06k|		sc_bin_to_hex(serial, serial_len, ti->serial_number, serial_len * 2 + 1, 0);
  241|  1.06k|		sc_log(ctx, "TokenInfo.serialNunmber '%s'", ti->serial_number);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  242|  1.06k|	}
  243|       |
  244|  1.13k|	if (ti->manufacturer_id == NULL) {
  ------------------
  |  Branch (244:6): [True: 1.13k, False: 0]
  ------------------
  245|  1.13k|		if (asn1_toki_attrs[2].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|  1.13k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (245:7): [True: 1.05k, False: 81]
  ------------------
  246|  1.05k|			ti->manufacturer_id = strdup((char *) mnfid);
  247|     81|		else
  248|     81|			ti->manufacturer_id = strdup("(unknown)");
  249|  1.13k|		if (ti->manufacturer_id == NULL)
  ------------------
  |  Branch (249:7): [True: 0, False: 1.13k]
  ------------------
  250|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  251|  1.13k|	}
  252|  1.13k|	if (ti->label == NULL) {
  ------------------
  |  Branch (252:6): [True: 1.13k, False: 0]
  ------------------
  253|  1.13k|		if (asn1_toki_attrs[3].flags & SC_ASN1_PRESENT ||
  ------------------
  |  |  147|  2.27k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (253:7): [True: 873, False: 266]
  ------------------
  254|    266|		    asn1_toki_attrs[4].flags & SC_ASN1_PRESENT)
  ------------------
  |  |  147|    266|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (254:7): [True: 0, False: 266]
  ------------------
  255|    873|			ti->label = strdup((char *) label);
  256|    266|		else
  257|    266|			ti->label = strdup("(unknown)");
  258|  1.13k|		if (ti->label == NULL)
  ------------------
  |  Branch (258:7): [True: 0, False: 1.13k]
  ------------------
  259|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  260|  1.13k|	}
  261|  1.13k|	if (asn1_toki_attrs[11].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|  1.13k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (261:6): [True: 169, False: 970]
  ------------------
  262|    169|		if (asn1_last_update[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|    169|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (262:7): [True: 26, False: 143]
  ------------------
  263|     26|			sc_log(ctx, "LastUpdate.generalizedTime present");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  264|     26|			ti->last_update.gtime = strdup((char *)last_update);
  265|     26|			if (ti->last_update.gtime == NULL)
  ------------------
  |  Branch (265:8): [True: 0, False: 26]
  ------------------
  266|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  267|     26|		}
  268|    143|		else if (asn1_last_update[1].flags & SC_ASN1_PRESENT)  {
  ------------------
  |  |  147|    143|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (268:12): [True: 103, False: 40]
  ------------------
  269|    103|			sc_log(ctx, "LastUpdate.referencedTime present");
  ------------------
  |  |   71|    103|#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|    103|		}
  271|    169|	}
  272|  1.13k|	if (asn1_toki_attrs[12].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|  1.13k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (272:6): [True: 3, False: 1.13k]
  ------------------
  273|      3|		preferred_language[2] = 0;
  274|      3|		ti->preferred_language = strdup((char *)preferred_language);
  275|      3|		if (ti->preferred_language == NULL)
  ------------------
  |  Branch (275:7): [True: 0, False: 3]
  ------------------
  276|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  277|      3|	}
  278|       |
  279|  1.13k|	sc_init_oid(&ti->profile_indication.oid);
  280|  1.13k|	if (asn1_toki_attrs[13].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|  1.13k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (280:6): [True: 15, False: 1.12k]
  ------------------
  281|     15|		if (asn1_profile_indication[0].flags & SC_ASN1_PRESENT)   {
  ------------------
  |  |  147|     15|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (281:7): [True: 0, False: 15]
  ------------------
  282|      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__
  |  |  ------------------
  ------------------
  283|      0|		}
  284|     15|		else if (asn1_profile_indication[1].flags & SC_ASN1_PRESENT)  {
  ------------------
  |  |  147|     15|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (284:12): [True: 13, False: 2]
  ------------------
  285|     13|			sc_log(ctx, "ProfileIndication.name present");
  ------------------
  |  |   71|     13|#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|     13|			ti->profile_indication.name = strdup((char *)profile_indication);
  287|     13|			if (ti->profile_indication.name == NULL)
  ------------------
  |  Branch (287:8): [True: 0, False: 13]
  ------------------
  288|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  289|     13|		}
  290|     15|	}
  291|       |
  292|  1.13k|	sc_log(ctx, "LastUpdate.path '%s'", sc_print_path(&ti->last_update.path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  293|  1.13k|	sc_log(ctx, "ProfileIndication.name '%s'",  ti->profile_indication.name);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  294|  1.13k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.13k|#define SC_SUCCESS				0
  ------------------
  295|  1.13k|}
sc_pkcs15_encode_tokeninfo:
  301|    435|{
  302|    435|	int r, ii;
  303|    435|	size_t serial_len, mnfid_len, label_len, flags_len, last_upd_len, pi_len;
  304|       |
  305|    435|	struct sc_asn1_entry asn1_toki_attrs[C_ASN1_TOKI_ATTRS_SIZE];
  306|    435|	struct sc_asn1_entry asn1_tokeninfo[2];
  307|    435|	struct sc_asn1_entry asn1_supported_algorithms[SC_MAX_SUPPORTED_ALGORITHMS + 1],
  308|    435|			asn1_algo_infos[SC_MAX_SUPPORTED_ALGORITHMS][7],
  309|    435|			asn1_algo_infos_parameters[SC_MAX_SUPPORTED_ALGORITHMS][3];
  310|    435|	size_t reference_len = sizeof(ti->supported_algos[0].reference);
  311|    435|	size_t mechanism_len = sizeof(ti->supported_algos[0].mechanism);
  312|    435|	size_t parameter_len = sizeof(ti->supported_algos[0].parameters);
  313|    435|	size_t operations_len = sizeof(ti->supported_algos[0].operations);
  314|    435|	size_t algo_ref_len = sizeof(ti->supported_algos[0].algo_ref);
  315|    435|	struct sc_asn1_entry asn1_last_update[C_ASN1_LAST_UPDATE_SIZE];
  316|    435|	struct sc_asn1_entry asn1_profile_indication[C_ASN1_PROFILE_INDICATION_SIZE];
  317|    435|	u8 serial[128];
  318|       |
  319|    435|	sc_copy_asn1_entry(c_asn1_toki_attrs, asn1_toki_attrs);
  320|    435|	sc_copy_asn1_entry(c_asn1_tokeninfo, asn1_tokeninfo);
  321|    435|	sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
  322|    435|	sc_copy_asn1_entry(c_asn1_profile_indication, asn1_profile_indication);
  323|       |
  324|  1.44k|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS && ti->supported_algos[ii].reference; ii++) {
  ------------------
  |  |   61|  2.89k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (324:13): [True: 1.44k, False: 0]
  |  Branch (324:47): [True: 1.01k, False: 435]
  ------------------
  325|  1.01k|		sc_copy_asn1_entry(c_asn1_algorithm_info, asn1_algo_infos[ii]);
  326|  1.01k|		sc_copy_asn1_entry(c_asn1_algorithm_info_parameters,
  327|  1.01k|			asn1_algo_infos_parameters[ii]);
  328|  1.01k|	}
  329|    435|	sc_copy_asn1_entry(c_asn1_supported_algorithms, asn1_supported_algorithms);
  330|       |
  331|  1.44k|	for (ii=0; ii<SC_MAX_SUPPORTED_ALGORITHMS && ti->supported_algos[ii].reference; ii++)   {
  ------------------
  |  |   61|  2.89k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (331:13): [True: 1.44k, False: 0]
  |  Branch (331:47): [True: 1.01k, False: 435]
  ------------------
  332|  1.01k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 0, &ti->supported_algos[ii].reference, &reference_len, 1);
  333|  1.01k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 1, &ti->supported_algos[ii].mechanism, &mechanism_len, 1);
  334|  1.01k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 2,
  335|  1.01k|			asn1_algo_infos_parameters[ii], NULL, 1);
  336|  1.01k|		if (!sc_valid_oid(&ti->supported_algos[ii].parameters)) {
  ------------------
  |  Branch (336:7): [True: 1.00k, False: 5]
  ------------------
  337|  1.00k|			sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 0,
  338|  1.00k|				NULL, NULL, 1);
  339|  1.00k|		}
  340|      5|		else {
  341|      5|			sc_format_asn1_entry(asn1_algo_infos_parameters[ii] + 1,
  342|      5|				&ti->supported_algos[ii].parameters, &parameter_len, 0);
  343|      5|		}
  344|  1.01k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 3, &ti->supported_algos[ii].operations, &operations_len, 1);
  345|  1.01k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 4, &ti->supported_algos[ii].algo_id, NULL, 1);
  346|  1.01k|		sc_format_asn1_entry(asn1_algo_infos[ii] + 5, &ti->supported_algos[ii].algo_ref, &algo_ref_len, 1);
  347|  1.01k|		sc_format_asn1_entry(asn1_supported_algorithms + ii, asn1_algo_infos[ii], NULL, 1);
  348|  1.01k|	}
  349|       |
  350|    435|	sc_format_asn1_entry(asn1_toki_attrs + 0, &ti->version, NULL, 1);
  351|    435|	if (ti->serial_number != NULL) {
  ------------------
  |  Branch (351:6): [True: 426, False: 9]
  ------------------
  352|    426|		serial_len = 0;
  353|    426|		if (strlen(ti->serial_number)/2 > sizeof(serial))
  ------------------
  |  Branch (353:7): [True: 0, False: 426]
  ------------------
  354|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  355|    426|		serial_len = sizeof(serial);
  356|    426|		if (sc_hex_to_bin(ti->serial_number, serial, &serial_len) < 0)
  ------------------
  |  Branch (356:7): [True: 0, False: 426]
  ------------------
  357|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  358|    426|		sc_format_asn1_entry(asn1_toki_attrs + 1, serial, &serial_len, 1);
  359|    426|	}
  360|      9|	else   {
  361|      9|		sc_format_asn1_entry(asn1_toki_attrs + 1, NULL, NULL, 0);
  362|      9|	}
  363|       |
  364|    435|	if (ti->manufacturer_id != NULL) {
  ------------------
  |  Branch (364:6): [True: 435, False: 0]
  ------------------
  365|    435|		mnfid_len = strlen(ti->manufacturer_id);
  366|    435|		sc_format_asn1_entry(asn1_toki_attrs + 2, ti->manufacturer_id, &mnfid_len, 1);
  367|    435|	}
  368|      0|	else    {
  369|      0|		sc_format_asn1_entry(asn1_toki_attrs + 2, NULL, NULL, 0);
  370|      0|	}
  371|       |
  372|    435|	if (ti->label != NULL) {
  ------------------
  |  Branch (372:6): [True: 435, False: 0]
  ------------------
  373|    435|		label_len = strlen(ti->label);
  374|    435|		sc_format_asn1_entry(asn1_toki_attrs + 3, ti->label, &label_len, 1);
  375|    435|	}
  376|      0|	else   {
  377|      0|		sc_format_asn1_entry(asn1_toki_attrs + 3, NULL, NULL, 0);
  378|      0|	}
  379|       |
  380|    435|	if (ti->flags) {
  ------------------
  |  Branch (380:6): [True: 340, False: 95]
  ------------------
  381|    340|		flags_len = sizeof(ti->flags);
  382|    340|		sc_format_asn1_entry(asn1_toki_attrs + 5, &ti->flags, &flags_len, 1);
  383|    340|	}
  384|     95|	else   {
  385|     95|		sc_format_asn1_entry(asn1_toki_attrs + 5, NULL, NULL, 0);
  386|     95|	}
  387|       |
  388|    435|	if (ti->num_seInfo)
  ------------------
  |  Branch (388:6): [True: 16, False: 419]
  ------------------
  389|     16|		sc_format_asn1_entry(asn1_toki_attrs + 6, ti->seInfo, &ti->num_seInfo, 1);
  390|    419|	else
  391|    419|		sc_format_asn1_entry(asn1_toki_attrs + 6, NULL, NULL, 0);
  392|       |
  393|    435|	sc_format_asn1_entry(asn1_toki_attrs + 7, NULL, NULL, 0);
  394|       |
  395|    435|	if (ti->supported_algos[0].reference)
  ------------------
  |  Branch (395:6): [True: 385, False: 50]
  ------------------
  396|    385|		sc_format_asn1_entry(asn1_toki_attrs + 8, asn1_supported_algorithms, NULL, 1);
  397|     50|	else
  398|     50|		sc_format_asn1_entry(asn1_toki_attrs + 8, NULL, NULL, 0);
  399|       |
  400|    435|	sc_format_asn1_entry(asn1_toki_attrs + 9, NULL, NULL, 0);
  401|    435|	sc_format_asn1_entry(asn1_toki_attrs + 10, NULL, NULL, 0);
  402|       |
  403|    435|	if (ti->last_update.path.len) {
  ------------------
  |  Branch (403:6): [True: 0, False: 435]
  ------------------
  404|      0|		sc_format_asn1_entry(asn1_last_update + 0, &ti->last_update.path, NULL, 1);
  405|      0|		sc_format_asn1_entry(asn1_toki_attrs + 11, asn1_last_update, NULL, 1);
  406|      0|	}
  407|    435|	else if (ti->last_update.gtime != NULL) {
  ------------------
  |  Branch (407:11): [True: 435, False: 0]
  ------------------
  408|    435|		last_upd_len = strlen(ti->last_update.gtime);
  409|    435|		sc_format_asn1_entry(asn1_last_update + 0, ti->last_update.gtime, &last_upd_len, 1);
  410|    435|		sc_format_asn1_entry(asn1_toki_attrs + 11, asn1_last_update, NULL, 1);
  411|    435|	}
  412|      0|	else   {
  413|      0|		sc_format_asn1_entry(asn1_toki_attrs + 11, NULL, NULL, 0);
  414|      0|	}
  415|    435|	sc_format_asn1_entry(asn1_toki_attrs + 12, NULL, NULL, 0);
  416|       |
  417|    435|	if (sc_valid_oid(&ti->profile_indication.oid))   {
  ------------------
  |  Branch (417:6): [True: 0, False: 435]
  ------------------
  418|      0|		sc_format_asn1_entry(asn1_profile_indication + 0, &ti->profile_indication.oid, NULL, 1);
  419|      0|		sc_format_asn1_entry(asn1_toki_attrs + 13, asn1_profile_indication, NULL, 1);
  420|      0|	}
  421|    435|	else if (ti->profile_indication.name)   {
  ------------------
  |  Branch (421:11): [True: 1, False: 434]
  ------------------
  422|      1|		pi_len = strlen(ti->profile_indication.name);
  423|      1|		sc_format_asn1_entry(asn1_profile_indication + 1, ti->profile_indication.name, &pi_len, 1);
  424|      1|		sc_format_asn1_entry(asn1_toki_attrs + 13, asn1_profile_indication, NULL, 1);
  425|      1|	}
  426|    434|	else    {
  427|    434|		sc_format_asn1_entry(asn1_toki_attrs + 13, NULL, NULL, 0);
  428|    434|	}
  429|       |
  430|    435|	sc_format_asn1_entry(asn1_tokeninfo, asn1_toki_attrs, NULL, 1);
  431|       |
  432|    435|	r = sc_asn1_encode(ctx, asn1_tokeninfo, buf, buflen);
  433|    435|	LOG_TEST_RET(ctx, r, "sc_asn1_encode() failed");
  ------------------
  |  |  174|    435|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    435|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    435|	int _ret = (r); \
  |  |  |  |  168|    435|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 100, False: 335]
  |  |  |  |  ------------------
  |  |  |  |  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|    435|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 335]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|       |
  435|    335|	return SC_SUCCESS;
  ------------------
  |  |   28|    335|#define SC_SUCCESS				0
  ------------------
  436|    435|}
sc_pkcs15_get_lastupdate:
  535|  60.5k|{
  536|  60.5k|	struct sc_context *ctx  = p15card->card->ctx;
  537|  60.5k|	struct sc_file *file = NULL;
  538|  60.5k|	struct sc_asn1_entry asn1_last_update[C_ASN1_LAST_UPDATE_SIZE];
  539|  60.5k|	unsigned char *content, last_update[32] = {0};
  540|  60.5k|	size_t lupdate_len = sizeof(last_update) - 1;
  541|  60.5k|	int r, content_len;
  542|  60.5k|	size_t size;
  543|       |
  544|  60.5k|	if (p15card->tokeninfo->last_update.gtime)
  ------------------
  |  Branch (544:6): [True: 4.91k, False: 55.6k]
  ------------------
  545|  4.91k|		goto done;
  546|       |
  547|  55.6k|	if (!p15card->tokeninfo->last_update.path.len)
  ------------------
  |  Branch (547:6): [True: 16.6k, False: 38.9k]
  ------------------
  548|  16.6k|		return NULL;
  549|       |
  550|  38.9k|	r = sc_select_file(p15card->card, &p15card->tokeninfo->last_update.path, &file);
  551|  38.9k|	if (r < 0)
  ------------------
  |  Branch (551:6): [True: 35.6k, False: 3.38k]
  ------------------
  552|  35.6k|		return NULL;
  553|       |
  554|  3.38k|	size = file->size ? file->size : 1024;
  ------------------
  |  Branch (554:9): [True: 1.50k, False: 1.88k]
  ------------------
  555|  3.38k|	sc_file_free(file);
  556|       |
  557|  3.38k|	content = calloc(1, size);
  558|  3.38k|	if (!content)
  ------------------
  |  Branch (558:6): [True: 0, False: 3.38k]
  ------------------
  559|      0|		return NULL;
  560|       |
  561|  3.38k|	r = sc_read_binary(p15card->card, 0, content, size, 0);
  562|  3.38k|	if (r < 0) {
  ------------------
  |  Branch (562:6): [True: 1.37k, False: 2.01k]
  ------------------
  563|  1.37k|		free(content);
  564|  1.37k|		return NULL;
  565|  1.37k|	}
  566|  2.01k|	content_len = r;
  567|       |
  568|  2.01k|	sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
  569|  2.01k|	sc_format_asn1_entry(asn1_last_update + 0, last_update, &lupdate_len, 0);
  570|       |
  571|  2.01k|	r = sc_asn1_decode(ctx, asn1_last_update, content, content_len, NULL, NULL);
  572|  2.01k|	free(content);
  573|  2.01k|	if (r < 0)
  ------------------
  |  Branch (573:6): [True: 89, False: 1.92k]
  ------------------
  574|     89|		return NULL;
  575|       |
  576|  1.92k|	if (asn1_last_update[0].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|  1.92k|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (576:6): [True: 1, False: 1.92k]
  ------------------
  577|      1|		p15card->tokeninfo->last_update.gtime = strdup((char *)last_update);
  578|      1|		if (!p15card->tokeninfo->last_update.gtime)
  ------------------
  |  Branch (578:7): [True: 0, False: 1]
  ------------------
  579|      0|			return NULL;
  580|      1|	}
  581|  6.84k|done:
  582|  6.84k|	sc_log(ctx, "lastUpdate.gtime '%s'", p15card->tokeninfo->last_update.gtime);
  ------------------
  |  |   71|  6.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__
  |  |  ------------------
  ------------------
  583|  6.84k|	return p15card->tokeninfo->last_update.gtime;
  584|  1.92k|}
sc_pkcs15_encode_odf:
  652|    929|{
  653|    929|	struct sc_path path;
  654|    929|	struct sc_asn1_entry asn1_obj_or_path[] = {
  655|    929|		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  174|    929|#define SC_ASN1_PATH			256
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  141|    929|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  162|    929|#define SC_ASN1_SEQUENCE                16
  ------------------
  656|    929|		{ NULL, 0, 0, 0, NULL, NULL }
  657|    929|	};
  658|    929|	struct sc_asn1_entry *asn1_paths = NULL;
  659|    929|	struct sc_asn1_entry *asn1_odf = NULL;
  660|    929|	int df_count = 0, r, c = 0;
  661|    929|	const int nr_indexes = sizeof(odf_indexes)/sizeof(odf_indexes[0]);
  662|    929|	struct sc_pkcs15_df *df;
  663|       |
  664|    929|	df = p15card->df_list;
  665|  4.24k|	while (df != NULL) {
  ------------------
  |  Branch (665:9): [True: 3.31k, False: 929]
  ------------------
  666|  3.31k|		df_count++;
  667|  3.31k|		df = df->next;
  668|  3.31k|	};
  669|    929|	if (df_count == 0)
  ------------------
  |  Branch (669:6): [True: 0, False: 929]
  ------------------
  670|    929|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "No DF's 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  671|       |
  672|    929|	asn1_odf = malloc(sizeof(struct sc_asn1_entry) * (df_count + 1));
  673|    929|	if (asn1_odf == NULL) {
  ------------------
  |  Branch (673:6): [True: 0, False: 929]
  ------------------
  674|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  675|      0|		goto err;
  676|      0|	}
  677|    929|	asn1_paths = malloc(sizeof(struct sc_asn1_entry) * (df_count * 2));
  678|    929|	if (asn1_paths == NULL) {
  ------------------
  |  Branch (678:6): [True: 0, False: 929]
  ------------------
  679|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  680|      0|		goto err;
  681|      0|	}
  682|  4.24k|	for (df = p15card->df_list; df != NULL; df = df->next) {
  ------------------
  |  Branch (682:30): [True: 3.31k, False: 929]
  ------------------
  683|  3.31k|		int j, type = -1;
  684|       |
  685|  11.7k|		for (j = 0; j < nr_indexes; j++)
  ------------------
  |  Branch (685:15): [True: 11.7k, False: 0]
  ------------------
  686|  11.7k|			if (odf_indexes[j] == df->type) {
  ------------------
  |  Branch (686:8): [True: 3.31k, False: 8.48k]
  ------------------
  687|  3.31k|				type = j;
  688|  3.31k|				break;
  689|  3.31k|			}
  690|  3.31k|		if (type == -1) {
  ------------------
  |  Branch (690:7): [True: 0, False: 3.31k]
  ------------------
  691|      0|			sc_log(ctx, "Unsupported DF 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__
  |  |  ------------------
  ------------------
  692|      0|			continue;
  693|      0|		}
  694|  3.31k|		asn1_odf[c] = c_asn1_odf[type];
  695|  3.31k|		sc_format_asn1_entry(asn1_odf + c, asn1_paths + 2*c, NULL, 1);
  696|  3.31k|		sc_copy_asn1_entry(asn1_obj_or_path, asn1_paths + 2*c);
  697|  3.31k|		sc_format_asn1_entry(asn1_paths + 2*c, &df->path, NULL, 1);
  698|  3.31k|		c++;
  699|  3.31k|	}
  700|    929|	asn1_odf[c].name = NULL;
  701|    929|	r = sc_asn1_encode(ctx, asn1_odf, buf, buflen);
  702|    929|err:
  703|    929|	if (asn1_paths != NULL)
  ------------------
  |  Branch (703:6): [True: 929, False: 0]
  ------------------
  704|    929|		free(asn1_paths);
  705|    929|	if (asn1_odf != NULL)
  ------------------
  |  Branch (705:6): [True: 929, False: 0]
  ------------------
  706|    929|		free(asn1_odf);
  707|    929|	return r;
  708|    929|}
sc_pkcs15_card_new:
  713|  10.6k|{
  714|  10.6k|	struct sc_pkcs15_card *p15card;
  715|       |
  716|  10.6k|	p15card = calloc(1, sizeof(struct sc_pkcs15_card));
  717|  10.6k|	if (p15card == NULL)
  ------------------
  |  Branch (717:6): [True: 0, False: 10.6k]
  ------------------
  718|      0|		return NULL;
  719|       |
  720|  10.6k|	p15card->tokeninfo = calloc(1, sizeof(struct sc_pkcs15_tokeninfo));
  721|  10.6k|	if (p15card->tokeninfo == NULL) {
  ------------------
  |  Branch (721:6): [True: 0, False: 10.6k]
  ------------------
  722|      0|		free(p15card);
  723|      0|		return NULL;
  724|      0|	}
  725|       |
  726|  10.6k|	p15card->magic = SC_PKCS15_CARD_MAGIC;
  ------------------
  |  |  519|  10.6k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  727|  10.6k|	return p15card;
  728|  10.6k|}
sc_pkcs15_tokeninfo_new:
  733|  3.39k|{
  734|  3.39k|	struct sc_pkcs15_tokeninfo *tokeninfo;
  735|       |
  736|  3.39k|	tokeninfo = calloc(1, sizeof(struct sc_pkcs15_tokeninfo));
  737|  3.39k|	if (tokeninfo == NULL) {
  ------------------
  |  Branch (737:6): [True: 0, False: 3.39k]
  ------------------
  738|      0|		return NULL;
  739|      0|	}
  740|       |
  741|  3.39k|	sc_init_oid(&tokeninfo->profile_indication.oid);
  742|       |
  743|  3.39k|	return tokeninfo;
  744|  3.39k|}
sc_pkcs15_free_tokeninfo:
  775|  14.7k|{
  776|  14.7k|	if (!tokeninfo)
  ------------------
  |  Branch (776:6): [True: 727, False: 14.0k]
  ------------------
  777|    727|		return;
  778|       |
  779|  14.0k|	sc_pkcs15_clear_tokeninfo(tokeninfo);
  780|  14.0k|	free(tokeninfo);
  781|  14.0k|}
sc_pkcs15_free_app:
  785|  26.4k|{
  786|  26.4k|	if (p15card && p15card->app) {
  ------------------
  |  Branch (786:6): [True: 26.4k, False: 0]
  |  Branch (786:17): [True: 327, False: 26.1k]
  ------------------
  787|    327|		free(p15card->app->label);
  788|    327|		free(p15card->app->ddo.value);
  789|    327|		free(p15card->app);
  790|       |		p15card->app = NULL;
  791|    327|	}
  792|  26.4k|}
sc_pkcs15_card_free:
  797|  10.6k|{
  798|  10.6k|	if (p15card == NULL || p15card->magic != SC_PKCS15_CARD_MAGIC)
  ------------------
  |  |  519|  10.6k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  |  Branch (798:6): [True: 0, False: 10.6k]
  |  Branch (798:25): [True: 0, False: 10.6k]
  ------------------
  799|      0|		return;
  800|       |
  801|  10.6k|	if (p15card->ops.clear)
  ------------------
  |  Branch (801:6): [True: 471, False: 10.1k]
  ------------------
  802|    471|		p15card->ops.clear(p15card);
  803|       |
  804|       |	/* For more complicated MD data a dedicated release procedure
  805|       |	 * has to be implemented. */
  806|  10.6k|	if (p15card->md_data)
  ------------------
  |  Branch (806:6): [True: 0, False: 10.6k]
  ------------------
  807|      0|		free(p15card->md_data);
  808|       |
  809|  10.6k|	sc_pkcs15_free_app(p15card);
  810|  10.6k|	sc_pkcs15_remove_objects(p15card);
  811|  10.6k|	sc_pkcs15_remove_dfs(p15card);
  812|  10.6k|	sc_pkcs15_free_unusedspace(p15card);
  813|  10.6k|	p15card->unusedspace_read = 0;
  814|       |
  815|  10.6k|	sc_file_free(p15card->file_app);
  816|  10.6k|	sc_file_free(p15card->file_tokeninfo);
  817|  10.6k|	sc_file_free(p15card->file_odf);
  818|  10.6k|	sc_file_free(p15card->file_unusedspace);
  819|       |
  820|  10.6k|	p15card->magic = 0;
  821|  10.6k|	sc_pkcs15_free_tokeninfo(p15card->tokeninfo);
  822|  10.6k|	sc_pkcs15_free_app(p15card);
  823|  10.6k|	free(p15card);
  824|  10.6k|}
sc_pkcs15_card_clear:
  829|  5.02k|{
  830|  5.02k|	if (p15card == NULL)
  ------------------
  |  Branch (830:6): [True: 0, False: 5.02k]
  ------------------
  831|      0|		return;
  832|       |
  833|  5.02k|	if (p15card->ops.clear)
  ------------------
  |  Branch (833:6): [True: 455, False: 4.56k]
  ------------------
  834|    455|		p15card->ops.clear(p15card);
  835|       |
  836|  5.02k|	p15card->flags = 0;
  837|  5.02k|	p15card->tokeninfo->version = 0;
  838|  5.02k|	p15card->tokeninfo->flags   = 0;
  839|       |
  840|  5.02k|	sc_pkcs15_remove_objects(p15card);
  841|  5.02k|	sc_pkcs15_remove_dfs(p15card);
  842|       |
  843|  5.02k|	p15card->df_list = NULL;
  844|  5.02k|	sc_file_free(p15card->file_app);
  845|  5.02k|	p15card->file_app = NULL;
  846|  5.02k|	sc_file_free(p15card->file_tokeninfo);
  847|  5.02k|	p15card->file_tokeninfo = NULL;
  848|  5.02k|	sc_file_free(p15card->file_odf);
  849|  5.02k|	p15card->file_odf = NULL;
  850|  5.02k|	sc_file_free(p15card->file_unusedspace);
  851|  5.02k|	p15card->file_unusedspace = NULL;
  852|       |
  853|  5.02k|	free(p15card->tokeninfo->label);
  854|  5.02k|	p15card->tokeninfo->label = NULL;
  855|  5.02k|	free(p15card->tokeninfo->serial_number);
  856|  5.02k|	p15card->tokeninfo->serial_number = NULL;
  857|  5.02k|	free(p15card->tokeninfo->manufacturer_id);
  858|  5.02k|	p15card->tokeninfo->manufacturer_id = NULL;
  859|  5.02k|	free(p15card->tokeninfo->last_update.gtime);
  860|  5.02k|	p15card->tokeninfo->last_update.gtime = NULL;
  861|  5.02k|	free(p15card->tokeninfo->preferred_language);
  862|  5.02k|	p15card->tokeninfo->preferred_language = NULL;
  863|  5.02k|	free(p15card->tokeninfo->profile_indication.name);
  864|  5.02k|	p15card->tokeninfo->profile_indication.name = NULL;
  865|  5.02k|	if (p15card->tokeninfo->seInfo != NULL) {
  ------------------
  |  Branch (865:6): [True: 0, False: 5.02k]
  ------------------
  866|      0|		size_t i;
  867|      0|		for (i = 0; i < p15card->tokeninfo->num_seInfo; i++)
  ------------------
  |  Branch (867:15): [True: 0, False: 0]
  ------------------
  868|      0|			free(p15card->tokeninfo->seInfo[i]);
  869|      0|		free(p15card->tokeninfo->seInfo);
  870|      0|		p15card->tokeninfo->seInfo     = NULL;
  871|      0|		p15card->tokeninfo->num_seInfo = 0;
  872|      0|	}
  873|       |
  874|  5.02k|	sc_pkcs15_free_app(p15card);
  875|  5.02k|}
sc_find_app:
  880|  5.31k|{
  881|  5.31k|	int ii;
  882|       |
  883|  5.31k|	if (card->app_count <= 0)
  ------------------
  |  Branch (883:6): [True: 5.15k, False: 159]
  ------------------
  884|  5.15k|		return NULL;
  885|       |
  886|    159|	if (!aid || !aid->len)
  ------------------
  |  Branch (886:6): [True: 159, False: 0]
  |  Branch (886:14): [True: 0, False: 0]
  ------------------
  887|    159|		return card->app[0];
  888|       |
  889|      0|	for (ii=0; ii < card->app_count; ii++) {
  ------------------
  |  Branch (889:13): [True: 0, False: 0]
  ------------------
  890|      0|		if (card->app[ii]->aid.len != aid->len)
  ------------------
  |  Branch (890:7): [True: 0, False: 0]
  ------------------
  891|      0|			continue;
  892|      0|		if (memcmp(card->app[ii]->aid.value, aid->value, aid->len))
  ------------------
  |  Branch (892:7): [True: 0, False: 0]
  ------------------
  893|      0|			continue;
  894|      0|		return card->app[ii];
  895|      0|	}
  896|      0|	return NULL;
  897|      0|}
sc_pkcs15_bind_internal:
  978|  5.31k|{
  979|  5.31k|	struct sc_path tmppath;
  980|  5.31k|	struct sc_card    *card = p15card->card;
  981|  5.31k|	struct sc_context *ctx  = card->ctx;
  982|  5.31k|	struct sc_pkcs15_tokeninfo tokeninfo;
  983|  5.31k|	struct sc_pkcs15_df *df;
  984|  5.31k|	const struct sc_app_info *info = NULL;
  985|  5.31k|	unsigned char *buf = NULL;
  986|  5.31k|	size_t len;
  987|  5.31k|	int    err, ok = 0;
  988|       |
  989|  5.31k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  5.31k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.31k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.31k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.31k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.31k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  990|       |	/* Enumerate apps now */
  991|  5.31k|	if (card->app_count < 0) {
  ------------------
  |  Branch (991:6): [True: 2.63k, False: 2.67k]
  ------------------
  992|  2.63k|		err = sc_enum_apps(card);
  993|  2.63k|		if (err != SC_SUCCESS)
  ------------------
  |  |   28|  2.63k|#define SC_SUCCESS				0
  ------------------
  |  Branch (993:7): [True: 2.57k, False: 65]
  ------------------
  994|  2.57k|			sc_log(ctx, "unable to enumerate apps: %s", sc_strerror(err));
  ------------------
  |  |   71|  2.57k|#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|  2.63k|	}
  996|  5.31k|	sc_file_free(p15card->file_app);
  997|  5.31k|	p15card->file_app = sc_file_new();
  998|  5.31k|	if (p15card->file_app == NULL) {
  ------------------
  |  Branch (998:6): [True: 0, False: 5.31k]
  ------------------
  999|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1000|      0|		goto end;
 1001|      0|	}
 1002|       |
 1003|  5.31k|	sc_format_path("3F005015", &p15card->file_app->path);
 1004|       |
 1005|  5.31k|	info = sc_find_app(card, aid);
 1006|  5.31k|	if (info)   {
  ------------------
  |  Branch (1006:6): [True: 159, False: 5.15k]
  ------------------
 1007|    159|		sc_log(ctx, "bind to application('%s',aid:'%s')", info->label, sc_dump_hex(info->aid.value, info->aid.len));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1008|    159|		sc_pkcs15_free_app(p15card);
 1009|    159|		p15card->app = sc_dup_app_info(info);
 1010|    159|		if (!p15card->app)   {
  ------------------
  |  Branch (1010:7): [True: 0, False: 159]
  ------------------
 1011|      0|			err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1012|      0|			goto end;
 1013|      0|		}
 1014|       |
 1015|    159|		if (info->path.len)
  ------------------
  |  Branch (1015:7): [True: 148, False: 11]
  ------------------
 1016|    148|			p15card->file_app->path = info->path;
 1017|       |
 1018|    159|		if (info->ddo.value && info->ddo.len)
  ------------------
  |  Branch (1018:7): [True: 25, False: 134]
  |  Branch (1018:26): [True: 18, False: 7]
  ------------------
 1019|     18|			parse_ddo(p15card, info->ddo.value, info->ddo.len);
 1020|       |
 1021|    159|	}
 1022|  5.15k|	else if (aid)   {
  ------------------
  |  Branch (1022:11): [True: 0, False: 5.15k]
  ------------------
 1023|      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__
  |  |  ------------------
  ------------------
 1024|      0|		err = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1025|      0|		goto end;
 1026|      0|	}
 1027|  5.31k|	sc_log(ctx, "application path '%s'", sc_print_path(&p15card->file_app->path));
  ------------------
  |  |   71|  5.31k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1028|       |
 1029|       |	/* Check if pkcs15 directory exists */
 1030|  5.31k|	err = sc_select_file(card, &p15card->file_app->path, NULL);
 1031|       |
 1032|       |	/* If the above test failed on cards without EF(DIR),
 1033|       |	 * try to continue read ODF from 3F005031. -aet
 1034|       |	 */
 1035|  5.31k|	if ((err != SC_SUCCESS) && (card->app_count < 1)) {
  ------------------
  |  |   28|  5.31k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1035:6): [True: 3.43k, False: 1.87k]
  |  Branch (1035:29): [True: 3.35k, False: 88]
  ------------------
 1036|  3.35k|		sc_format_path("3F00", &p15card->file_app->path);
 1037|  3.35k|		err = SC_SUCCESS;
  ------------------
  |  |   28|  3.35k|#define SC_SUCCESS				0
  ------------------
 1038|  3.35k|	}
 1039|       |
 1040|  5.31k|	if (err < 0)   {
  ------------------
  |  Branch (1040:6): [True: 88, False: 5.22k]
  ------------------
 1041|     88|		sc_log (ctx, "Cannot select application path");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1042|     88|		goto end;
 1043|     88|	}
 1044|       |
 1045|  5.22k|	if (p15card->file_odf == NULL) {
  ------------------
  |  Branch (1045:6): [True: 5.22k, False: 2]
  ------------------
 1046|       |		/* check if an ODF is present; we don't know yet whether we have a pkcs15 card */
 1047|  5.22k|		sc_format_path("5031", &tmppath);
 1048|  5.22k|		err = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &tmppath);
 1049|  5.22k|		if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|  5.22k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1049:7): [True: 0, False: 5.22k]
  ------------------
 1050|      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__
  |  |  ------------------
  ------------------
 1051|      0|			goto end;
 1052|      0|		}
 1053|  5.22k|		sc_log(ctx, "absolute path to EF(ODF) %s", sc_print_path(&tmppath));
  ------------------
  |  |   71|  5.22k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1054|  5.22k|		err = sc_select_file(card, &tmppath, &p15card->file_odf);
 1055|  5.22k|	}
 1056|      2|	else {
 1057|      2|		tmppath = p15card->file_odf->path;
 1058|      2|		sc_file_free(p15card->file_odf);
 1059|      2|		p15card->file_odf = NULL;
 1060|      2|		err = sc_select_file(card, &tmppath, &p15card->file_odf);
 1061|      2|	}
 1062|       |
 1063|  5.22k|	if (err != SC_SUCCESS) {
  ------------------
  |  |   28|  5.22k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1063:6): [True: 3.33k, False: 1.89k]
  ------------------
 1064|  3.33k|		sc_log(ctx, "EF(ODF) not found in '%s'", sc_print_path(&tmppath));
  ------------------
  |  |   71|  3.33k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1065|  3.33k|		goto end;
 1066|  3.33k|	}
 1067|       |
 1068|  1.89k|	len = p15card->file_odf->size;
 1069|  1.89k|	if (!len) {
  ------------------
  |  Branch (1069:6): [True: 350, False: 1.54k]
  ------------------
 1070|    350|		sc_log(ctx, "EF(ODF) is empty");
  ------------------
  |  |   71|    350|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1071|    350|		goto end;
 1072|    350|	}
 1073|  1.54k|	if (len > MAX_FILE_SIZE) {
  ------------------
  |  |  229|  1.54k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (1073:6): [True: 182, False: 1.36k]
  ------------------
 1074|    182|		sc_log(ctx, "EF(ODF) too large");
  ------------------
  |  |   71|    182|#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|    182|		goto end;
 1076|    182|	}
 1077|  1.36k|	buf = malloc(len);
 1078|  1.36k|	if(buf == NULL) {
  ------------------
  |  Branch (1078:5): [True: 0, False: 1.36k]
  ------------------
 1079|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1080|      0|		goto end;
 1081|      0|	}
 1082|       |
 1083|  1.36k|	err = -1; /* file state: not in cache */
 1084|  1.36k|	if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1084:6): [True: 562, False: 800]
  ------------------
 1085|    562|		err = sc_pkcs15_read_cached_file(p15card, &tmppath, &buf, &len);
 1086|    562|		if (err == SC_SUCCESS)
  ------------------
  |  |   28|    562|#define SC_SUCCESS				0
  ------------------
  |  Branch (1086:7): [True: 0, False: 562]
  ------------------
 1087|      0|			err = (int)len;
 1088|    562|	}
 1089|  1.36k|	if (err < 0) {
  ------------------
  |  Branch (1089:6): [True: 1.36k, False: 0]
  ------------------
 1090|  1.36k|		err = sc_read_binary(card, 0, buf, len, 0);
 1091|  1.36k|		if (err < 2) {
  ------------------
  |  Branch (1091:7): [True: 114, False: 1.24k]
  ------------------
 1092|    114|			if (err < 0) {
  ------------------
  |  Branch (1092:8): [True: 47, False: 67]
  ------------------
 1093|     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__
  |  |  ------------------
  ------------------
 1094|     67|			} else {
 1095|     67|				err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|     67|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1096|     67|				sc_log(ctx, "Invalid content of EF(ODF): %s", sc_strerror(err));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1097|     67|			}
 1098|    114|			goto end;
 1099|    114|		}
 1100|       |		/* sc_read_binary may return less than requested */
 1101|  1.24k|		len = err;
 1102|       |
 1103|  1.24k|		if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1103:7): [True: 501, False: 747]
  ------------------
 1104|    501|			sc_pkcs15_cache_file(p15card, &tmppath, buf, len);
 1105|    501|		}
 1106|  1.24k|	}
 1107|       |
 1108|  1.24k|	if (parse_odf(buf, len, p15card)) {
  ------------------
  |  Branch (1108:6): [True: 49, False: 1.19k]
  ------------------
 1109|     49|		err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|     49|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1110|     49|		sc_log(ctx, "Unable to parse ODF");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1111|     49|		goto end;
 1112|     49|	}
 1113|  1.19k|	free(buf);
 1114|  1.19k|	buf = NULL;
 1115|       |
 1116|  1.19k|	sc_log(ctx, "The following DFs were found:");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1117|  5.93k|	for (df = p15card->df_list; df; df = df->next)
  ------------------
  |  Branch (1117:30): [True: 4.73k, False: 1.19k]
  ------------------
 1118|  4.73k|		sc_log(ctx, "  DF type %u, path %s, index %u, count %d", df->type,
  ------------------
  |  |   71|  5.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__
  |  |  ------------------
  ------------------
 1119|  1.19k|				sc_print_path(&df->path), df->path.index, df->path.count);
 1120|       |
 1121|  1.19k|	if (p15card->file_tokeninfo == NULL) {
  ------------------
  |  Branch (1121:6): [True: 1.19k, False: 0]
  ------------------
 1122|  1.19k|		sc_format_path("5032", &tmppath);
 1123|  1.19k|		err = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &tmppath);
 1124|  1.19k|		if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|  1.19k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1124:7): [True: 0, False: 1.19k]
  ------------------
 1125|      0|			sc_log(ctx, "Cannot make absolute path to EF(TokenInfo); 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__
  |  |  ------------------
  ------------------
 1126|      0|			goto end;
 1127|      0|		}
 1128|  1.19k|		sc_log(ctx, "absolute path to EF(TokenInfo) %s", sc_print_path(&tmppath));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1129|  1.19k|	}
 1130|      0|	else {
 1131|      0|		tmppath = p15card->file_tokeninfo->path;
 1132|      0|		sc_file_free(p15card->file_tokeninfo);
 1133|      0|		p15card->file_tokeninfo = NULL;
 1134|      0|	}
 1135|       |
 1136|  1.19k|	err = sc_select_file(card, &tmppath, &p15card->file_tokeninfo);
 1137|  1.19k|	if (err)   {
  ------------------
  |  Branch (1137:6): [True: 16, False: 1.18k]
  ------------------
 1138|     16|		sc_log(ctx, "cannot select EF(TokenInfo) file: %s", sc_strerror(err));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1139|     16|		goto end;
 1140|     16|	}
 1141|       |
 1142|  1.18k|	len = p15card->file_tokeninfo->size;
 1143|  1.18k|	if (!len) {
  ------------------
  |  Branch (1143:6): [True: 8, False: 1.17k]
  ------------------
 1144|      8|		sc_log(ctx, "EF(TokenInfo) is empty");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1145|      8|		goto end;
 1146|      8|	}
 1147|  1.17k|	if (len > MAX_FILE_SIZE) {
  ------------------
  |  |  229|  1.17k|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (1147:6): [True: 16, False: 1.15k]
  ------------------
 1148|     16|		sc_log(ctx, "EF(TokenInfo) too large");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1149|     16|		goto end;
 1150|     16|	}
 1151|  1.15k|	buf = malloc(len);
 1152|  1.15k|	if(buf == NULL) {
  ------------------
  |  Branch (1152:5): [True: 0, False: 1.15k]
  ------------------
 1153|      0|		err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1154|      0|		goto end;
 1155|      0|	}
 1156|       |
 1157|  1.15k|	err = -1; /* file state: not in cache */
 1158|  1.15k|	if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1158:6): [True: 480, False: 679]
  ------------------
 1159|    480|		err = sc_pkcs15_read_cached_file(p15card, &tmppath, &buf, &len);
 1160|    480|		if (err == SC_SUCCESS)
  ------------------
  |  |   28|    480|#define SC_SUCCESS				0
  ------------------
  |  Branch (1160:7): [True: 0, False: 480]
  ------------------
 1161|      0|			err = (int)len;
 1162|    480|	}
 1163|  1.15k|	if (err < 0) {
  ------------------
  |  Branch (1163:6): [True: 1.15k, False: 0]
  ------------------
 1164|  1.15k|		err = sc_read_binary(card, 0, buf, len, 0);
 1165|  1.15k|		if (err <= 2) {
  ------------------
  |  Branch (1165:7): [True: 18, False: 1.14k]
  ------------------
 1166|     18|			if (err < 0)   {
  ------------------
  |  Branch (1166:8): [True: 14, False: 4]
  ------------------
 1167|     14|				sc_log(ctx, "read EF(TokenInfo) file error: %s", sc_strerror(err));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1168|     14|			} else {
 1169|      4|				err = SC_ERROR_PKCS15_APP_NOT_FOUND;
  ------------------
  |  |  131|      4|#define SC_ERROR_PKCS15_APP_NOT_FOUND		-1901
  ------------------
 1170|      4|				sc_log(ctx, "Invalid content of EF(TokenInfo): %s", sc_strerror(err));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1171|      4|			}
 1172|     18|			goto end;
 1173|     18|		}
 1174|       |		/* sc_read_binary may return less than requested */
 1175|  1.14k|		len = err;
 1176|       |
 1177|  1.14k|		if (p15card->opts.use_file_cache) {
  ------------------
  |  Branch (1177:7): [True: 473, False: 668]
  ------------------
 1178|    473|			sc_pkcs15_cache_file(p15card, &tmppath, buf, len);
 1179|    473|		}
 1180|  1.14k|	}
 1181|       |
 1182|  1.14k|	memset(&tokeninfo, 0, sizeof(tokeninfo));
 1183|  1.14k|	err = sc_pkcs15_parse_tokeninfo(ctx, &tokeninfo, buf, (size_t)err);
 1184|  1.14k|	if (err != SC_SUCCESS)   {
  ------------------
  |  |   28|  1.14k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1184:6): [True: 36, False: 1.10k]
  ------------------
 1185|     36|		sc_log(ctx, "cannot parse TokenInfo content: %s", sc_strerror(err));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1186|     36|		goto end;
 1187|     36|	}
 1188|       |
 1189|  1.10k|	sc_pkcs15_clear_tokeninfo(p15card->tokeninfo);
 1190|  1.10k|	*(p15card->tokeninfo) = tokeninfo;
 1191|       |
 1192|  1.10k|	if (!p15card->tokeninfo->serial_number && 0 == card->serialnr.len) {
  ------------------
  |  Branch (1192:6): [True: 73, False: 1.03k]
  |  Branch (1192:44): [True: 66, False: 7]
  ------------------
 1193|     66|		sc_card_ctl(p15card->card, SC_CARDCTL_GET_SERIALNR, &card->serialnr);
 1194|     66|	}
 1195|       |
 1196|  1.10k|	if (!p15card->tokeninfo->serial_number && card->serialnr.len)   {
  ------------------
  |  Branch (1196:6): [True: 73, False: 1.03k]
  |  Branch (1196:44): [True: 18, False: 55]
  ------------------
 1197|     18|		char *serial = calloc(1, card->serialnr.len*2 + 1);
 1198|     18|		size_t ii;
 1199|     18|		if (!serial) {
  ------------------
  |  Branch (1199:7): [True: 0, False: 18]
  ------------------
 1200|      0|			err = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1201|      0|			goto end;
 1202|      0|		}
 1203|       |
 1204|     96|		for(ii=0;ii<card->serialnr.len;ii++)
  ------------------
  |  Branch (1204:12): [True: 78, False: 18]
  ------------------
 1205|     78|			sprintf(serial + ii*2, "%02X", *(card->serialnr.value + ii));
 1206|       |
 1207|     18|		p15card->tokeninfo->serial_number = serial;
 1208|     18|		sc_log(ctx, "p15card->tokeninfo->serial_number %s", p15card->tokeninfo->serial_number);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1209|     18|	}
 1210|       |
 1211|  1.10k|	ok = 1;
 1212|  5.31k|end:
 1213|  5.31k|	if(buf != NULL)
  ------------------
  |  Branch (1213:5): [True: 1.32k, False: 3.99k]
  ------------------
 1214|  1.32k|		free(buf);
 1215|  5.31k|	if (!ok) {
  ------------------
  |  Branch (1215:6): [True: 4.20k, False: 1.10k]
  ------------------
 1216|  4.20k|		sc_pkcs15_card_clear(p15card);
 1217|  4.20k|		if (err == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|  4.20k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (1217:7): [True: 368, False: 3.84k]
  ------------------
 1218|    368|			err = SC_ERROR_WRONG_CARD;
  ------------------
  |  |   94|    368|#define SC_ERROR_WRONG_CARD			-1413
  ------------------
 1219|  4.20k|		LOG_FUNC_RETURN(ctx, err);
  ------------------
  |  |  164|  4.20k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.20k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.20k|	int _ret = r; \
  |  |  |  |  155|  4.20k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.20k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.20k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.65k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 3.65k, False: 556]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.20k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.20k|	} else { \
  |  |  |  |  159|      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.20k|	return _ret; \
  |  |  |  |  163|  4.20k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1220|  4.20k|	}
 1221|       |
 1222|  1.10k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.10k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.10k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.10k|	int _ret = r; \
  |  |  |  |  155|  1.10k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.10k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.10k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.10k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.10k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.10k|	} else { \
  |  |  |  |  159|      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.10k|	return _ret; \
  |  |  |  |  163|  1.10k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1223|  1.10k|}
pkcs15_get_default_use_file_cache:
 1227|  4.96k|{
 1228|       |	/* enable file caching by default for cards with static content to avoid
 1229|       |	 * synchronization problems.
 1230|       |	 *
 1231|       |	 * The following list was initialized with the cards that can't be modified
 1232|       |	 * with OpenSC i.e. which don't have a profile/driver for pkcs15-init. */
 1233|  4.96k|	const char *card_drivers_with_file_cache[] = {
 1234|  4.96k|			"atrust-acos",
 1235|  4.96k|			"belpic",
 1236|  4.96k|			"cac1",
 1237|  4.96k|			"cac",
 1238|  4.96k|			"coolkey",
 1239|  4.96k|			"edo",
 1240|  4.96k|			"esteid2018",
 1241|  4.96k|			"esteid2025",
 1242|  4.96k|			"flex",
 1243|  4.96k|			"cyberflex",
 1244|  4.96k|			"gemsafeV1",
 1245|  4.96k|			"idprime",
 1246|  4.96k|			"itacns",
 1247|  4.96k|			"jpki",
 1248|  4.96k|			"MaskTech",
 1249|  4.96k|			"mcrd",
 1250|  4.96k|			"myeid",
 1251|  4.96k|			"npa",
 1252|  4.96k|			"nqapplet",
 1253|  4.96k|			"tcos",
 1254|  4.96k|			"dtrust",
 1255|  4.96k|			"lteid",
 1256|  4.96k|	};
 1257|       |
 1258|  4.96k|	if (NULL == card || NULL == card->driver || NULL == card->driver->short_name)
  ------------------
  |  Branch (1258:6): [True: 0, False: 4.96k]
  |  Branch (1258:22): [True: 0, False: 4.96k]
  |  Branch (1258:46): [True: 0, False: 4.96k]
  ------------------
 1259|      0|		return "no";
 1260|   104k|	for (size_t i = 0; i < (sizeof card_drivers_with_file_cache / sizeof *card_drivers_with_file_cache); i++) {
  ------------------
  |  Branch (1260:21): [True: 101k, False: 3.43k]
  ------------------
 1261|   101k|		if (0 == strcmp(card->driver->short_name, card_drivers_with_file_cache[i]))
  ------------------
  |  Branch (1261:7): [True: 1.53k, False: 99.5k]
  ------------------
 1262|  1.53k|			return "public";
 1263|   101k|	}
 1264|       |
 1265|  3.43k|	return "no";
 1266|  4.96k|}
sc_pkcs15_bind:
 1271|  4.96k|{
 1272|  4.96k|	struct sc_pkcs15_card *p15card = NULL;
 1273|  4.96k|	struct sc_context *ctx;
 1274|  4.96k|	scconf_block *conf_block = NULL;
 1275|  4.96k|	int r, emu_first, enable_emu;
 1276|  4.96k|	const char *use_file_cache;
 1277|  4.96k|	const char *pin_protected_certificate, *private_certificate;
 1278|       |
 1279|  4.96k|	if (card == NULL || p15card_out == NULL) {
  ------------------
  |  Branch (1279:6): [True: 0, False: 4.96k]
  |  Branch (1279:22): [True: 0, False: 4.96k]
  ------------------
 1280|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1281|      0|	}
 1282|  4.96k|	ctx = card->ctx;
 1283|       |
 1284|  4.96k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  4.96k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.96k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.96k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.96k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.96k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1285|  4.96k|	sc_log(ctx, "application(aid:'%s')", aid ? sc_dump_hex(aid->value, aid->len) : "empty");
  ------------------
  |  |   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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 0, False: 4.96k]
  |  |  ------------------
  ------------------
 1286|       |
 1287|  4.96k|	p15card = sc_pkcs15_card_new();
 1288|  4.96k|	if (p15card == NULL)
  ------------------
  |  Branch (1288:6): [True: 0, False: 4.96k]
  ------------------
 1289|  4.96k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1290|       |
 1291|  4.96k|	p15card->card = card;
 1292|  4.96k|	p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_NO_FILES;
  ------------------
  |  |  604|  4.96k|#define SC_PKCS15_OPTS_CACHE_NO_FILES			0
  ------------------
 1293|  4.96k|	use_file_cache = pkcs15_get_default_use_file_cache(card);
 1294|  4.96k|	p15card->opts.use_pin_cache = 1;
 1295|  4.96k|	p15card->opts.pin_cache_counter = 10;
 1296|  4.96k|	p15card->opts.pin_cache_ignore_user_consent = 0;
 1297|  4.96k|	pin_protected_certificate = "protect";
 1298|  4.96k|	private_certificate = "";
 1299|       |
 1300|  4.96k|	conf_block = sc_get_conf_block(ctx, "framework", "pkcs15", 1);
 1301|  4.96k|	if (conf_block) {
  ------------------
  |  Branch (1301:6): [True: 0, False: 4.96k]
  ------------------
 1302|      0|		use_file_cache = scconf_get_str(conf_block, "use_file_caching", use_file_cache);
 1303|      0|		p15card->opts.use_pin_cache = scconf_get_bool(conf_block, "use_pin_caching", p15card->opts.use_pin_cache);
 1304|      0|		p15card->opts.pin_cache_counter = scconf_get_int(conf_block, "pin_cache_counter", p15card->opts.pin_cache_counter);
 1305|      0|		p15card->opts.pin_cache_ignore_user_consent = scconf_get_bool(conf_block, "pin_cache_ignore_user_consent",
 1306|      0|				p15card->opts.pin_cache_ignore_user_consent);
 1307|      0|		pin_protected_certificate = scconf_get_str(conf_block, "pin_protected_certificate", pin_protected_certificate);
 1308|       |		/* read also the old value to keep backward compatibility */
 1309|      0|		private_certificate = scconf_get_str(conf_block, "private_certificate", private_certificate);
 1310|      0|	}
 1311|       |
 1312|  4.96k|	if (0 == strcmp(use_file_cache, "yes")) {
  ------------------
  |  Branch (1312:6): [True: 0, False: 4.96k]
  ------------------
 1313|      0|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_ALL_FILES;
  ------------------
  |  |  606|      0|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
 1314|  4.96k|	} else if (0 == strcmp(use_file_cache, "public")) {
  ------------------
  |  Branch (1314:13): [True: 1.53k, False: 3.43k]
  ------------------
 1315|  1.53k|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_PUBLIC_FILES;
  ------------------
  |  |  605|  1.53k|#define SC_PKCS15_OPTS_CACHE_PUBLIC_FILES		1
  ------------------
 1316|  3.43k|	} else if (0 == strcmp(use_file_cache, "no")) {
  ------------------
  |  Branch (1316:13): [True: 3.43k, False: 0]
  ------------------
 1317|  3.43k|		p15card->opts.use_file_cache = SC_PKCS15_OPTS_CACHE_NO_FILES;
  ------------------
  |  |  604|  3.43k|#define SC_PKCS15_OPTS_CACHE_NO_FILES			0
  ------------------
 1318|  3.43k|	}
 1319|       |
 1320|  4.96k|	if (0 == strcmp(pin_protected_certificate, "protect")) {
  ------------------
  |  Branch (1320:6): [True: 4.96k, False: 0]
  ------------------
 1321|  4.96k|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT;
  ------------------
  |  |  609|  4.96k|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT		0
  ------------------
 1322|  4.96k|	} else if (0 == strcmp(pin_protected_certificate, "ignore")) {
  ------------------
  |  Branch (1322:13): [True: 0, False: 0]
  ------------------
 1323|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE;
  ------------------
  |  |  610|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE		1
  ------------------
 1324|      0|	} else if (0 == strcmp(pin_protected_certificate, "declassify")) {
  ------------------
  |  Branch (1324:13): [True: 0, False: 0]
  ------------------
 1325|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY;
  ------------------
  |  |  611|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY	2
  ------------------
 1326|      0|	}
 1327|       |	/* overwrite pin_protected_certificate when private_certificate set */
 1328|  4.96k|	if (0 == strcmp(private_certificate, "protect")) {
  ------------------
  |  Branch (1328:6): [True: 0, False: 4.96k]
  ------------------
 1329|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT;
  ------------------
  |  |  609|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_PROTECT		0
  ------------------
 1330|  4.96k|	} else if (0 == strcmp(private_certificate, "ignore")) {
  ------------------
  |  Branch (1330:13): [True: 0, False: 4.96k]
  ------------------
 1331|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE;
  ------------------
  |  |  610|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_IGNORE		1
  ------------------
 1332|  4.96k|	} else if (0 == strcmp(private_certificate, "declassify")) {
  ------------------
  |  Branch (1332:13): [True: 0, False: 4.96k]
  ------------------
 1333|      0|		p15card->opts.pin_protected_certificate = SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY;
  ------------------
  |  |  611|      0|#define SC_PKCS15_CARD_OPTS_PRIV_CERT_DECLASSIFY	2
  ------------------
 1334|      0|	}
 1335|  4.96k|	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|  4.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__
  |  |  ------------------
  ------------------
 1336|  4.96k|			p15card->opts.use_file_cache, p15card->opts.use_pin_cache, p15card->opts.pin_cache_counter,
 1337|  4.96k|			p15card->opts.pin_cache_ignore_user_consent, p15card->opts.pin_protected_certificate);
 1338|       |
 1339|  4.96k|	r = sc_lock(card);
 1340|  4.96k|	if (r) {
  ------------------
  |  Branch (1340:6): [True: 0, False: 4.96k]
  ------------------
 1341|      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__
  |  |  ------------------
  ------------------
 1342|      0|		sc_pkcs15_card_free(p15card);
 1343|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1344|      0|	}
 1345|       |
 1346|  4.96k|	enable_emu = scconf_get_bool(conf_block, "enable_pkcs15_emulation", 1);
 1347|  4.96k|	if (enable_emu) {
  ------------------
  |  Branch (1347:6): [True: 4.96k, False: 0]
  ------------------
 1348|  4.96k|		sc_log(ctx, "PKCS#15 emulation enabled");
  ------------------
  |  |   71|  4.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__
  |  |  ------------------
  ------------------
 1349|  4.96k|		emu_first = scconf_get_bool(conf_block, "try_emulation_first", 0);
 1350|  4.96k|		if (emu_first || sc_pkcs15_is_emulation_only(card)) {
  ------------------
  |  Branch (1350:7): [True: 0, False: 4.96k]
  |  Branch (1350:20): [True: 564, False: 4.40k]
  ------------------
 1351|    564|			r = sc_pkcs15_bind_synthetic(p15card, aid);
 1352|    564|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|    564|#define SC_SUCCESS				0
  ------------------
  |  Branch (1352:8): [True: 263, False: 301]
  ------------------
 1353|    263|				goto done;
 1354|    301|			r = sc_pkcs15_bind_internal(p15card, aid);
 1355|    301|			if (r < 0)
  ------------------
  |  Branch (1355:8): [True: 279, False: 22]
  ------------------
 1356|    279|				goto error;
 1357|  4.40k|		} else {
 1358|  4.40k|			r = sc_pkcs15_bind_internal(p15card, aid);
 1359|  4.40k|			if (r == SC_SUCCESS)
  ------------------
  |  |   28|  4.40k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1359:8): [True: 1.56k, False: 2.83k]
  ------------------
 1360|  1.56k|				goto done;
 1361|  2.83k|			r = sc_pkcs15_bind_synthetic(p15card, aid);
 1362|  2.83k|			if (r < 0)
  ------------------
  |  Branch (1362:8): [True: 2.24k, False: 599]
  ------------------
 1363|  2.24k|				goto error;
 1364|  2.83k|		}
 1365|  4.96k|	}
 1366|      0|	else {
 1367|      0|		r = sc_pkcs15_bind_internal(p15card, aid);
 1368|      0|		if (r < 0)
  ------------------
  |  Branch (1368:7): [True: 0, False: 0]
  ------------------
 1369|      0|			goto error;
 1370|      0|	}
 1371|  2.45k|done:
 1372|  2.45k|	*p15card_out = p15card;
 1373|  2.45k|	sc_unlock(card);
 1374|  2.45k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.45k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.45k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.45k|	int _ret = r; \
  |  |  |  |  155|  2.45k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.45k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.45k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.45k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.45k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.45k|	} else { \
  |  |  |  |  159|      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.45k|	return _ret; \
  |  |  |  |  163|  2.45k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1375|  2.51k|error:
 1376|  2.51k|	sc_unlock(card);
 1377|  2.51k|	sc_pkcs15_card_free(p15card);
 1378|  2.51k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  2.51k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.51k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.51k|	int _ret = r; \
  |  |  |  |  155|  2.51k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.51k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.51k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.51k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.51k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.51k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.51k|	} else { \
  |  |  |  |  159|      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.51k|	return _ret; \
  |  |  |  |  163|  2.51k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1379|  2.51k|}
sc_pkcs15_unbind:
 1384|  2.45k|{
 1385|  2.45k|	if (p15card == NULL || p15card->magic != SC_PKCS15_CARD_MAGIC) {
  ------------------
  |  |  519|  2.45k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  |  Branch (1385:6): [True: 0, False: 2.45k]
  |  Branch (1385:25): [True: 0, False: 2.45k]
  ------------------
 1386|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1387|      0|	}
 1388|       |
 1389|  2.45k|	LOG_FUNC_CALLED(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1390|  2.45k|	if (p15card->dll_handle)
  ------------------
  |  Branch (1390:6): [True: 0, False: 2.45k]
  ------------------
 1391|      0|		sc_dlclose(p15card->dll_handle);
 1392|  2.45k|	sc_pkcs15_pincache_clear(p15card);
 1393|  2.45k|	sc_pkcs15_card_free(p15card);
 1394|  2.45k|	return 0;
 1395|  2.45k|}
sc_pkcs15_get_objects:
 1483|  21.4k|{
 1484|  21.4k|	return sc_pkcs15_get_objects_cond(p15card, type, NULL, NULL, ret, ret_size);
 1485|  21.4k|}
sc_pkcs15_search_objects:
 1666|   346k|{
 1667|   346k|	return __sc_pkcs15_search_objects(p15card,
 1668|   346k|			sk->class_mask, sk->type,
 1669|   346k|			compare_obj_key, sk,
 1670|   346k|			ret, ret_size);
 1671|   346k|}
sc_pkcs15_get_objects_cond:
 1678|  23.0k|{
 1679|  23.0k|	return __sc_pkcs15_search_objects(p15card, 0, type,
 1680|  23.0k|			func, func_arg, ret, ret_size);
 1681|  23.0k|}
sc_pkcs15_find_object_by_id:
 1687|   364k|{
 1688|   364k|	struct sc_pkcs15_search_key sk;
 1689|   364k|	int	r;
 1690|       |
 1691|   364k|	memset(&sk, 0, sizeof(sk));
 1692|   364k|	sk.id = id;
 1693|       |
 1694|   364k|	r = __sc_pkcs15_search_objects(p15card, 0, type, compare_obj_key, &sk, out, 1);
 1695|   364k|	if (r < 0)
  ------------------
  |  Branch (1695:6): [True: 0, False: 364k]
  ------------------
 1696|      0|		return r;
 1697|   364k|	if (r == 0)
  ------------------
  |  Branch (1697:6): [True: 363k, False: 860]
  ------------------
 1698|   363k|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|   363k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1699|    860|	return 0;
 1700|   364k|}
sc_pkcs15_find_prkey_by_id:
 1714|    610|{
 1715|    610|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_PRKEY, id, out);
  ------------------
  |  |  418|    610|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
 1716|    610|}
sc_pkcs15_find_pubkey_by_id:
 1722|     22|{
 1723|     22|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_PUBKEY, id, out);
  ------------------
  |  |  425|     22|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
 1724|     22|}
sc_pkcs15_find_skey_by_id:
 1730|  6.65k|{
 1731|  6.65k|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_SKEY, id, out);
  ------------------
  |  |  432|  6.65k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
 1732|  6.65k|}
sc_pkcs15_find_pin_by_auth_id:
 1738|  2.94k|{
 1739|  2.94k|	return sc_pkcs15_find_object_by_id(p15card, SC_PKCS15_TYPE_AUTH, id, out);
  ------------------
  |  |  444|  2.94k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
 1740|  2.94k|}
sc_pkcs15_find_pin_by_reference:
 1746|  1.07k|{
 1747|  1.07k|	struct sc_pkcs15_search_key sk;
 1748|       |
 1749|  1.07k|	memset(&sk, 0, sizeof(sk));
 1750|  1.07k|	sk.match_reference = 1;
 1751|  1.07k|	sk.reference = reference;
 1752|  1.07k|	sk.path = path;
 1753|       |
 1754|  1.07k|	return find_by_key(p15card, SC_PKCS15_TYPE_AUTH_PIN, &sk, out);
  ------------------
  |  |  445|  1.07k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 1755|  1.07k|}
sc_pkcs15_find_pin_by_type_and_reference:
 1762|    930|{
 1763|    930|	struct sc_context *ctx = p15card->card->ctx;
 1764|    930|	struct sc_pkcs15_object *auth_objs[0x10];
 1765|    930|	size_t nn_objs, ii;
 1766|    930|	int r;
 1767|       |
 1768|       |	/* Get all existing pkcs15 AUTH objects */
 1769|    930|	r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, auth_objs, 0x10);
  ------------------
  |  |  445|    930|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 1770|    930|	LOG_TEST_RET(ctx, r, "Get PKCS#15 AUTH objects error");
  ------------------
  |  |  174|    930|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    930|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    930|	int _ret = (r); \
  |  |  |  |  168|    930|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 930]
  |  |  |  |  ------------------
  |  |  |  |  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|    930|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 930]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1771|    930|	nn_objs = r;
 1772|       |
 1773|  2.01k|	for (ii=0; ii<nn_objs; ii++)   {
  ------------------
  |  Branch (1773:13): [True: 1.24k, False: 768]
  ------------------
 1774|  1.24k|		struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)auth_objs[ii]->data;
 1775|       |
 1776|  1.24k|		if (auth_info->auth_method != auth_method)
  ------------------
  |  Branch (1776:7): [True: 225, False: 1.02k]
  ------------------
 1777|    225|			continue;
 1778|  1.02k|		if (auth_info->auth_type == SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.02k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1778:7): [True: 1.02k, False: 0]
  ------------------
 1779|  1.02k|			if (auth_info->attrs.pin.reference != reference)
  ------------------
  |  Branch (1779:8): [True: 594, False: 428]
  ------------------
 1780|    594|				continue;
 1781|       |
 1782|    428|		if (path && !sc_compare_path(&auth_info->path, path))
  ------------------
  |  Branch (1782:7): [True: 321, False: 107]
  |  Branch (1782:15): [True: 266, False: 55]
  ------------------
 1783|    266|			continue;
 1784|       |
 1785|    162|		if (out)
  ------------------
  |  Branch (1785:7): [True: 162, False: 0]
  ------------------
 1786|    162|			*out = auth_objs[ii];
 1787|       |
 1788|    162|		return SC_SUCCESS;
  ------------------
  |  |   28|    162|#define SC_SUCCESS				0
  ------------------
 1789|    428|	}
 1790|       |
 1791|    768|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    768|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1792|    930|}
sc_pkcs15_find_prkey_by_reference:
 1916|    573|{
 1917|    573|	struct sc_pkcs15_search_key sk;
 1918|       |
 1919|    573|	memset(&sk, 0, sizeof(sk));
 1920|    573|	sk.match_reference = 1;
 1921|    573|	sk.reference = reference;
 1922|    573|	sk.path = path;
 1923|       |
 1924|    573|	return find_by_key(p15card, SC_PKCS15_TYPE_PRKEY, &sk, out);
  ------------------
  |  |  418|    573|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
 1925|    573|}
sc_pkcs15_add_object:
 1930|  2.58k|{
 1931|  2.58k|	struct sc_pkcs15_object *p = p15card->obj_list;
 1932|       |
 1933|  2.58k|	if (!obj)
  ------------------
  |  Branch (1933:6): [True: 0, False: 2.58k]
  ------------------
 1934|      0|		return 0;
 1935|  2.58k|	obj->next = obj->prev = NULL;
 1936|  2.58k|	if (p15card->obj_list == NULL) {
  ------------------
  |  Branch (1936:6): [True: 1.47k, False: 1.11k]
  ------------------
 1937|  1.47k|		p15card->obj_list = obj;
 1938|  1.47k|		return 0;
 1939|  1.47k|	}
 1940|  2.51k|	while (p->next != NULL)
  ------------------
  |  Branch (1940:9): [True: 1.40k, False: 1.11k]
  ------------------
 1941|  1.40k|		p = p->next;
 1942|  1.11k|	p->next = obj;
 1943|  1.11k|	obj->prev = p;
 1944|       |
 1945|  1.11k|	return 0;
 1946|  2.58k|}
sc_pkcs15_remove_object:
 1951|    806|{
 1952|    806|	if (!obj)
  ------------------
  |  Branch (1952:6): [True: 0, False: 806]
  ------------------
 1953|      0|		return;
 1954|    806|	else if (obj->prev == NULL)
  ------------------
  |  Branch (1954:11): [True: 671, False: 135]
  ------------------
 1955|    671|		p15card->obj_list = obj->next;
 1956|    135|	else
 1957|    135|		obj->prev->next = obj->next;
 1958|    806|	if (obj->next != NULL)
  ------------------
  |  Branch (1958:6): [True: 7, False: 799]
  ------------------
 1959|      7|		obj->next->prev = obj->prev;
 1960|    806|}
sc_pkcs15_free_object:
 1981|  15.3k|{
 1982|  15.3k|	if (!obj)
  ------------------
  |  Branch (1982:6): [True: 2.39k, False: 12.9k]
  ------------------
 1983|  2.39k|		return;
 1984|  12.9k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  12.9k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 1985|  2.61k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  2.61k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1985:2): [True: 2.61k, False: 10.3k]
  ------------------
 1986|  2.61k|		sc_pkcs15_free_prkey_info((sc_pkcs15_prkey_info_t *)obj->data);
 1987|  2.61k|		break;
 1988|     78|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|     78|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1988:2): [True: 78, False: 12.8k]
  ------------------
 1989|       |		/* This is normally passed to framework-pkcs15,
 1990|       |		 * but if something fails on the way, it would not get freed */
 1991|     78|		if (obj->emulated) {
  ------------------
  |  Branch (1991:7): [True: 0, False: 78]
  ------------------
 1992|      0|			sc_pkcs15_free_pubkey(obj->emulated);
 1993|      0|		}
 1994|     78|		sc_pkcs15_free_pubkey_info((sc_pkcs15_pubkey_info_t *)obj->data);
 1995|     78|		break;
 1996|    278|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|    278|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1996:2): [True: 278, False: 12.6k]
  ------------------
 1997|    278|		sc_pkcs15_free_cert_info((sc_pkcs15_cert_info_t *)obj->data);
 1998|    278|		break;
 1999|  4.32k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  4.32k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (1999:2): [True: 4.32k, False: 8.60k]
  ------------------
 2000|  4.32k|		sc_pkcs15_free_skey_info((sc_pkcs15_skey_info_t *)obj->data);
 2001|  4.32k|		break;
 2002|  2.28k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  2.28k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (2002:2): [True: 2.28k, False: 10.6k]
  ------------------
 2003|  2.28k|		sc_pkcs15_free_data_info((sc_pkcs15_data_info_t *)obj->data);
 2004|  2.28k|		break;
 2005|  3.34k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  3.34k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (2005:2): [True: 3.34k, False: 9.58k]
  ------------------
 2006|  3.34k|		sc_pkcs15_free_auth_info((sc_pkcs15_auth_info_t *)obj->data);
 2007|  3.34k|		break;
 2008|      0|	default:
  ------------------
  |  Branch (2008:2): [True: 0, False: 12.9k]
  ------------------
 2009|      0|		free(obj->data);
 2010|  12.9k|	}
 2011|       |
 2012|  12.9k|	sc_pkcs15_free_object_content(obj);
 2013|       |
 2014|  12.9k|	free(obj);
 2015|  12.9k|}
sc_pkcs15_add_df:
 2020|  6.83k|{
 2021|  6.83k|	struct sc_pkcs15_df *p, *newdf;
 2022|       |
 2023|  6.83k|	newdf = calloc(1, sizeof(struct sc_pkcs15_df));
 2024|  6.83k|	if (newdf == NULL)
  ------------------
  |  Branch (2024:6): [True: 0, False: 6.83k]
  ------------------
 2025|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2026|  6.83k|	newdf->path = *path;
 2027|  6.83k|	newdf->type = type;
 2028|       |
 2029|  6.83k|	if (p15card->df_list == NULL) {
  ------------------
  |  Branch (2029:6): [True: 1.87k, False: 4.96k]
  ------------------
 2030|  1.87k|		p15card->df_list = newdf;
 2031|  1.87k|		return 0;
 2032|  1.87k|	}
 2033|       |
 2034|  4.96k|	p = p15card->df_list;
 2035|  20.0k|	while (p->next != NULL)
  ------------------
  |  Branch (2035:9): [True: 15.0k, False: 4.96k]
  ------------------
 2036|  15.0k|		p = p->next;
 2037|  4.96k|	p->next = newdf;
 2038|  4.96k|	newdf->prev = p;
 2039|       |
 2040|  4.96k|	return 0;
 2041|  6.83k|}
sc_pkcs15_encode_df:
 2064|  1.18k|{
 2065|  1.18k|	unsigned char *buf = NULL, *tmp = NULL, *p;
 2066|  1.18k|	size_t bufsize = 0, tmpsize;
 2067|  1.18k|	const struct sc_pkcs15_object *obj;
 2068|  1.18k|	int (* func)(struct sc_context *, const struct sc_pkcs15_object *nobj,
 2069|  1.18k|		     unsigned char **nbuf, size_t *nbufsize) = NULL;
 2070|  1.18k|	int r;
 2071|       |
 2072|  1.18k|	if (p15card == NULL || p15card->magic != SC_PKCS15_CARD_MAGIC) {
  ------------------
  |  |  519|  1.18k|#define SC_PKCS15_CARD_MAGIC		0x10203040
  ------------------
  |  Branch (2072:6): [True: 0, False: 1.18k]
  |  Branch (2072:25): [True: 0, False: 1.18k]
  ------------------
 2073|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2074|      0|	}
 2075|  1.18k|	switch (df->type) {
  ------------------
  |  Branch (2075:10): [True: 1.18k, False: 0]
  ------------------
 2076|    240|	case SC_PKCS15_PRKDF:
  ------------------
  |  |  488|    240|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (2076:2): [True: 240, False: 941]
  ------------------
 2077|    240|		func = sc_pkcs15_encode_prkdf_entry;
 2078|    240|		break;
 2079|    157|	case SC_PKCS15_PUKDF:
  ------------------
  |  |  489|    157|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (2079:2): [True: 157, False: 1.02k]
  ------------------
 2080|    157|	case SC_PKCS15_PUKDF_TRUSTED:
  ------------------
  |  |  490|    157|#define SC_PKCS15_PUKDF_TRUSTED		2
  ------------------
  |  Branch (2080:2): [True: 0, False: 1.18k]
  ------------------
 2081|    157|		func = sc_pkcs15_encode_pukdf_entry;
 2082|    157|		break;
 2083|    184|	case SC_PKCS15_SKDF:
  ------------------
  |  |  491|    184|#define SC_PKCS15_SKDF			3
  ------------------
  |  Branch (2083:2): [True: 184, False: 997]
  ------------------
 2084|    184|		func = sc_pkcs15_encode_skdf_entry;
 2085|    184|		break;
 2086|    118|	case SC_PKCS15_CDF:
  ------------------
  |  |  492|    118|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (2086:2): [True: 118, False: 1.06k]
  ------------------
 2087|    233|	case SC_PKCS15_CDF_TRUSTED:
  ------------------
  |  |  493|    233|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
  |  Branch (2087:2): [True: 115, False: 1.06k]
  ------------------
 2088|    233|	case SC_PKCS15_CDF_USEFUL:
  ------------------
  |  |  494|    233|#define SC_PKCS15_CDF_USEFUL		6
  ------------------
  |  Branch (2088:2): [True: 0, False: 1.18k]
  ------------------
 2089|    233|		func = sc_pkcs15_encode_cdf_entry;
 2090|    233|		break;
 2091|    122|	case SC_PKCS15_DODF:
  ------------------
  |  |  495|    122|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (2091:2): [True: 122, False: 1.05k]
  ------------------
 2092|    122|		func = sc_pkcs15_encode_dodf_entry;
 2093|    122|		break;
 2094|    245|	case SC_PKCS15_AODF:
  ------------------
  |  |  496|    245|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (2094:2): [True: 245, False: 936]
  ------------------
 2095|    245|		func = sc_pkcs15_encode_aodf_entry;
 2096|    245|		break;
 2097|  1.18k|	}
 2098|  1.18k|	if (func == NULL) {
  ------------------
  |  Branch (2098:6): [True: 0, False: 1.18k]
  ------------------
 2099|      0|		sc_log(ctx, "unknown DF type: %d", df->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__
  |  |  ------------------
  ------------------
 2100|      0|		*buf_out = NULL;
 2101|      0|		*bufsize_out = 0;
 2102|      0|		return 0;
 2103|      0|	}
 2104|  2.76k|	for (obj = p15card->obj_list; obj != NULL; obj = obj->next) {
  ------------------
  |  Branch (2104:32): [True: 1.59k, False: 1.16k]
  ------------------
 2105|  1.59k|		if (obj->df != df)
  ------------------
  |  Branch (2105:7): [True: 1.18k, False: 412]
  ------------------
 2106|  1.18k|			continue;
 2107|    412|		r = func(ctx, obj, &tmp, &tmpsize);
 2108|    412|		if (r) {
  ------------------
  |  Branch (2108:7): [True: 14, False: 398]
  ------------------
 2109|     14|			free(tmp);
 2110|     14|			free(buf);
 2111|     14|			return r;
 2112|     14|		}
 2113|    398|		if (!tmpsize)
  ------------------
  |  Branch (2113:7): [True: 0, False: 398]
  ------------------
 2114|      0|			continue;
 2115|    398|		p = (u8 *) realloc(buf, bufsize + tmpsize);
 2116|    398|		if (!p) {
  ------------------
  |  Branch (2116:7): [True: 0, False: 398]
  ------------------
 2117|      0|			free(tmp);
 2118|      0|			free(buf);
 2119|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2120|      0|		}
 2121|    398|		buf = p;
 2122|    398|		memcpy(buf + bufsize, tmp, tmpsize);
 2123|    398|		free(tmp);
 2124|    398|		tmp = NULL;
 2125|    398|		bufsize += tmpsize;
 2126|    398|	}
 2127|  1.16k|	*buf_out = buf;
 2128|  1.16k|	*bufsize_out = bufsize;
 2129|       |
 2130|  1.16k|	return 0;
 2131|  1.18k|}
sc_pkcs15_parse_df:
 2136|   330k|{
 2137|   330k|	struct sc_context *ctx = p15card->card->ctx;
 2138|   330k|	unsigned char *buf;
 2139|   330k|	const unsigned char *p;
 2140|   330k|	size_t bufsize;
 2141|   330k|	int r;
 2142|   330k|	struct sc_pkcs15_object *obj = NULL;
 2143|   330k|	int (* func)(struct sc_pkcs15_card *, struct sc_pkcs15_object *,
 2144|   330k|		     const u8 **nbuf, size_t *nbufsize) = NULL;
 2145|       |
 2146|   330k|	sc_log(ctx, "called; path=%s, type=%d, enum=%d", sc_print_path(&df->path), df->type, df->enumerated);
  ------------------
  |  |   71|   330k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2147|       |
 2148|   330k|	if (df->enumerated)
  ------------------
  |  Branch (2148:6): [True: 0, False: 330k]
  ------------------
 2149|   330k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2150|       |
 2151|   330k|	switch (df->type) {
  ------------------
  |  Branch (2151:10): [True: 319k, False: 11.3k]
  ------------------
 2152|   102k|	case SC_PKCS15_PRKDF:
  ------------------
  |  |  488|   102k|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (2152:2): [True: 102k, False: 228k]
  ------------------
 2153|   102k|		func = sc_pkcs15_decode_prkdf_entry;
 2154|   102k|		break;
 2155|  92.4k|	case SC_PKCS15_PUKDF:
  ------------------
  |  |  489|  92.4k|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (2155:2): [True: 92.4k, False: 238k]
  ------------------
 2156|  92.4k|		func = sc_pkcs15_decode_pukdf_entry;
 2157|  92.4k|		break;
 2158|  4.82k|	case SC_PKCS15_SKDF:
  ------------------
  |  |  491|  4.82k|#define SC_PKCS15_SKDF			3
  ------------------
  |  Branch (2158:2): [True: 4.82k, False: 325k]
  ------------------
 2159|  4.82k|		func = sc_pkcs15_decode_skdf_entry;
 2160|  4.82k|		break;
 2161|  72.2k|	case SC_PKCS15_CDF:
  ------------------
  |  |  492|  72.2k|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (2161:2): [True: 72.2k, False: 258k]
  ------------------
 2162|   101k|	case SC_PKCS15_CDF_TRUSTED:
  ------------------
  |  |  493|   101k|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
  |  Branch (2162:2): [True: 29.3k, False: 301k]
  ------------------
 2163|   117k|	case SC_PKCS15_CDF_USEFUL:
  ------------------
  |  |  494|   117k|#define SC_PKCS15_CDF_USEFUL		6
  ------------------
  |  Branch (2163:2): [True: 16.2k, False: 314k]
  ------------------
 2164|   117k|		func = sc_pkcs15_decode_cdf_entry;
 2165|   117k|		break;
 2166|    444|	case SC_PKCS15_DODF:
  ------------------
  |  |  495|    444|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (2166:2): [True: 444, False: 330k]
  ------------------
 2167|    444|		func = sc_pkcs15_decode_dodf_entry;
 2168|    444|		break;
 2169|  1.19k|	case SC_PKCS15_AODF:
  ------------------
  |  |  496|  1.19k|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (2169:2): [True: 1.19k, False: 329k]
  ------------------
 2170|  1.19k|		func = sc_pkcs15_decode_aodf_entry;
 2171|  1.19k|		break;
 2172|   330k|	}
 2173|   330k|	if (func == NULL) {
  ------------------
  |  Branch (2173:6): [True: 11.3k, False: 319k]
  ------------------
 2174|  11.3k|		sc_log(ctx, "unknown DF type: %d", df->type);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2175|  11.3k|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  164|  11.3k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  11.3k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  11.3k|	int _ret = r; \
  |  |  |  |  155|  11.3k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 11.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  11.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|  11.3k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 11.3k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  11.3k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  11.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|  11.3k|	return _ret; \
  |  |  |  |  163|  11.3k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2176|  11.3k|	}
 2177|   319k|	r = sc_pkcs15_read_file(p15card, &df->path, &buf, &bufsize, 0);
 2178|   319k|	LOG_TEST_RET(ctx, r, "pkcs15 read file failed");
  ------------------
  |  |  174|   319k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|   319k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|   319k|	int _ret = (r); \
  |  |  |  |  168|   319k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 318k, False: 1.03k]
  |  |  |  |  ------------------
  |  |  |  |  169|   318k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|   318k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|   318k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|   318k|		return _ret; \
  |  |  |  |  172|   318k|	} \
  |  |  |  |  173|   319k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.03k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2179|       |
 2180|  1.03k|	p = buf;
 2181|  1.34k|	while (bufsize && *p != 0x00) {
  ------------------
  |  Branch (2181:9): [True: 1.08k, False: 258]
  |  Branch (2181:20): [True: 999, False: 87]
  ------------------
 2182|       |
 2183|    999|		obj = calloc(1, sizeof(struct sc_pkcs15_object));
 2184|    999|		if (obj == NULL) {
  ------------------
  |  Branch (2184:7): [True: 0, False: 999]
  ------------------
 2185|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2186|      0|			goto ret;
 2187|      0|		}
 2188|    999|		r = func(p15card, obj, &p, &bufsize);
 2189|    999|		if (r) {
  ------------------
  |  Branch (2189:7): [True: 693, False: 306]
  ------------------
 2190|    693|			free(obj);
 2191|    693|			if (r == SC_ERROR_ASN1_END_OF_CONTENTS) {
  ------------------
  |  |   84|    693|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (2191:8): [True: 83, False: 610]
  ------------------
 2192|     83|				r = 0;
 2193|     83|				break;
 2194|     83|			}
 2195|    610|			sc_log(ctx, "%s: Error decoding DF entry", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2196|    610|			goto ret;
 2197|    693|		}
 2198|       |
 2199|    306|		obj->df = df;
 2200|    306|		r = sc_pkcs15_add_object(p15card, obj);
 2201|    306|		if (r) {
  ------------------
  |  Branch (2201:7): [True: 0, False: 306]
  ------------------
 2202|      0|			if (obj->data)
  ------------------
  |  Branch (2202:8): [True: 0, False: 0]
  ------------------
 2203|      0|				free(obj->data);
 2204|      0|			free(obj);
 2205|      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__
  |  |  ------------------
  ------------------
 2206|      0|			goto ret;
 2207|      0|		}
 2208|  1.63k|		while (bufsize > 0 && *p == 00) {
  ------------------
  |  Branch (2208:10): [True: 1.63k, False: 4]
  |  Branch (2208:25): [True: 1.32k, False: 302]
  ------------------
 2209|  1.32k|			bufsize--;
 2210|  1.32k|			p++;
 2211|  1.32k|		}
 2212|    428|	};
 2213|       |
 2214|    428|	if (r > 0)
  ------------------
  |  Branch (2214:6): [True: 0, False: 428]
  ------------------
 2215|      0|		r = 0;
 2216|  1.03k|ret:
 2217|  1.03k|	df->enumerated = 1;
 2218|  1.03k|	free(buf);
 2219|  1.03k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|    610|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 610, False: 428]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2220|  1.03k|}
sc_pkcs15_read_file:
 2472|   319k|{
 2473|   319k|	struct sc_context *ctx;
 2474|   319k|	struct sc_file *file = NULL;
 2475|   319k|	unsigned char *data = NULL;
 2476|   319k|	size_t	len = 0, offset = 0;
 2477|   319k|	int	r;
 2478|       |
 2479|   319k|	if (p15card == NULL || p15card->card == NULL || in_path == NULL || buf == NULL) {
  ------------------
  |  Branch (2479:6): [True: 0, False: 319k]
  |  Branch (2479:25): [True: 0, False: 319k]
  |  Branch (2479:50): [True: 0, False: 319k]
  |  Branch (2479:69): [True: 0, False: 319k]
  ------------------
 2480|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2481|      0|	}
 2482|   319k|	ctx = p15card->card->ctx;
 2483|       |
 2484|   319k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|   319k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|   319k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|   319k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|   319k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 319k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2485|   319k|	sc_log(ctx, "path=%s, index=%u, count=%d", sc_print_path(in_path), in_path->index, in_path->count);
  ------------------
  |  |   71|   319k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2486|       |
 2487|   319k|	r = -1; /* file state: not in cache */
 2488|   319k|	if (p15card->opts.use_file_cache
  ------------------
  |  Branch (2488:6): [True: 90.8k, False: 228k]
  ------------------
 2489|  90.8k|	    && ((p15card->opts.use_file_cache & SC_PKCS15_OPTS_CACHE_ALL_FILES) || !private_data)) {
  ------------------
  |  |  606|  90.8k|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
  |  Branch (2489:10): [True: 0, False: 90.8k]
  |  Branch (2489:77): [True: 90.8k, False: 0]
  ------------------
 2490|  90.8k|		r = sc_pkcs15_read_cached_file(p15card, in_path, &data, &len);
 2491|       |
 2492|  90.8k|		if (!r && in_path->aid.len > 0 && in_path->len >= 2)   {
  ------------------
  |  Branch (2492:7): [True: 120, False: 90.7k]
  |  Branch (2492:13): [True: 0, False: 120]
  |  Branch (2492:37): [True: 0, False: 0]
  ------------------
 2493|      0|			struct sc_path parent = *in_path;
 2494|       |
 2495|      0|			parent.len -= 2;
 2496|      0|			parent.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|      0|#define SC_PATH_TYPE_PATH		2
  ------------------
 2497|      0|			r = sc_select_file(p15card->card, &parent, NULL);
 2498|      0|		}
 2499|  90.8k|	}
 2500|       |
 2501|   319k|	if (r) {
  ------------------
  |  Branch (2501:6): [True: 319k, False: 120]
  ------------------
 2502|   319k|		r = sc_lock(p15card->card);
 2503|   319k|		if (r)
  ------------------
  |  Branch (2503:7): [True: 0, False: 319k]
  ------------------
 2504|      0|			goto fail;
 2505|   319k|		r = sc_select_file(p15card->card, in_path, &file);
 2506|   319k|		if (r)
  ------------------
  |  Branch (2506:7): [True: 288k, False: 30.8k]
  ------------------
 2507|   288k|			goto fail_unlock;
 2508|       |
 2509|       |		/* Handle the case where the ASN.1 Path object specified
 2510|       |		 * index and length values */
 2511|       |
 2512|  30.8k|		if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|  30.8k|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2512:7): [True: 1.14k, False: 29.6k]
  ------------------
 2513|       |
 2514|       |			// in_path->index: record_no
 2515|       |			// in_path->count: ignored!
 2516|       |
 2517|  1.14k|			if(file->record_length > 0) {
  ------------------
  |  Branch (2517:7): [True: 121, False: 1.02k]
  ------------------
 2518|    121|				if(file->record_length > MAX_FILE_SIZE) {
  ------------------
  |  |  229|    121|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (2518:8): [True: 0, False: 121]
  ------------------
 2519|      0|					len = MAX_FILE_SIZE;
  ------------------
  |  |  229|      0|#define MAX_FILE_SIZE 65535
  ------------------
 2520|      0|					sc_log(ctx, "  record size truncated, encoded length: %"SC_FORMAT_LEN_SIZE_T"u", 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__
  |  |  ------------------
  ------------------
 2521|    121|				} else {
 2522|    121|					len = file->record_length;
 2523|    121|				}
 2524|  1.02k|			} else {
 2525|  1.02k|				len = MAX_FILE_SIZE;
  ------------------
  |  |  229|  1.02k|#define MAX_FILE_SIZE 65535
  ------------------
 2526|  1.02k|			}
 2527|       |
 2528|  1.14k|			if ((in_path->index <= 0) || (in_path->index > (int)(file->record_count))) {
  ------------------
  |  Branch (2528:8): [True: 1.14k, False: 0]
  |  Branch (2528:33): [True: 0, False: 0]
  ------------------
 2529|  1.14k|				sc_log(ctx, "  record number out of bounds: %d", in_path->index);
  ------------------
  |  |   71|  1.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__
  |  |  ------------------
  ------------------
 2530|  1.14k|				r = SC_ERROR_RECORD_NOT_FOUND;
  ------------------
  |  |   52|  1.14k|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
 2531|  1.14k|				goto fail_unlock;
 2532|  1.14k|			}
 2533|       |
 2534|  29.6k|		} else {
 2535|       |
 2536|  29.6k|			if (in_path->count < 0) {
  ------------------
  |  Branch (2536:8): [True: 29.6k, False: 34]
  ------------------
 2537|  29.6k|				if (file->size)
  ------------------
  |  Branch (2537:9): [True: 22.6k, False: 6.99k]
  ------------------
 2538|  22.6k|					len = (file->size > MAX_FILE_SIZE)? MAX_FILE_SIZE:file->size;
  ------------------
  |  |  229|  22.6k|#define MAX_FILE_SIZE 65535
  ------------------
              					len = (file->size > MAX_FILE_SIZE)? MAX_FILE_SIZE:file->size;
  ------------------
  |  |  229|      0|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (2538:12): [True: 0, False: 22.6k]
  ------------------
 2539|  6.99k|				else
 2540|  6.99k|					len = 1024;
 2541|  29.6k|				offset = 0;
 2542|  29.6k|			}
 2543|     34|			else {
 2544|     34|				offset = in_path->index;
 2545|     34|				len = in_path->count;
 2546|       |				/* Make sure we're within proper bounds */
 2547|     34|				if (offset >= file->size || offset + len > file->size) {
  ------------------
  |  Branch (2547:9): [True: 9, False: 25]
  |  Branch (2547:33): [True: 7, False: 18]
  ------------------
 2548|     16|					r = SC_ERROR_INVALID_ASN1_OBJECT;
  ------------------
  |  |   82|     16|#define SC_ERROR_INVALID_ASN1_OBJECT		-1401
  ------------------
 2549|     16|					goto fail_unlock;
 2550|     16|				}
 2551|     34|			}
 2552|  29.6k|		}
 2553|       |
 2554|  29.6k|		free(data);
 2555|  29.6k|		data = malloc(len);
 2556|  29.6k|		if (data == NULL) {
  ------------------
  |  Branch (2556:7): [True: 0, False: 29.6k]
  ------------------
 2557|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2558|      0|			goto fail_unlock;
 2559|      0|		}
 2560|       |
 2561|  29.6k|		if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE_TLV) {
  ------------------
  |  |  225|  29.6k|#define SC_FILE_EF_LINEAR_VARIABLE_TLV	0x05
  ------------------
  |  Branch (2561:7): [True: 782, False: 28.8k]
  ------------------
 2562|    782|			unsigned int i;
 2563|    782|			size_t l, record_len;
 2564|    782|			unsigned char *head = data;
 2565|       |
 2566|  1.02k|			for (i=1; ; i++) {
 2567|  1.02k|				l = len - (head - data);
 2568|  1.02k|				if (l > 256) {
  ------------------
  |  Branch (2568:9): [True: 771, False: 253]
  ------------------
 2569|    771|					l = 256;
 2570|    771|				}
 2571|  1.02k|				r = sc_read_record(p15card->card, i, 0, head, l, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1305|  1.02k|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
 2572|  1.02k|				if (r == SC_ERROR_RECORD_NOT_FOUND)
  ------------------
  |  |   52|  1.02k|#define SC_ERROR_RECORD_NOT_FOUND		-1202
  ------------------
  |  Branch (2572:9): [True: 6, False: 1.01k]
  ------------------
 2573|      6|					break;
 2574|  1.01k|				if (r < 0) {
  ------------------
  |  Branch (2574:9): [True: 758, False: 260]
  ------------------
 2575|    758|					goto fail_unlock;
 2576|    758|				}
 2577|    260|				if (r < 2)
  ------------------
  |  Branch (2577:9): [True: 17, False: 243]
  ------------------
 2578|     17|					break;
 2579|    243|				record_len = head[1];
 2580|    243|				if (record_len != 0xff) {
  ------------------
  |  Branch (2580:9): [True: 232, False: 11]
  ------------------
 2581|    232|					memmove(head, head+2, r-2);
 2582|    232|					head += (r-2);
 2583|    232|				}
 2584|     11|				else {
 2585|     11|					if (r < 4)
  ------------------
  |  Branch (2585:10): [True: 1, False: 10]
  ------------------
 2586|      1|						break;
 2587|     10|					memmove(head, head+4, r-4);
 2588|     10|					head += (r-4);
 2589|     10|				}
 2590|    243|			}
 2591|     24|			len = head-data;
 2592|     24|		}
 2593|  28.8k|		else if (file->ef_structure == SC_FILE_EF_LINEAR_VARIABLE) {
  ------------------
  |  |  224|  28.8k|#define SC_FILE_EF_LINEAR_VARIABLE	0x04
  ------------------
  |  Branch (2593:12): [True: 0, False: 28.8k]
  ------------------
 2594|      0|			r = sc_read_record(p15card->card, in_path->index, (unsigned)offset, data, len, SC_RECORD_BY_REC_NR);
  ------------------
  |  | 1305|      0|#define SC_RECORD_BY_REC_NR		0x00100UL
  ------------------
 2595|      0|			if (r < 0) {
  ------------------
  |  Branch (2595:8): [True: 0, False: 0]
  ------------------
 2596|      0|				goto fail_unlock;
 2597|      0|			}
 2598|       |			/* sc_read_record may return less than requested */
 2599|      0|			len = r;
 2600|      0|		}
 2601|  28.8k|		else {
 2602|  28.8k|			unsigned long flags = 0;
 2603|  28.8k|			r = sc_read_binary(p15card->card, (unsigned)offset, data, len, &flags);
 2604|  28.8k|			if (r < 0) {
  ------------------
  |  Branch (2604:8): [True: 27.9k, False: 900]
  ------------------
 2605|  27.9k|				goto fail_unlock;
 2606|  27.9k|			}
 2607|       |			/* sc_read_binary may return less than requested */
 2608|    900|			len = r;
 2609|       |
 2610|    900|			if (flags & SC_FILE_FLAG_COMPRESSED_AUTO
  ------------------
  |  |  230|  1.80k|#define SC_FILE_FLAG_COMPRESSED_AUTO		0x01
  ------------------
  |  Branch (2610:8): [True: 0, False: 900]
  ------------------
 2611|    900|			    || flags & SC_FILE_FLAG_COMPRESSED_ZLIB
  ------------------
  |  |  231|  1.80k|#define SC_FILE_FLAG_COMPRESSED_ZLIB		0x02
  ------------------
  |  Branch (2611:11): [True: 0, False: 900]
  ------------------
 2612|    900|			    || flags & SC_FILE_FLAG_COMPRESSED_GZIP) {
  ------------------
  |  |  232|    900|#define SC_FILE_FLAG_COMPRESSED_GZIP		0x04
  ------------------
  |  Branch (2612:11): [True: 0, False: 900]
  ------------------
 2613|      0|				unsigned char *decompressed_buf = NULL;
 2614|      0|				size_t decompressed_len = 0;
 2615|      0|				r = decompress_file(p15card->card, data, len, &decompressed_buf, &decompressed_len, flags);
 2616|      0|				if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (2616:9): [True: 0, False: 0]
  ------------------
 2617|      0|					goto fail_unlock;
 2618|      0|				}
 2619|      0|				free(data);
 2620|      0|				data = decompressed_buf;
 2621|      0|				len = decompressed_len;
 2622|      0|			}
 2623|    900|		}
 2624|    924|		sc_unlock(p15card->card);
 2625|       |
 2626|    924|		sc_file_free(file);
 2627|       |
 2628|    924|		if (len && p15card->opts.use_file_cache
  ------------------
  |  Branch (2628:7): [True: 670, False: 254]
  |  Branch (2628:14): [True: 180, False: 490]
  ------------------
 2629|    180|		    && ((p15card->opts.use_file_cache & SC_PKCS15_OPTS_CACHE_ALL_FILES) || !private_data)) {
  ------------------
  |  |  606|    180|#define SC_PKCS15_OPTS_CACHE_ALL_FILES			2
  ------------------
  |  Branch (2629:11): [True: 0, False: 180]
  |  Branch (2629:78): [True: 180, False: 0]
  ------------------
 2630|    180|			sc_pkcs15_cache_file(p15card, in_path, data, len);
 2631|    180|		}
 2632|    924|		if (len == 0) {
  ------------------
  |  Branch (2632:7): [True: 254, False: 670]
  ------------------
 2633|    254|			free(data);
 2634|    254|			data = NULL;
 2635|    254|		}
 2636|    924|	}
 2637|  1.04k|	*buf = data;
 2638|  1.04k|	*buflen = len;
 2639|  1.04k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.04k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.04k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.04k|	int _ret = r; \
  |  |  |  |  155|  1.04k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.04k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.04k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.04k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.04k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.04k|	} else { \
  |  |  |  |  159|      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.04k|	return _ret; \
  |  |  |  |  163|  1.04k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2640|       |
 2641|   318k|fail_unlock:
 2642|   318k|	sc_unlock(p15card->card);
 2643|   318k|fail:
 2644|   318k|	free(data);
 2645|   318k|	sc_file_free(file);
 2646|   318k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|   318k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|   318k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|   318k|	int _ret = r; \
  |  |  |  |  155|   318k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 318k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|   318k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|   318k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 318k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|   318k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|   318k|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|   318k|	return _ret; \
  |  |  |  |  163|   318k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2647|   318k|}
sc_pkcs15_compare_id:
 2652|   110k|{
 2653|   110k|	if (id1 == NULL || id2 == NULL)
  ------------------
  |  Branch (2653:6): [True: 0, False: 110k]
  |  Branch (2653:21): [True: 0, False: 110k]
  ------------------
 2654|      0|		return 0;
 2655|   110k|	if (id1->len != id2->len)
  ------------------
  |  Branch (2655:6): [True: 24.3k, False: 85.9k]
  ------------------
 2656|  24.3k|		return 0;
 2657|  85.9k|	return memcmp(id1->value, id2->value, id1->len) == 0;
 2658|   110k|}
sc_pkcs15_format_id:
 2663|  8.23k|{
 2664|  8.23k|	size_t len;
 2665|       |
 2666|  8.23k|	if (!id)
  ------------------
  |  Branch (2666:6): [True: 0, False: 8.23k]
  ------------------
 2667|      0|		return;
 2668|  8.23k|	len = sizeof(id->value);
 2669|       |
 2670|  8.23k|	if (sc_hex_to_bin(str, id->value, &len) != SC_SUCCESS)
  ------------------
  |  |   28|  8.23k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2670:6): [True: 337, False: 7.89k]
  ------------------
 2671|    337|		id->len = 0;
 2672|  7.89k|	else
 2673|  7.89k|		id->len = len;
 2674|  8.23k|}
sc_pkcs15_print_id:
 2679|  5.63k|{
 2680|  5.63k|	static char buffer[256];
 2681|       |
 2682|  5.63k|	sc_bin_to_hex(id->value, id->len, buffer, sizeof(buffer), '\0');
 2683|  5.63k|	return buffer;
 2684|  5.63k|}
sc_pkcs15_make_absolute_path:
 2697|  11.4k|{
 2698|       |	/* nothing to do if child has valid 'aid' */
 2699|  11.4k|	if (child->aid.len)
  ------------------
  |  Branch (2699:6): [True: 0, False: 11.4k]
  ------------------
 2700|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2701|       |
 2702|  11.4k|	if (parent->aid.len)   {
  ------------------
  |  Branch (2702:6): [True: 0, False: 11.4k]
  ------------------
 2703|      0|		sc_path_t ppath;
 2704|       |
 2705|       |		/* child inherits parent's 'aid' */
 2706|      0|		child->aid = parent->aid;
 2707|      0|		if (!parent->len)
  ------------------
  |  Branch (2707:7): [True: 0, False: 0]
  ------------------
 2708|      0|			return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2709|       |
 2710|       |		/* parent has valid 'path' -- concatenate it with the child's one */
 2711|      0|		memcpy(&ppath, parent, sizeof(sc_path_t));
 2712|      0|		ppath.aid.len = 0;
 2713|      0|		ppath.type = SC_PATH_TYPE_FROM_CURRENT;
  ------------------
  |  |  122|      0|#define SC_PATH_TYPE_FROM_CURRENT	4
  ------------------
 2714|      0|		return sc_concatenate_path(child, &ppath, child);
 2715|       |
 2716|      0|	}
 2717|  11.4k|	else if (parent->type == SC_PATH_TYPE_DF_NAME)   {
  ------------------
  |  |  118|  11.4k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (2717:11): [True: 26, False: 11.4k]
  ------------------
 2718|       |		/* child inherits parent's 'DF NAME' as 'aid' */
 2719|     26|		if (parent->len > sizeof(child->aid.value))
  ------------------
  |  Branch (2719:7): [True: 0, False: 26]
  ------------------
 2720|      0|			return SC_ERROR_WRONG_LENGTH;
  ------------------
  |  |   56|      0|#define SC_ERROR_WRONG_LENGTH			-1206
  ------------------
 2721|       |
 2722|     26|		memcpy(child->aid.value, parent->value, parent->len);
 2723|     26|		child->aid.len = parent->len;
 2724|       |
 2725|     26|		return SC_SUCCESS;
  ------------------
  |  |   28|     26|#define SC_SUCCESS				0
  ------------------
 2726|     26|	}
 2727|       |
 2728|       |	/* a 0 length path stays a 0 length path */
 2729|  11.4k|	if (child->len == 0)
  ------------------
  |  Branch (2729:6): [True: 675, False: 10.7k]
  ------------------
 2730|    675|		return SC_SUCCESS;
  ------------------
  |  |   28|    675|#define SC_SUCCESS				0
  ------------------
 2731|       |
 2732|  10.7k|	if (sc_compare_path_prefix(sc_get_mf_path(), child))
  ------------------
  |  Branch (2732:6): [True: 1.74k, False: 9.02k]
  ------------------
 2733|  1.74k|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.74k|#define SC_SUCCESS				0
  ------------------
 2734|       |
 2735|  9.02k|	return sc_concatenate_path(child, parent, child);
 2736|  10.7k|}
sc_pkcs15_free_object_content:
 2740|  13.6k|{
 2741|  13.6k|	if (obj->content.value && obj->content.len) {
  ------------------
  |  Branch (2741:6): [True: 108, False: 13.5k]
  |  Branch (2741:28): [True: 108, False: 0]
  ------------------
 2742|    108|		if (obj->content_free) {
  ------------------
  |  Branch (2742:7): [True: 34, False: 74]
  ------------------
 2743|     34|			obj->content_free(obj->content.value, obj->content.len);
 2744|     74|		} else {
 2745|     74|			free(obj->content.value);
 2746|     74|		}
 2747|    108|	}
 2748|       |	obj->content.value = NULL;
 2749|  13.6k|	obj->content.len = 0;
 2750|  13.6k|}
sc_pkcs15_allocate_object_content:
 2756|     34|{
 2757|     34|	unsigned char *tmp_buf;
 2758|       |
 2759|     34|	if (!obj)
  ------------------
  |  Branch (2759:6): [True: 0, False: 34]
  ------------------
 2760|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2761|       |
 2762|     34|	if (!value || !len)   {
  ------------------
  |  Branch (2762:6): [True: 0, False: 34]
  |  Branch (2762:16): [True: 0, False: 34]
  ------------------
 2763|      0|		sc_pkcs15_free_object_content(obj);
 2764|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2765|      0|	}
 2766|       |
 2767|       |	/* Need to pass by temporary variable,
 2768|       |	 * because 'value' and 'content.value' pointers can be the sames.
 2769|       |	 */
 2770|     34|	if (SC_PKCS15_TYPE_AUTH & obj->type
  ------------------
  |  |  444|     34|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (2770:6): [True: 34, False: 0]
  ------------------
 2771|      0|			|| SC_PKCS15_TYPE_SKEY & obj->type
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (2771:7): [True: 0, False: 0]
  ------------------
 2772|     34|			|| SC_PKCS15_TYPE_PRKEY & obj->type) {
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2772:7): [True: 0, False: 0]
  ------------------
 2773|     34|		tmp_buf = sc_mem_secure_alloc(len);
 2774|     34|		obj->content_free = sc_mem_secure_free;
 2775|     34|	} else {
 2776|      0|		tmp_buf = malloc(len);
 2777|      0|	}
 2778|     34|	if (!tmp_buf)
  ------------------
  |  Branch (2778:6): [True: 0, False: 34]
  ------------------
 2779|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2780|       |
 2781|     34|	memcpy(tmp_buf, value, len);
 2782|       |
 2783|     34|	sc_pkcs15_free_object_content(obj);
 2784|       |
 2785|     34|	obj->content.value = tmp_buf;
 2786|     34|	obj->content.len = len;
 2787|       |
 2788|     34|	return SC_SUCCESS;
  ------------------
  |  |   28|     34|#define SC_SUCCESS				0
  ------------------
 2789|     34|}
sc_pkcs15_get_specific_supported_algo:
 2815|  2.69k|{
 2816|  2.69k|	struct sc_context *ctx = p15card->card->ctx;
 2817|  2.69k|	struct sc_supported_algo_info *info = NULL;
 2818|  2.69k|	int ii;
 2819|       |
 2820|  2.69k|	if (algo_oid == NULL)
  ------------------
  |  Branch (2820:6): [True: 0, False: 2.69k]
  ------------------
 2821|      0|		return NULL;
 2822|       |
 2823|  5.70k|	for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo->supported_algos[ii].reference; ii++)
  ------------------
  |  |   61|  11.4k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (2823:12): [True: 5.70k, False: 0]
  |  Branch (2823:46): [True: 3.04k, False: 2.65k]
  ------------------
 2824|  3.04k|		if ((p15card->tokeninfo->supported_algos[ii].operations & operation)
  ------------------
  |  Branch (2824:7): [True: 2.90k, False: 139]
  ------------------
 2825|  2.90k|				&& (p15card->tokeninfo->supported_algos[ii].mechanism == mechanism)
  ------------------
  |  Branch (2825:8): [True: 748, False: 2.16k]
  ------------------
 2826|    748|				&& sc_compare_oid(algo_oid, &p15card->tokeninfo->supported_algos[ii].algo_id) == 1)
  ------------------
  |  Branch (2826:8): [True: 31, False: 717]
  ------------------
 2827|     31|			break;
 2828|       |
 2829|  2.69k|	if (ii < SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo->supported_algos[ii].reference)   {
  ------------------
  |  |   61|  5.38k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (2829:6): [True: 2.69k, False: 0]
  |  Branch (2829:42): [True: 31, False: 2.65k]
  ------------------
 2830|     31|		info = &p15card->tokeninfo->supported_algos[ii];
 2831|     31|		sc_log(ctx, "found supported algorithm (ref:%X,mech:%X,ops:%X,algo_ref:%X)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2832|     31|				info->reference, info->mechanism, info->operations, info->algo_ref);
 2833|     31|	}
 2834|       |
 2835|  2.69k|	return info;
 2836|  2.69k|}
sc_pkcs15_get_generalized_time:
 2840|    767|{
 2841|    767|#ifdef HAVE_GETTIMEOFDAY
 2842|    767|	struct timeval tv;
 2843|    767|#endif
 2844|    767|	struct tm tm;
 2845|    767|	time_t t;
 2846|       |
 2847|    767|	if (!ctx || !out)
  ------------------
  |  Branch (2847:6): [True: 0, False: 767]
  |  Branch (2847:14): [True: 0, False: 767]
  ------------------
 2848|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2849|    767|	*out = NULL;
 2850|       |
 2851|    767|#ifdef HAVE_GETTIMEOFDAY
 2852|    767|	gettimeofday(&tv, NULL);
 2853|    767|	t = tv.tv_sec;
 2854|       |#else
 2855|       |	t = time(NULL);
 2856|       |#endif
 2857|       |
 2858|       |#ifdef _WIN32
 2859|       |	if (0 != gmtime_s(&tm, &t))
 2860|       |		LOG_FUNC_RETURN(ctx, SC_ERROR_INTERNAL);
 2861|       |#else
 2862|    767|	if (NULL == gmtime_r(&t, &tm))
  ------------------
  |  Branch (2862:6): [True: 0, False: 767]
  ------------------
 2863|    767|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2864|    767|#endif
 2865|       |
 2866|    767|	*out = calloc(1, 16);
 2867|    767|	if (*out == NULL)
  ------------------
  |  Branch (2867:6): [True: 0, False: 767]
  ------------------
 2868|    767|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "memory failure");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2869|       |
 2870|       |	/* print time in generalized time format */
 2871|    767|	if (!strftime(*out, 16, "%Y%m%d%H%M%SZ", &tm)) {
  ------------------
  |  Branch (2871:6): [True: 0, False: 767]
  ------------------
 2872|      0|		free(*out);
 2873|      0|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "strftime 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2874|      0|	}
 2875|       |
 2876|    767|	return SC_SUCCESS;
  ------------------
  |  |   28|    767|#define SC_SUCCESS				0
  ------------------
 2877|    767|}
sc_pkcs15_add_supported_algo_ref:
 2882|  1.35k|{
 2883|  1.35k|	unsigned int ii, *algo_refs = NULL;
 2884|       |
 2885|  1.35k|	if (!algo)
  ------------------
  |  Branch (2885:6): [True: 0, False: 1.35k]
  ------------------
 2886|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2887|       |
 2888|  1.35k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  1.35k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (2888:10): [True: 1.35k, False: 0]
  ------------------
 2889|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2889:2): [True: 0, False: 1.35k]
  ------------------
 2890|      0|		algo_refs = ((struct sc_pkcs15_prkey_info *)obj->data)->algo_refs;
 2891|      0|		break;
 2892|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (2892:2): [True: 0, False: 1.35k]
  ------------------
 2893|      0|		algo_refs = ((struct sc_pkcs15_pubkey_info *)obj->data)->algo_refs;
 2894|      0|		break;
 2895|  1.35k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  1.35k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (2895:2): [True: 1.35k, False: 0]
  ------------------
 2896|  1.35k|		algo_refs = ((struct sc_pkcs15_skey_info *)obj->data)->algo_refs;
 2897|  1.35k|		break;
 2898|  1.35k|	}
 2899|  1.35k|	if (!algo_refs)
  ------------------
  |  Branch (2899:6): [True: 0, False: 1.35k]
  ------------------
 2900|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2901|       |
 2902|  2.02k|	for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && *(algo_refs + ii);ii++)
  ------------------
  |  |   61|  4.05k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (2902:12): [True: 2.02k, False: 0]
  |  Branch (2902:46): [True: 676, False: 1.35k]
  ------------------
 2903|    676|		if (*(algo_refs + ii) == algo->reference)
  ------------------
  |  Branch (2903:7): [True: 1, False: 675]
  ------------------
 2904|      1|			return SC_SUCCESS;
  ------------------
  |  |   28|  1.35k|#define SC_SUCCESS				0
  ------------------
 2905|       |
 2906|  2.02k|	for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS;ii++)   {
  ------------------
  |  |   61|  2.02k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (2906:12): [True: 2.02k, False: 0]
  ------------------
 2907|  2.02k|		if (*(algo_refs + ii) == 0)   {
  ------------------
  |  Branch (2907:7): [True: 1.35k, False: 675]
  ------------------
 2908|  1.35k|			*(algo_refs + ii) = algo->reference;
 2909|  1.35k|			return SC_SUCCESS;
  ------------------
  |  |   28|  1.35k|#define SC_SUCCESS				0
  ------------------
 2910|  1.35k|		}
 2911|  2.02k|	}
 2912|       |
 2913|      0|	return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
 2914|  1.35k|}
sc_pkcs15_free_key_params:
 3094|  3.01k|{
 3095|  3.01k|	if (!params)
  ------------------
  |  Branch (3095:6): [True: 0, False: 3.01k]
  ------------------
 3096|      0|		return;
 3097|  3.01k|	if (params->data && params->free_params)
  ------------------
  |  Branch (3097:6): [True: 706, False: 2.30k]
  |  Branch (3097:22): [True: 676, False: 30]
  ------------------
 3098|    676|		params->free_params(params->data);
 3099|  2.33k|	else if (params->data)
  ------------------
  |  Branch (3099:11): [True: 30, False: 2.30k]
  ------------------
 3100|     30|		free(params->data);
 3101|       |
 3102|       |	params->data = NULL;
 3103|  3.01k|}
pkcs15.c:sc_pkcs15_clear_tokeninfo:
  748|  15.2k|{
  749|  15.2k|	if (!tokeninfo)
  ------------------
  |  Branch (749:6): [True: 0, False: 15.2k]
  ------------------
  750|      0|		return;
  751|       |
  752|  15.2k|	free(tokeninfo->label);
  753|  15.2k|	tokeninfo->label = NULL;
  754|  15.2k|	free(tokeninfo->serial_number);
  755|  15.2k|	tokeninfo->serial_number = NULL;
  756|  15.2k|	free(tokeninfo->manufacturer_id);
  757|  15.2k|	tokeninfo->manufacturer_id = NULL;
  758|  15.2k|	free(tokeninfo->last_update.gtime);
  759|  15.2k|	tokeninfo->last_update.gtime = NULL;
  760|  15.2k|	free(tokeninfo->preferred_language);
  761|  15.2k|	tokeninfo->preferred_language = NULL;
  762|  15.2k|	free(tokeninfo->profile_indication.name);
  763|  15.2k|	tokeninfo->profile_indication.name = NULL;
  764|  15.2k|	if (tokeninfo->seInfo != NULL) {
  ------------------
  |  Branch (764:6): [True: 19, False: 15.1k]
  ------------------
  765|     19|		unsigned i;
  766|     80|		for (i = 0; i < tokeninfo->num_seInfo; i++)
  ------------------
  |  Branch (766:15): [True: 61, False: 19]
  ------------------
  767|     61|			free(tokeninfo->seInfo[i]);
  768|     19|		free(tokeninfo->seInfo);
  769|       |		tokeninfo->seInfo = NULL;
  770|     19|	}
  771|  15.2k|}
pkcs15.c:sc_dup_app_info:
  902|    159|{
  903|    159|	struct sc_app_info *out = calloc(1, sizeof(struct sc_app_info));
  904|       |
  905|    159|	if (!out)
  ------------------
  |  Branch (905:6): [True: 0, False: 159]
  ------------------
  906|      0|		return NULL;
  907|       |
  908|    159|	memcpy(out, info, sizeof(struct sc_app_info));
  909|       |
  910|    159|	if (info->label) {
  ------------------
  |  Branch (910:6): [True: 117, False: 42]
  ------------------
  911|    117|		out->label = strdup(info->label);
  912|    117|		if (!out->label) {
  ------------------
  |  Branch (912:7): [True: 0, False: 117]
  ------------------
  913|      0|			free(out);
  914|      0|			return NULL;
  915|      0|		}
  916|    117|	} else
  917|     42|		out->label = NULL;
  918|       |
  919|    159|	out->ddo.value = malloc(info->ddo.len);
  920|    159|	if (!out->ddo.value) {
  ------------------
  |  Branch (920:6): [True: 0, False: 159]
  ------------------
  921|      0|		free(out->label);
  922|      0|		free(out);
  923|      0|		return NULL;
  924|      0|	}
  925|    159|	memcpy(out->ddo.value, info->ddo.value, info->ddo.len);
  926|    159|	out->ddo.len = info->ddo.len;
  927|       |
  928|    159|	return out;
  929|    159|}
pkcs15.c:parse_ddo:
  467|     18|{
  468|     18|	struct sc_context *ctx = p15card->card->ctx;
  469|     18|	struct sc_asn1_entry asn1_ddo[7];
  470|     18|	sc_path_t odf_path, ti_path, us_path;
  471|     18|	struct sc_iid iid;
  472|     18|	struct sc_aid aid;
  473|     18|	int r;
  474|       |
  475|     18|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|       |
  477|     18|	iid.len = sizeof(iid.value);
  478|     18|	aid.len = sizeof(aid.value);
  479|       |
  480|     18|	sc_copy_asn1_entry(c_asn1_ddo, asn1_ddo);
  481|     18|	sc_format_asn1_entry(asn1_ddo + 1, &odf_path, NULL, 0);
  482|     18|	sc_format_asn1_entry(asn1_ddo + 2, &ti_path, NULL, 0);
  483|     18|	sc_format_asn1_entry(asn1_ddo + 3, &us_path, NULL, 0);
  484|     18|	sc_format_asn1_entry(asn1_ddo + 4, iid.value, &iid.len, 0);
  485|     18|	sc_format_asn1_entry(asn1_ddo + 5, aid.value, &aid.len, 0);
  486|       |
  487|     18|	r = sc_asn1_decode(ctx, asn1_ddo, buf, buflen, NULL, NULL);
  488|     18|	LOG_TEST_RET(ctx, r, "DDO parsing 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|       |
  490|      9|	if (asn1_ddo[1].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      9|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (490:6): [True: 2, False: 7]
  ------------------
  491|      2|		sc_file_free(p15card->file_odf);
  492|      2|		p15card->file_odf = sc_file_new();
  493|      2|		if (p15card->file_odf == NULL)
  ------------------
  |  Branch (493:7): [True: 0, False: 2]
  ------------------
  494|      0|			goto mem_err;
  495|      2|		p15card->file_odf->path = odf_path;
  496|      2|	}
  497|      9|	if (asn1_ddo[2].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      9|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (497:6): [True: 0, False: 9]
  ------------------
  498|      0|		sc_file_free(p15card->file_tokeninfo);
  499|      0|		p15card->file_tokeninfo = sc_file_new();
  500|      0|		if (p15card->file_tokeninfo == NULL)
  ------------------
  |  Branch (500:7): [True: 0, False: 0]
  ------------------
  501|      0|			goto mem_err;
  502|      0|		p15card->file_tokeninfo->path = ti_path;
  503|      0|	}
  504|      9|	if (asn1_ddo[3].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      9|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (504:6): [True: 0, False: 9]
  ------------------
  505|      0|		sc_file_free(p15card->file_unusedspace);
  506|      0|		p15card->file_unusedspace = sc_file_new();
  507|      0|		if (p15card->file_unusedspace == NULL)
  ------------------
  |  Branch (507:7): [True: 0, False: 0]
  ------------------
  508|      0|			goto mem_err;
  509|      0|		p15card->file_unusedspace->path = us_path;
  510|      0|	}
  511|      9|	if (asn1_ddo[4].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      9|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (511:6): [True: 0, False: 9]
  ------------------
  512|      0|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "DDO.IID '%s'", sc_dump_hex(iid.value, iid.len));
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  513|      0|		memcpy(&p15card->app->ddo.iid, &iid, sizeof(struct sc_iid));
  514|      0|	}
  515|      9|	if (asn1_ddo[5].flags & SC_ASN1_PRESENT) {
  ------------------
  |  |  147|      9|#define SC_ASN1_PRESENT			0x00000001
  ------------------
  |  Branch (515:6): [True: 2, False: 7]
  ------------------
  516|      2|		sc_debug(ctx, SC_LOG_DEBUG_ASN1, "DDO.AID '%s'", sc_dump_hex(aid.value, aid.len));
  ------------------
  |  |   70|      2|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  517|      2|		memcpy(&p15card->app->ddo.aid, &aid, sizeof(struct sc_aid));
  518|      2|	}
  519|       |
  520|      9|	fix_authentic_ddo(p15card);
  521|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  522|      0|mem_err:
  523|      0|	sc_file_free(p15card->file_odf);
  524|      0|	p15card->file_odf = NULL;
  525|      0|	sc_file_free(p15card->file_tokeninfo);
  526|      0|	p15card->file_tokeninfo = NULL;
  527|      0|	sc_file_free(p15card->file_unusedspace);
  528|      0|	p15card->file_unusedspace = NULL;
  529|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  530|      0|}
pkcs15.c:fix_authentic_ddo:
  453|      9|{
  454|       |	/* AuthentIC v3.2 card has invalid ODF and tokenInfo paths encoded into DDO.
  455|       |	 * Cleanup this attributes -- default values must be OK.
  456|       |	 */
  457|      9|	if (p15card->card->type == SC_CARD_TYPE_OBERTHUR_AUTHENTIC_3_2)   {
  ------------------
  |  Branch (457:6): [True: 0, False: 9]
  ------------------
  458|      0|		sc_file_free(p15card->file_odf);
  459|      0|		p15card->file_odf = NULL;
  460|      0|		sc_file_free(p15card->file_tokeninfo);
  461|       |		p15card->file_tokeninfo = NULL;
  462|      0|	}
  463|      9|}
pkcs15.c:parse_odf:
  615|  1.24k|{
  616|  1.24k|	const unsigned char *p = buf;
  617|  1.24k|	size_t left = buflen;
  618|  1.24k|	int r, i, type;
  619|  1.24k|	struct sc_path path;
  620|  1.24k|	struct sc_asn1_entry asn1_obj_or_path[] = {
  621|  1.24k|		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  174|  1.24k|#define SC_ASN1_PATH			256
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  141|  1.24k|#define SC_ASN1_CONS			0x20000000
  ------------------
              		{ "path", SC_ASN1_PATH, SC_ASN1_CONS | SC_ASN1_SEQUENCE, 0, &path, NULL },
  ------------------
  |  |  162|  1.24k|#define SC_ASN1_SEQUENCE                16
  ------------------
  622|  1.24k|		{ NULL, 0, 0, 0, NULL, NULL }
  623|  1.24k|	};
  624|  1.24k|	struct sc_asn1_entry asn1_odf[10];
  625|       |
  626|  1.24k|	sc_copy_asn1_entry(c_asn1_odf, asn1_odf);
  627|  12.4k|	for (i = 0; asn1_odf[i].name != NULL; i++)
  ------------------
  |  Branch (627:14): [True: 11.2k, False: 1.24k]
  ------------------
  628|  11.2k|		sc_format_asn1_entry(asn1_odf + i, asn1_obj_or_path, NULL, 0);
  629|  6.10k|	while (left > 0) {
  ------------------
  |  Branch (629:9): [True: 6.10k, False: 3]
  ------------------
  630|  6.10k|		r = sc_asn1_decode_choice(p15card->card->ctx, asn1_odf, p, left, &p, &left);
  631|  6.10k|		if (r == SC_ERROR_ASN1_END_OF_CONTENTS)
  ------------------
  |  |   84|  6.10k|#define SC_ERROR_ASN1_END_OF_CONTENTS		-1403
  ------------------
  |  Branch (631:7): [True: 1.19k, False: 4.91k]
  ------------------
  632|  1.19k|			break;
  633|  4.91k|		if (r < 0)
  ------------------
  |  Branch (633:7): [True: 49, False: 4.86k]
  ------------------
  634|     49|			return r;
  635|  4.86k|		type = r;
  636|  4.86k|		if (p15card->file_app) {
  ------------------
  |  Branch (636:7): [True: 4.86k, False: 0]
  ------------------
  637|  4.86k|			r = sc_pkcs15_make_absolute_path(&p15card->file_app->path, &path);
  638|  4.86k|			if (r < 0)
  ------------------
  |  Branch (638:8): [True: 0, False: 4.86k]
  ------------------
  639|      0|				return r;
  640|  4.86k|			r = sc_pkcs15_add_df(p15card, odf_indexes[type], &path);
  641|  4.86k|			if (r)
  ------------------
  |  Branch (641:8): [True: 0, False: 4.86k]
  ------------------
  642|      0|				return r;
  643|  4.86k|		}
  644|  4.86k|	}
  645|  1.19k|	return 0;
  646|  1.24k|}
pkcs15.c:__sc_pkcs15_search_objects:
 1402|   734k|{
 1403|   734k|	struct sc_pkcs15_object *obj = NULL;
 1404|   734k|	struct sc_pkcs15_df	*df = NULL;
 1405|   734k|	unsigned int	df_mask = 0;
 1406|   734k|	size_t		match_count = 0;
 1407|   734k|	int r;
 1408|       |
 1409|   734k|	if (type)
  ------------------
  |  Branch (1409:6): [True: 387k, False: 346k]
  ------------------
 1410|   387k|		class_mask |= SC_PKCS15_TYPE_TO_CLASS(type);
  ------------------
  |  |  449|   387k|#define SC_PKCS15_TYPE_TO_CLASS(t)		(1 << ((t) >> 8))
  ------------------
 1411|       |
 1412|       |	/* Make sure the class mask we have makes sense */
 1413|   734k|	if (class_mask == 0
  ------------------
  |  Branch (1413:6): [True: 0, False: 734k]
  ------------------
 1414|   734k|			|| (class_mask & ~(
  ------------------
  |  Branch (1414:7): [True: 0, False: 734k]
  ------------------
 1415|   734k|					SC_PKCS15_SEARCH_CLASS_PRKEY |
  ------------------
  |  |  450|   734k|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
 1416|   734k|					SC_PKCS15_SEARCH_CLASS_PUBKEY |
  ------------------
  |  |  451|   734k|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
 1417|   734k|					SC_PKCS15_SEARCH_CLASS_SKEY |
  ------------------
  |  |  452|   734k|#define SC_PKCS15_SEARCH_CLASS_SKEY		0x0008U
  ------------------
 1418|   734k|					SC_PKCS15_SEARCH_CLASS_CERT |
  ------------------
  |  |  453|   734k|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
 1419|   734k|					SC_PKCS15_SEARCH_CLASS_DATA |
  ------------------
  |  |  454|   734k|#define SC_PKCS15_SEARCH_CLASS_DATA		0x0020U
  ------------------
 1420|   734k|					SC_PKCS15_SEARCH_CLASS_AUTH))) {
  ------------------
  |  |  455|   734k|#define SC_PKCS15_SEARCH_CLASS_AUTH		0x0040U
  ------------------
 1421|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1422|      0|	}
 1423|       |
 1424|   734k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_PRKEY)
  ------------------
  |  |  450|   734k|#define SC_PKCS15_SEARCH_CLASS_PRKEY		0x0002U
  ------------------
  |  Branch (1424:6): [True: 351k, False: 383k]
  ------------------
 1425|   351k|		df_mask |= (1 << SC_PKCS15_PRKDF);
  ------------------
  |  |  488|   351k|#define SC_PKCS15_PRKDF			0
  ------------------
 1426|   734k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_PUBKEY)
  ------------------
  |  |  451|   734k|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
  |  Branch (1426:6): [True: 346k, False: 387k]
  ------------------
 1427|   346k|		df_mask |= (1 << SC_PKCS15_PUKDF) | (1 << SC_PKCS15_PUKDF_TRUSTED);
  ------------------
  |  |  489|   346k|#define SC_PKCS15_PUKDF			1
  ------------------
              		df_mask |= (1 << SC_PKCS15_PUKDF) | (1 << SC_PKCS15_PUKDF_TRUSTED);
  ------------------
  |  |  490|   346k|#define SC_PKCS15_PUKDF_TRUSTED		2
  ------------------
 1428|   734k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_CERT)
  ------------------
  |  |  453|   734k|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
  |  Branch (1428:6): [True: 346k, False: 387k]
  ------------------
 1429|   346k|		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  492|   346k|#define SC_PKCS15_CDF			4
  ------------------
              		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  493|   346k|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
              		df_mask |= (1 << SC_PKCS15_CDF) | (1 << SC_PKCS15_CDF_TRUSTED) | (1 << SC_PKCS15_CDF_USEFUL);
  ------------------
  |  |  494|   346k|#define SC_PKCS15_CDF_USEFUL		6
  ------------------
 1430|   734k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_DATA)
  ------------------
  |  |  454|   734k|#define SC_PKCS15_SEARCH_CLASS_DATA		0x0020U
  ------------------
  |  Branch (1430:6): [True: 4.13k, False: 730k]
  ------------------
 1431|  4.13k|		df_mask |= (1 << SC_PKCS15_DODF);
  ------------------
  |  |  495|  4.13k|#define SC_PKCS15_DODF			7
  ------------------
 1432|   734k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_AUTH)
  ------------------
  |  |  455|   734k|#define SC_PKCS15_SEARCH_CLASS_AUTH		0x0040U
  ------------------
  |  Branch (1432:6): [True: 12.1k, False: 722k]
  ------------------
 1433|  12.1k|		df_mask |= (1 << SC_PKCS15_AODF);
  ------------------
  |  |  496|  12.1k|#define SC_PKCS15_AODF			8
  ------------------
 1434|   734k|	if (class_mask & SC_PKCS15_SEARCH_CLASS_SKEY)
  ------------------
  |  |  452|   734k|#define SC_PKCS15_SEARCH_CLASS_SKEY		0x0008U
  ------------------
  |  Branch (1434:6): [True: 19.9k, False: 714k]
  ------------------
 1435|  19.9k|		df_mask |= (1 << SC_PKCS15_SKDF);
  ------------------
  |  |  491|  19.9k|#define SC_PKCS15_SKDF			3
  ------------------
 1436|       |
 1437|       |	/* Make sure all the DFs we want to search have been
 1438|       |	 * enumerated. */
 1439|  2.22M|	for (df = p15card->df_list; df != NULL; df = df->next) {
  ------------------
  |  Branch (1439:30): [True: 1.49M, False: 734k]
  ------------------
 1440|  1.49M|		if (!(df_mask & (1 << df->type)))   {
  ------------------
  |  Branch (1440:7): [True: 971k, False: 519k]
  ------------------
 1441|   971k|			continue;
 1442|   971k|		}
 1443|   519k|		if (df->enumerated)
  ------------------
  |  Branch (1443:7): [True: 189k, False: 330k]
  ------------------
 1444|   189k|			continue;
 1445|       |		/* Enumerate the DF's, so p15card->obj_list is populated. */
 1446|   330k|		if (p15card->ops.parse_df)
  ------------------
  |  Branch (1446:7): [True: 0, False: 330k]
  ------------------
 1447|      0|			r = p15card->ops.parse_df(p15card, df);
 1448|   330k|		else
 1449|   330k|			r = sc_pkcs15_parse_df(p15card, df);
 1450|   330k|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|   330k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1450:7): [True: 330k, False: 428]
  ------------------
 1451|   330k|			continue;
 1452|   330k|	}
 1453|       |
 1454|       |	/* And now loop over all objects */
 1455|  1.17M|	for (obj = p15card->obj_list; obj != NULL; obj = obj->next) {
  ------------------
  |  Branch (1455:32): [True: 442k, False: 733k]
  ------------------
 1456|       |		/* Check object type */
 1457|   442k|		if (!(class_mask & SC_PKCS15_TYPE_TO_CLASS(obj->type)))
  ------------------
  |  |  449|   442k|#define SC_PKCS15_TYPE_TO_CLASS(t)		(1 << ((t) >> 8))
  ------------------
  |  Branch (1457:7): [True: 326k, False: 116k]
  ------------------
 1458|   326k|			continue;
 1459|   116k|		if (type != 0
  ------------------
  |  Branch (1459:7): [True: 64.5k, False: 51.7k]
  ------------------
 1460|  64.5k|		 && obj->type != type
  ------------------
  |  Branch (1460:7): [True: 59.2k, False: 5.30k]
  ------------------
 1461|  59.2k|		 && (obj->type & SC_PKCS15_TYPE_CLASS_MASK) != type)
  ------------------
  |  |  416|  59.2k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (1461:7): [True: 0, False: 59.2k]
  ------------------
 1462|      0|			continue;
 1463|       |
 1464|       |		/* Potential candidate, apply search function */
 1465|   116k|		if (func != NULL && func(obj, func_arg) <= 0)
  ------------------
  |  Branch (1465:7): [True: 110k, False: 5.76k]
  |  Branch (1465:23): [True: 109k, False: 879]
  ------------------
 1466|   109k|			continue;
 1467|       |		/* Okay, we have a match. */
 1468|  6.64k|		match_count++;
 1469|  6.64k|		if (!ret || ret_size <= 0)
  ------------------
  |  Branch (1469:7): [True: 242, False: 6.40k]
  |  Branch (1469:15): [True: 0, False: 6.40k]
  ------------------
 1470|    242|			continue;
 1471|  6.40k|		ret[match_count-1] = obj;
 1472|  6.40k|		if (ret_size <= match_count)
  ------------------
  |  Branch (1472:7): [True: 637, False: 5.76k]
  ------------------
 1473|    637|			break;
 1474|  6.40k|	}
 1475|       |
 1476|   734k|	return (int)match_count;
 1477|   734k|}
pkcs15.c:compare_obj_key:
 1622|   110k|{
 1623|   110k|	struct sc_pkcs15_search_key *sk = (struct sc_pkcs15_search_key *) arg;
 1624|       |
 1625|   110k|	if (sk->id && !compare_obj_id(obj, sk->id))
  ------------------
  |  Branch (1625:6): [True: 110k, False: 204]
  |  Branch (1625:16): [True: 109k, False: 875]
  ------------------
 1626|   109k|		return 0;
 1627|  1.07k|	if (sk->app_oid && !sc_obj_app_oid(obj, sk->app_oid))
  ------------------
  |  Branch (1627:6): [True: 0, False: 1.07k]
  |  Branch (1627:21): [True: 0, False: 0]
  ------------------
 1628|      0|		return 0;
 1629|  1.07k|	if (sk->usage_mask && !compare_obj_usage(obj, sk->usage_mask, sk->usage_value))
  ------------------
  |  Branch (1629:6): [True: 0, False: 1.07k]
  |  Branch (1629:24): [True: 0, False: 0]
  ------------------
 1630|      0|		return 0;
 1631|  1.07k|	if (sk->flags_mask && !compare_obj_flags(obj, sk->flags_mask, sk->flags_value))
  ------------------
  |  Branch (1631:6): [True: 0, False: 1.07k]
  |  Branch (1631:24): [True: 0, False: 0]
  ------------------
 1632|      0|		return 0;
 1633|  1.07k|	if (sk->match_reference && !compare_obj_reference(obj, sk->reference))
  ------------------
  |  Branch (1633:6): [True: 204, False: 875]
  |  Branch (1633:29): [True: 199, False: 5]
  ------------------
 1634|    199|		return 0;
 1635|    880|	if (sk->path && !compare_obj_path(obj, sk->path))
  ------------------
  |  Branch (1635:6): [True: 5, False: 875]
  |  Branch (1635:18): [True: 1, False: 4]
  ------------------
 1636|      1|		return 0;
 1637|    879|	if (
 1638|    879|		sk->app_label && sk->label &&
  ------------------
  |  Branch (1638:3): [True: 0, False: 879]
  |  Branch (1638:20): [True: 0, False: 0]
  ------------------
 1639|      0|		!compare_obj_data_name(obj, sk->app_label, sk->label)
  ------------------
  |  Branch (1639:3): [True: 0, False: 0]
  ------------------
 1640|    879|	) {
 1641|      0|		return 0;
 1642|      0|	}
 1643|       |
 1644|    879|	return 1;
 1645|    879|}
pkcs15.c:compare_obj_id:
 1490|   110k|{
 1491|   110k|	void *data = obj->data;
 1492|       |
 1493|   110k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|   110k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (1493:10): [True: 110k, False: 0]
  ------------------
 1494|  43.2k|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|  43.2k|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1494:2): [True: 43.2k, False: 67.0k]
  ------------------
 1495|  43.2k|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_cert_info *) data)->id, id);
 1496|  56.9k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  56.9k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1496:2): [True: 56.9k, False: 53.3k]
  ------------------
 1497|  56.9k|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_prkey_info *) data)->id, id);
 1498|  8.51k|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|  8.51k|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1498:2): [True: 8.51k, False: 101k]
  ------------------
 1499|  8.51k|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_pubkey_info *) data)->id, id);
 1500|     95|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|     95|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (1500:2): [True: 95, False: 110k]
  ------------------
 1501|     95|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_skey_info *) data)->id, id);
 1502|  1.49k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  1.49k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (1502:2): [True: 1.49k, False: 108k]
  ------------------
 1503|  1.49k|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_auth_info *) data)->auth_id, id);
 1504|      0|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (1504:2): [True: 0, False: 110k]
  ------------------
 1505|      0|		return sc_pkcs15_compare_id(&((struct sc_pkcs15_data_info *) data)->id, id);
 1506|   110k|	}
 1507|      0|	return 0;
 1508|   110k|}
pkcs15.c:compare_obj_reference:
 1562|    204|{
 1563|    204|	struct sc_pkcs15_auth_info *auth_info;
 1564|    204|	void		*data = obj->data;
 1565|    204|	int		reference;
 1566|       |
 1567|    204|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    204|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 1568|    108|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|    108|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (1568:2): [True: 108, False: 96]
  ------------------
 1569|    108|		auth_info = (struct sc_pkcs15_auth_info *) obj->data;
 1570|    108|		if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    108|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1570:7): [True: 0, False: 108]
  ------------------
 1571|      0|			return 0;
 1572|    108|		reference = auth_info->attrs.pin.reference;
 1573|    108|		break;
 1574|     96|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|     96|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1574:2): [True: 96, False: 108]
  ------------------
 1575|     96|		reference = ((struct sc_pkcs15_prkey_info *) data)->key_reference;
 1576|     96|		break;
 1577|      0|	default:
  ------------------
  |  Branch (1577:2): [True: 0, False: 204]
  ------------------
 1578|      0|		return 0;
 1579|    204|	}
 1580|    204|	return reference == value;
 1581|    204|}
pkcs15.c:compare_obj_path:
 1586|      5|{
 1587|      5|	void *data = obj->data;
 1588|       |
 1589|      5|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|      5|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (1589:10): [True: 5, False: 0]
  ------------------
 1590|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1590:2): [True: 0, False: 5]
  ------------------
 1591|      0|		return sc_compare_path(&((struct sc_pkcs15_prkey_info *) data)->path, path);
 1592|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1592:2): [True: 0, False: 5]
  ------------------
 1593|      0|		return sc_compare_path(&((struct sc_pkcs15_pubkey_info *) data)->path, path);
 1594|      0|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|      0|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (1594:2): [True: 0, False: 5]
  ------------------
 1595|      0|		return sc_compare_path(&((struct sc_pkcs15_skey_info *) data)->path, path);
 1596|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1596:2): [True: 0, False: 5]
  ------------------
 1597|      0|		return sc_compare_path(&((struct sc_pkcs15_cert_info *) data)->path, path);
 1598|      5|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|      5|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (1598:2): [True: 5, False: 0]
  ------------------
 1599|      5|		return sc_compare_path(&((struct sc_pkcs15_auth_info *) data)->path, path);
 1600|      0|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (1600:2): [True: 0, False: 5]
  ------------------
 1601|      0|		return sc_compare_path(&((struct sc_pkcs15_data_info *) data)->path, path);
 1602|      5|	}
 1603|      0|	return 0;
 1604|      5|}
pkcs15.c:find_by_key:
 1651|  1.64k|{
 1652|  1.64k|	int r;
 1653|       |
 1654|  1.64k|	r = sc_pkcs15_get_objects_cond(p15card, type, compare_obj_key, sk, out, 1);
 1655|  1.64k|	if (r < 0)
  ------------------
  |  Branch (1655:6): [True: 0, False: 1.64k]
  ------------------
 1656|      0|		return r;
 1657|  1.64k|	if (r == 0)
  ------------------
  |  Branch (1657:6): [True: 1.64k, False: 4]
  ------------------
 1658|  1.64k|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|  1.64k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 1659|      4|	return 0;
 1660|  1.64k|}
pkcs15.c:sc_pkcs15_remove_objects:
 1965|  15.6k|{
 1966|  15.6k|	struct sc_pkcs15_object *cur = NULL, *next = NULL;
 1967|       |
 1968|  15.6k|	if (!p15card || !p15card->obj_list)
  ------------------
  |  Branch (1968:6): [True: 0, False: 15.6k]
  |  Branch (1968:18): [True: 14.8k, False: 800]
  ------------------
 1969|  14.8k|		return;
 1970|  2.57k|	for (cur = p15card->obj_list; cur; cur = next)   {
  ------------------
  |  Branch (1970:32): [True: 1.77k, False: 800]
  ------------------
 1971|  1.77k|		next = cur->next;
 1972|  1.77k|		sc_pkcs15_free_object(cur);
 1973|  1.77k|	}
 1974|       |
 1975|       |	p15card->obj_list = NULL;
 1976|    800|}
pkcs15.c:sc_pkcs15_remove_dfs:
 2046|  15.6k|{
 2047|  15.6k|	struct sc_pkcs15_df *cur = NULL, *next = NULL;
 2048|       |
 2049|  15.6k|	if (!p15card || !p15card->df_list)
  ------------------
  |  Branch (2049:6): [True: 0, False: 15.6k]
  |  Branch (2049:18): [True: 13.7k, False: 1.87k]
  ------------------
 2050|  13.7k|		return;
 2051|       |
 2052|  8.70k|	for (cur = p15card->df_list; cur; cur = next)   {
  ------------------
  |  Branch (2052:31): [True: 6.83k, False: 1.87k]
  ------------------
 2053|  6.83k|		next = cur->next;
 2054|  6.83k|		free(cur);
 2055|  6.83k|	}
 2056|       |
 2057|       |	p15card->df_list = NULL;
 2058|  1.87k|}
pkcs15.c:sc_pkcs15_free_unusedspace:
 2281|  10.6k|{
 2282|  10.6k|	struct sc_pkcs15_unusedspace *cur = NULL, *next = NULL;
 2283|       |
 2284|  10.6k|	if (!p15card || !p15card->unusedspace_list)
  ------------------
  |  Branch (2284:6): [True: 0, False: 10.6k]
  |  Branch (2284:18): [True: 10.6k, False: 0]
  ------------------
 2285|  10.6k|		return;
 2286|      0|	for (cur = p15card->unusedspace_list; cur; cur = next)   {
  ------------------
  |  Branch (2286:40): [True: 0, False: 0]
  ------------------
 2287|      0|		next = cur->next;
 2288|      0|		free(cur);
 2289|      0|	}
 2290|       |
 2291|       |	p15card->unusedspace_list = NULL;
 2292|      0|}

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

card-entersafe.c:sc_evp_cipher:
  135|     17|{
  136|     17|	return (EVP_CIPHER *)EVP_get_cipherbyname(algorithm);
  137|     17|}
card-entersafe.c:sc_evp_cipher_free:
  140|     17|{
  141|     17|	return;
  142|     17|}
card-epass2003.c:sc_evp_cipher:
  135|    850|{
  136|    850|	return (EVP_CIPHER *)EVP_get_cipherbyname(algorithm);
  137|    850|}
card-epass2003.c:sc_evp_cipher_free:
  140|    850|{
  141|    850|	return;
  142|    850|}

sc_get_version:
   59|  3.69k|{
   60|  3.69k|    return sc_version;
   61|  3.69k|}
sc_hex_to_bin:
   64|  80.9k|{
   65|  80.9k|	const char *sc_hex_to_bin_separators = " :";
   66|  80.9k|	if (in == NULL || out == NULL || outlen == NULL) {
  ------------------
  |  Branch (66:6): [True: 0, False: 80.9k]
  |  Branch (66:20): [True: 0, False: 80.9k]
  |  Branch (66:35): [True: 0, False: 80.9k]
  ------------------
   67|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   68|      0|	}
   69|       |
   70|  80.9k|	int byte_needs_nibble = 0;
   71|  80.9k|	int r = SC_SUCCESS;
  ------------------
  |  |   28|  80.9k|#define SC_SUCCESS				0
  ------------------
   72|  80.9k|	size_t left = *outlen;
   73|  80.9k|	u8 byte = 0;
   74|  1.56M|	while (*in != '\0' && 0 != left) {
  ------------------
  |  Branch (74:9): [True: 1.48M, False: 79.3k]
  |  Branch (74:24): [True: 1.48M, False: 27]
  ------------------
   75|  1.48M|		char c = *in++;
   76|  1.48M|		u8 nibble;
   77|  1.48M|		if      ('0' <= c && c <= '9')
  ------------------
  |  Branch (77:12): [True: 1.48M, False: 309]
  |  Branch (77:24): [True: 779k, False: 707k]
  ------------------
   78|   779k|			nibble = c - '0';
   79|   708k|		else if ('a' <= c && c <= 'f')
  ------------------
  |  Branch (79:12): [True: 138k, False: 569k]
  |  Branch (79:24): [True: 137k, False: 694]
  ------------------
   80|   137k|			nibble = c - 'a' + 10;
   81|   570k|		else if ('A' <= c && c <= 'F')
  ------------------
  |  Branch (81:12): [True: 191k, False: 379k]
  |  Branch (81:24): [True: 190k, False: 816]
  ------------------
   82|   190k|			nibble = c - 'A' + 10;
   83|   380k|		else {
   84|   380k|			if (strchr(sc_hex_to_bin_separators, (int) c)) {
  ------------------
  |  Branch (84:8): [True: 379k, False: 1.23k]
  ------------------
   85|   379k|				if (byte_needs_nibble) {
  ------------------
  |  Branch (85:9): [True: 316, False: 378k]
  ------------------
   86|    316|					r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    316|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   87|    316|					goto err;
   88|    316|				}
   89|   378k|				continue;
   90|   379k|			}
   91|  1.23k|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.23k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   92|  1.23k|			goto err;
   93|   380k|		}
   94|       |
   95|  1.10M|		if (byte_needs_nibble) {
  ------------------
  |  Branch (95:7): [True: 550k, False: 556k]
  ------------------
   96|   550k|			byte |= nibble;
   97|   550k|			*out++ = (u8) byte;
   98|   550k|			left--;
   99|   550k|			byte_needs_nibble = 0;
  100|   556k|		} else {
  101|   556k|			byte  = nibble << 4;
  102|   556k|			byte_needs_nibble = 1;
  103|   556k|		}
  104|  1.10M|	}
  105|       |
  106|  79.3k|	if (left == *outlen && 1 == byte_needs_nibble && 0 != left) {
  ------------------
  |  Branch (106:6): [True: 3.47k, False: 75.8k]
  |  Branch (106:25): [True: 3.34k, False: 133]
  |  Branch (106:51): [True: 3.34k, False: 0]
  ------------------
  107|       |		/* no output written so far, but we have a valid nibble in the upper
  108|       |		 * bits. Allow this special case. */
  109|  3.34k|		*out = (u8) byte>>4;
  110|  3.34k|		left--;
  111|  3.34k|		byte_needs_nibble = 0;
  112|  3.34k|	}
  113|       |
  114|       |	/* for ease of implementation we only accept completely hexed bytes. */
  115|  79.3k|	if (byte_needs_nibble) {
  ------------------
  |  Branch (115:6): [True: 1.50k, False: 77.8k]
  ------------------
  116|  1.50k|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  1.50k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  117|  1.50k|		goto err;
  118|  1.50k|	}
  119|       |
  120|       |	/* skip all trailing separators to see if we missed something */
  121|  77.8k|	while (*in != '\0') {
  ------------------
  |  Branch (121:9): [True: 27, False: 77.8k]
  ------------------
  122|     27|		if (NULL == strchr(sc_hex_to_bin_separators, (int) *in))
  ------------------
  |  Branch (122:7): [True: 27, False: 0]
  ------------------
  123|     27|			break;
  124|      0|		in++;
  125|      0|	}
  126|  77.8k|	if (*in != '\0') {
  ------------------
  |  Branch (126:6): [True: 27, False: 77.8k]
  ------------------
  127|     27|		r = SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|     27|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  128|     27|		goto err;
  129|     27|	}
  130|       |
  131|  80.9k|err:
  132|  80.9k|	*outlen -= left;
  133|  80.9k|	return r;
  134|  77.8k|}
sc_bin_to_hex:
  138|  81.9k|{
  139|  81.9k|	if (in == NULL || out == NULL) {
  ------------------
  |  Branch (139:6): [True: 0, False: 81.9k]
  |  Branch (139:20): [True: 0, False: 81.9k]
  ------------------
  140|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  141|      0|	}
  142|       |
  143|  81.9k|	if (in_sep > 0) {
  ------------------
  |  Branch (143:6): [True: 74.0k, False: 7.88k]
  ------------------
  144|  74.0k|		if (out_len < in_len*3 || out_len < 1)
  ------------------
  |  Branch (144:7): [True: 0, False: 74.0k]
  |  Branch (144:29): [True: 0, False: 74.0k]
  ------------------
  145|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  146|  74.0k|	} else {
  147|  7.88k|		if (out_len < in_len*2 + 1)
  ------------------
  |  Branch (147:7): [True: 0, False: 7.88k]
  ------------------
  148|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  149|  7.88k|	}
  150|       |
  151|  81.9k|	const char hex[] = "0123456789abcdef";
  152|  1.05M|	while (in_len) {
  ------------------
  |  Branch (152:9): [True: 973k, False: 81.9k]
  ------------------
  153|   973k|		unsigned char value = *in++;
  154|   973k|		*out++ = hex[(value >> 4) & 0xF];
  155|   973k|		*out++ = hex[ value       & 0xF];
  156|   973k|		in_len--;
  157|   973k|		if (in_len && in_sep > 0)
  ------------------
  |  Branch (157:7): [True: 905k, False: 67.9k]
  |  Branch (157:17): [True: 848k, False: 56.3k]
  ------------------
  158|   848k|			*out++ = (char)in_sep;
  159|   973k|	}
  160|  81.9k|	*out = '\0';
  161|       |
  162|  81.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  81.9k|#define SC_SUCCESS				0
  ------------------
  163|  81.9k|}
ulong2bebytes:
  189|  5.08k|{
  190|  5.08k|	if (buf != NULL) {
  ------------------
  |  Branch (190:6): [True: 5.08k, False: 0]
  ------------------
  191|  5.08k|		buf[3] = (u8) (x & 0xff);
  192|  5.08k|		buf[2] = (u8) ((x >> 8) & 0xff);
  193|  5.08k|		buf[1] = (u8) ((x >> 16) & 0xff);
  194|  5.08k|		buf[0] = (u8) ((x >> 24) & 0xff);
  195|  5.08k|	}
  196|  5.08k|	return buf;
  197|  5.08k|}
ushort2bebytes:
  200|    981|{
  201|    981|	if (buf != NULL) {
  ------------------
  |  Branch (201:6): [True: 981, False: 0]
  ------------------
  202|    981|		buf[1] = (u8) (x & 0xff);
  203|    981|		buf[0] = (u8) ((x >> 8) & 0xff);
  204|    981|	}
  205|    981|	return buf;
  206|    981|}
bebytes2ulong:
  209|   128k|{
  210|   128k|	if (buf == NULL)
  ------------------
  |  Branch (210:6): [True: 0, False: 128k]
  ------------------
  211|      0|		return 0UL;
  212|   128k|	return (unsigned long)buf[0] << 24
  213|   128k|		| (unsigned long)buf[1] << 16
  214|   128k|		| (unsigned long)buf[2] << 8
  215|   128k|		| (unsigned long)buf[3];
  216|   128k|}
bebytes2ushort:
  219|   383k|{
  220|   383k|	if (buf == NULL)
  ------------------
  |  Branch (220:6): [True: 0, False: 383k]
  ------------------
  221|      0|		return 0U;
  222|   383k|	return (unsigned short)buf[0] << 8
  223|   383k|		| (unsigned short)buf[1];
  224|   383k|}
lebytes2ushort:
  227|  1.29k|{
  228|  1.29k|	if (buf == NULL)
  ------------------
  |  Branch (228:6): [True: 0, False: 1.29k]
  ------------------
  229|      0|		return 0U;
  230|  1.29k|	return (unsigned short)buf[1] << 8
  231|  1.29k|		| (unsigned short)buf[0];
  232|  1.29k|}
set_string:
  245|  2.30k|{
  246|  2.30k|	if (strp == NULL) {
  ------------------
  |  Branch (246:6): [True: 0, False: 2.30k]
  ------------------
  247|      0|		return;
  248|      0|	}
  249|       |
  250|  2.30k|	free(*strp);
  251|  2.30k|	*strp = value ? strdup(value) : NULL;
  ------------------
  |  Branch (251:10): [True: 2.30k, False: 0]
  ------------------
  252|  2.30k|}
sc_init_oid:
  255|  39.4k|{
  256|  39.4k|	int ii;
  257|       |
  258|  39.4k|	if (!oid)
  ------------------
  |  Branch (258:6): [True: 0, False: 39.4k]
  ------------------
  259|      0|		return;
  260|   671k|	for (ii=0; ii<SC_MAX_OBJECT_ID_OCTETS; ii++)
  ------------------
  |  |   46|   671k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (260:13): [True: 631k, False: 39.4k]
  ------------------
  261|   631k|		oid->value[ii] = -1;
  262|  39.4k|}
sc_format_oid:
  265|  9.62k|{
  266|  9.62k|	int        ii, ret = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|  9.62k|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  267|  9.62k|	const char *p;
  268|  9.62k|	char       *q;
  269|       |
  270|  9.62k|	if (oid == NULL || in == NULL)
  ------------------
  |  Branch (270:6): [True: 0, False: 9.62k]
  |  Branch (270:21): [True: 0, False: 9.62k]
  ------------------
  271|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  272|       |
  273|  9.62k|	sc_init_oid(oid);
  274|       |
  275|  9.62k|	p = in;
  276|  49.0k|	for (ii=0; ii < SC_MAX_OBJECT_ID_OCTETS; ii++)   {
  ------------------
  |  |   46|  49.0k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (276:13): [True: 49.0k, False: 0]
  ------------------
  277|  49.0k|		oid->value[ii] = (int)strtol(p, &q, 10);
  278|  49.0k|		if (!*q)
  ------------------
  |  Branch (278:7): [True: 7.41k, False: 41.6k]
  ------------------
  279|  7.41k|			break;
  280|       |
  281|  41.6k|		if (!(q[0] == '.' && isdigit((unsigned char)q[1])))
  ------------------
  |  Branch (281:9): [True: 39.4k, False: 2.20k]
  |  Branch (281:24): [True: 39.4k, False: 0]
  ------------------
  282|  2.20k|			goto out;
  283|       |
  284|  39.4k|		p = q + 1;
  285|  39.4k|	}
  286|       |
  287|  7.41k|	if (!sc_valid_oid(oid))
  ------------------
  |  Branch (287:6): [True: 0, False: 7.41k]
  ------------------
  288|      0|		goto out;
  289|       |
  290|  7.41k|	ret = SC_SUCCESS;
  ------------------
  |  |   28|  7.41k|#define SC_SUCCESS				0
  ------------------
  291|  9.62k|out:
  292|  9.62k|	if (ret)
  ------------------
  |  Branch (292:6): [True: 2.20k, False: 7.41k]
  ------------------
  293|  2.20k|		sc_init_oid(oid);
  294|       |
  295|  9.62k|	return ret;
  296|  7.41k|}
sc_compare_oid:
  299|  24.9k|{
  300|  24.9k|	int i;
  301|       |
  302|  24.9k|	if (oid1 == NULL || oid2 == NULL) {
  ------------------
  |  Branch (302:6): [True: 0, False: 24.9k]
  |  Branch (302:22): [True: 0, False: 24.9k]
  ------------------
  303|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  304|      0|	}
  305|       |
  306|  73.4k|	for (i = 0; i < SC_MAX_OBJECT_ID_OCTETS; i++)   {
  ------------------
  |  |   46|  73.4k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (306:14): [True: 73.4k, False: 0]
  ------------------
  307|  73.4k|		if (oid1->value[i] != oid2->value[i])
  ------------------
  |  Branch (307:7): [True: 20.0k, False: 53.4k]
  ------------------
  308|  20.0k|			return 0;
  309|  53.4k|		if (oid1->value[i] == -1)
  ------------------
  |  Branch (309:7): [True: 4.85k, False: 48.5k]
  ------------------
  310|  4.85k|			break;
  311|  53.4k|	}
  312|       |
  313|  4.85k|	return 1;
  314|  24.9k|}
sc_valid_oid:
  318|  10.4k|{
  319|  10.4k|	int ii;
  320|       |
  321|  10.4k|	if (!oid)
  ------------------
  |  Branch (321:6): [True: 0, False: 10.4k]
  ------------------
  322|      0|		return 0;
  323|  10.4k|	if (oid->value[0] == -1 || oid->value[1] == -1)
  ------------------
  |  Branch (323:6): [True: 748, False: 9.68k]
  |  Branch (323:29): [True: 0, False: 9.68k]
  ------------------
  324|    748|		return 0;
  325|  9.68k|	if (oid->value[0] > 2 || oid->value[1] > 39)
  ------------------
  |  Branch (325:6): [True: 0, False: 9.68k]
  |  Branch (325:27): [True: 5, False: 9.67k]
  ------------------
  326|      5|		return 0;
  327|  26.2k|	for (ii=0;ii<SC_MAX_OBJECT_ID_OCTETS;ii++)
  ------------------
  |  |   46|  26.2k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (327:12): [True: 25.2k, False: 1.03k]
  ------------------
  328|  25.2k|		if (oid->value[ii])
  ------------------
  |  Branch (328:7): [True: 8.63k, False: 16.5k]
  ------------------
  329|  8.63k|			break;
  330|  9.67k|	if (ii==SC_MAX_OBJECT_ID_OCTETS)
  ------------------
  |  |   46|  9.67k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (330:6): [True: 1.03k, False: 8.63k]
  ------------------
  331|  1.03k|		return 0;
  332|  8.63k|	return 1;
  333|  9.67k|}
sc_path_set:
  355|  8.89k|{
  356|  8.89k|	if (path == NULL || id == NULL || id_len == 0 || id_len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  8.89k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (356:6): [True: 0, False: 8.89k]
  |  Branch (356:22): [True: 0, False: 8.89k]
  |  Branch (356:36): [True: 0, False: 8.89k]
  |  Branch (356:51): [True: 0, False: 8.89k]
  ------------------
  357|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  358|       |
  359|  8.89k|	memset(path, 0, sizeof(*path));
  360|  8.89k|	memcpy(path->value, id, id_len);
  361|  8.89k|	path->len   = id_len;
  362|  8.89k|	path->type  = type;
  363|  8.89k|	path->index = idx;
  364|  8.89k|	path->count = count;
  365|       |
  366|  8.89k|	return SC_SUCCESS;
  ------------------
  |  |   28|  8.89k|#define SC_SUCCESS				0
  ------------------
  367|  8.89k|}
sc_format_path:
  370|  43.7k|{
  371|  43.7k|	int type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  43.7k|#define SC_PATH_TYPE_PATH		2
  ------------------
  372|       |
  373|  43.7k|	if (path) {
  ------------------
  |  Branch (373:6): [True: 43.7k, False: 0]
  ------------------
  374|  43.7k|		memset(path, 0, sizeof(*path));
  375|  43.7k|		if (*str == 'i' || *str == 'I') {
  ------------------
  |  Branch (375:7): [True: 643, False: 43.0k]
  |  Branch (375:22): [True: 8, False: 43.0k]
  ------------------
  376|    651|			type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    651|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  377|    651|			str++;
  378|    651|		}
  379|  43.7k|		path->len = sizeof(path->value);
  380|  43.7k|		if (sc_hex_to_bin(str, path->value, &path->len) >= 0) {
  ------------------
  |  Branch (380:7): [True: 40.9k, False: 2.73k]
  ------------------
  381|  40.9k|			path->type = type;
  382|  40.9k|		}
  383|  43.7k|		path->count = -1;
  384|  43.7k|	}
  385|  43.7k|}
sc_append_path_id:
  393|  45.9k|{
  394|  45.9k|	if (dest->len + idlen > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  45.9k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (394:6): [True: 287, False: 45.6k]
  ------------------
  395|    287|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|    287|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  396|  45.6k|	memcpy(dest->value + dest->len, id, idlen);
  397|  45.6k|	dest->len += idlen;
  398|  45.6k|	return SC_SUCCESS;
  ------------------
  |  |   28|  45.6k|#define SC_SUCCESS				0
  ------------------
  399|  45.9k|}
sc_append_file_id:
  402|  45.9k|{
  403|  45.9k|	u8 id[2] = { fid >> 8, fid & 0xff };
  404|       |
  405|  45.9k|	return sc_append_path_id(dest, id, 2);
  406|  45.9k|}
sc_concatenate_path:
  409|  15.4k|{
  410|  15.4k|	sc_path_t tpath;
  411|       |
  412|  15.4k|	if (d == NULL || p1 == NULL || p2 == NULL)
  ------------------
  |  Branch (412:6): [True: 0, False: 15.4k]
  |  Branch (412:19): [True: 0, False: 15.4k]
  |  Branch (412:33): [True: 0, False: 15.4k]
  ------------------
  413|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  414|       |
  415|  15.4k|	if (p1->type == SC_PATH_TYPE_DF_NAME || p2->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  30.8k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
              	if (p1->type == SC_PATH_TYPE_DF_NAME || p2->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  15.4k|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (415:6): [True: 0, False: 15.4k]
  |  Branch (415:42): [True: 0, False: 15.4k]
  ------------------
  416|       |		/* we do not support concatenation of AIDs at the moment */
  417|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  418|       |
  419|  15.4k|	if (p1->len + p2->len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|  15.4k|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (419:6): [True: 0, False: 15.4k]
  ------------------
  420|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  421|       |
  422|  15.4k|	memset(&tpath, 0, sizeof(sc_path_t));
  423|  15.4k|	memcpy(tpath.value, p1->value, p1->len);
  424|  15.4k|	memcpy(tpath.value + p1->len, p2->value, p2->len);
  425|  15.4k|	tpath.len  = p1->len + p2->len;
  426|  15.4k|	tpath.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  15.4k|#define SC_PATH_TYPE_PATH		2
  ------------------
  427|       |	/* use 'index' and 'count' entry of the second path object */
  428|  15.4k|	tpath.index = p2->index;
  429|  15.4k|	tpath.count = p2->count;
  430|       |	/* the result is currently always as path */
  431|  15.4k|	tpath.type  = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|  15.4k|#define SC_PATH_TYPE_PATH		2
  ------------------
  432|       |
  433|  15.4k|	*d = tpath;
  434|       |
  435|  15.4k|	return SC_SUCCESS;
  ------------------
  |  |   28|  15.4k|#define SC_SUCCESS				0
  ------------------
  436|  15.4k|}
sc_print_path:
  439|  1.00M|{
  440|  1.00M|	static char buffer[SC_MAX_PATH_STRING_SIZE + SC_MAX_AID_STRING_SIZE];
  441|       |
  442|  1.00M|	if (sc_path_print(buffer, sizeof(buffer), path) != SC_SUCCESS)
  ------------------
  |  |   28|  1.00M|#define SC_SUCCESS				0
  ------------------
  |  Branch (442:6): [True: 0, False: 1.00M]
  ------------------
  443|      0|		buffer[0] = '\0';
  444|       |
  445|  1.00M|	return buffer;
  446|  1.00M|}
sc_path_print:
  449|  1.41M|{
  450|  1.41M|	size_t i;
  451|       |
  452|  1.41M|	if (buf == NULL || path == NULL)
  ------------------
  |  Branch (452:6): [True: 0, False: 1.41M]
  |  Branch (452:21): [True: 0, False: 1.41M]
  ------------------
  453|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  454|       |
  455|  1.41M|	if (buflen < path->len * 2 + path->aid.len * 2 + 3)
  ------------------
  |  Branch (455:6): [True: 239, False: 1.41M]
  ------------------
  456|    239|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|    239|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  457|       |
  458|  1.41M|	buf[0] = '\0';
  459|  1.41M|	if (path->aid.len)   {
  ------------------
  |  Branch (459:6): [True: 16.1k, False: 1.39M]
  ------------------
  460|   127k|		for (i = 0; i < path->aid.len; i++)
  ------------------
  |  Branch (460:15): [True: 111k, False: 16.1k]
  ------------------
  461|   111k|			snprintf(buf + strlen(buf), buflen - strlen(buf), "%02x", path->aid.value[i]);
  462|  16.1k|		snprintf(buf + strlen(buf), buflen - strlen(buf), "::");
  463|  16.1k|	}
  464|       |
  465|  8.31M|	for (i = 0; i < path->len; i++)
  ------------------
  |  Branch (465:14): [True: 6.90M, False: 1.41M]
  ------------------
  466|  6.90M|		snprintf(buf + strlen(buf), buflen - strlen(buf), "%02x", path->value[i]);
  467|  1.41M|	if (!path->aid.len && path->type == SC_PATH_TYPE_DF_NAME)
  ------------------
  |  |  118|  1.39M|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (467:6): [True: 1.39M, False: 16.1k]
  |  Branch (467:24): [True: 10.0k, False: 1.38M]
  ------------------
  468|  10.0k|		snprintf(buf + strlen(buf), buflen - strlen(buf), "::");
  469|       |
  470|  1.41M|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.41M|#define SC_SUCCESS				0
  ------------------
  471|  1.41M|}
sc_compare_path:
  474|  36.5k|{
  475|  36.5k|	return path1->len == path2->len
  ------------------
  |  Branch (475:9): [True: 12.8k, False: 23.7k]
  ------------------
  476|  12.8k|		&& !memcmp(path1->value, path2->value, path1->len);
  ------------------
  |  Branch (476:6): [True: 3.13k, False: 9.67k]
  ------------------
  477|  36.5k|}
sc_compare_path_prefix:
  480|  10.7k|{
  481|  10.7k|	sc_path_t tpath;
  482|       |
  483|  10.7k|	if (prefix->len > path->len)
  ------------------
  |  Branch (483:6): [True: 212, False: 10.5k]
  ------------------
  484|    212|		return 0;
  485|       |
  486|  10.5k|	tpath     = *path;
  487|  10.5k|	tpath.len = prefix->len;
  488|       |
  489|  10.5k|	return sc_compare_path(&tpath, prefix);
  490|  10.7k|}
sc_get_mf_path:
  493|  11.8k|{
  494|  11.8k|	static const sc_path_t mf_path = {
  495|  11.8k|		{0x3f, 0x00, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 2,
  496|  11.8k|		0,
  497|  11.8k|		0,
  498|  11.8k|		SC_PATH_TYPE_PATH,
  ------------------
  |  |  119|  11.8k|#define SC_PATH_TYPE_PATH		2
  ------------------
  499|  11.8k|		{{0},0}
  500|  11.8k|	};
  501|  11.8k|	return &mf_path;
  502|  11.8k|}
sc_file_add_acl_entry:
  506|  1.34M|{
  507|  1.34M|	sc_acl_entry_t *p, *_new;
  508|       |
  509|  1.34M|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|  1.34M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (509:6): [True: 0, False: 1.34M]
  |  Branch (509:22): [True: 0, False: 1.34M]
  ------------------
  510|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  511|      0|	}
  512|       |
  513|  1.34M|	switch (method) {
  514|   117k|	case SC_AC_NEVER:
  ------------------
  |  |  163|   117k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (514:2): [True: 117k, False: 1.22M]
  ------------------
  515|   117k|		sc_file_clear_acl_entries(file, operation);
  516|   117k|		file->acl[operation] = (sc_acl_entry_t *) 1;
  517|   117k|		return SC_SUCCESS;
  ------------------
  |  |   28|   117k|#define SC_SUCCESS				0
  ------------------
  518|  1.07M|	case SC_AC_NONE:
  ------------------
  |  |  150|  1.07M|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (518:2): [True: 1.07M, False: 273k]
  ------------------
  519|  1.07M|		sc_file_clear_acl_entries(file, operation);
  520|  1.07M|		file->acl[operation] = (sc_acl_entry_t *) 2;
  521|  1.07M|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.07M|#define SC_SUCCESS				0
  ------------------
  522|  6.21k|	case SC_AC_UNKNOWN:
  ------------------
  |  |  162|  6.21k|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  |  Branch (522:2): [True: 6.21k, False: 1.33M]
  ------------------
  523|  6.21k|		sc_file_clear_acl_entries(file, operation);
  524|  6.21k|		file->acl[operation] = (sc_acl_entry_t *) 3;
  525|  6.21k|		return SC_SUCCESS;
  ------------------
  |  |   28|  6.21k|#define SC_SUCCESS				0
  ------------------
  526|   149k|	default:
  ------------------
  |  Branch (526:2): [True: 149k, False: 1.19M]
  ------------------
  527|       |		/* NONE and UNKNOWN get zapped when a new AC is added.
  528|       |		 * If the ACL is NEVER, additional entries will be
  529|       |		 * dropped silently. */
  530|   149k|		if (file->acl[operation] == (sc_acl_entry_t *) 1)
  ------------------
  |  Branch (530:7): [True: 275, False: 149k]
  ------------------
  531|    275|			return SC_SUCCESS;
  ------------------
  |  |   28|    275|#define SC_SUCCESS				0
  ------------------
  532|   149k|		if (file->acl[operation] == (sc_acl_entry_t *) 2
  ------------------
  |  Branch (532:7): [True: 1.15k, False: 148k]
  ------------------
  533|   148k|		 || file->acl[operation] == (sc_acl_entry_t *) 3)
  ------------------
  |  Branch (533:7): [True: 157, False: 148k]
  ------------------
  534|  1.31k|			file->acl[operation] = NULL;
  535|  1.34M|	}
  536|       |
  537|       |	/* If the entry is already present (e.g. due to the mapping)
  538|       |	 * of the card's AC with OpenSC's), don't add it again. */
  539|   168k|	for (p = file->acl[operation]; p != NULL; p = p->next) {
  ------------------
  |  Branch (539:33): [True: 21.6k, False: 146k]
  ------------------
  540|  21.6k|		if ((p->method == method) && (p->key_ref == key_ref))
  ------------------
  |  Branch (540:7): [True: 20.9k, False: 759]
  |  Branch (540:32): [True: 2.51k, False: 18.3k]
  ------------------
  541|  2.51k|			return SC_SUCCESS;
  ------------------
  |  |   28|  2.51k|#define SC_SUCCESS				0
  ------------------
  542|  21.6k|	}
  543|       |
  544|   146k|	_new = malloc(sizeof(sc_acl_entry_t));
  545|   146k|	if (_new == NULL)
  ------------------
  |  Branch (545:6): [True: 0, False: 146k]
  ------------------
  546|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  547|   146k|	_new->method = method;
  548|   146k|	_new->key_ref = (unsigned)key_ref;
  549|   146k|	_new->next = NULL;
  550|       |
  551|   146k|	p = file->acl[operation];
  552|   146k|	if (p == NULL) {
  ------------------
  |  Branch (552:6): [True: 141k, False: 5.73k]
  ------------------
  553|   141k|		file->acl[operation] = _new;
  554|   141k|		return SC_SUCCESS;
  ------------------
  |  |   28|   141k|#define SC_SUCCESS				0
  ------------------
  555|   141k|	}
  556|  18.9k|	while (p->next != NULL)
  ------------------
  |  Branch (556:9): [True: 13.2k, False: 5.73k]
  ------------------
  557|  13.2k|		p = p->next;
  558|  5.73k|	p->next = _new;
  559|       |
  560|  5.73k|	return SC_SUCCESS;
  ------------------
  |  |   28|  5.73k|#define SC_SUCCESS				0
  ------------------
  561|   146k|}
sc_file_get_acl_entry:
  565|  1.59M|{
  566|  1.59M|	sc_acl_entry_t *p;
  567|  1.59M|	static const sc_acl_entry_t e_never = {
  568|  1.59M|		SC_AC_NEVER, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  163|  1.59M|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
              		SC_AC_NEVER, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|  1.59M|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  569|  1.59M|	};
  570|  1.59M|	static const sc_acl_entry_t e_none = {
  571|  1.59M|		SC_AC_NONE, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  150|  1.59M|#define SC_AC_NONE			0x00000000
  ------------------
              		SC_AC_NONE, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|  1.59M|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  572|  1.59M|	};
  573|  1.59M|	static const sc_acl_entry_t e_unknown = {
  574|  1.59M|		SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  162|  1.59M|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
              		SC_AC_UNKNOWN, SC_AC_KEY_REF_NONE, NULL
  ------------------
  |  |  204|  1.59M|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  575|  1.59M|	};
  576|       |
  577|  1.59M|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|  1.59M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (577:6): [True: 1, False: 1.59M]
  |  Branch (577:22): [True: 2, False: 1.59M]
  ------------------
  578|      3|		return NULL;
  579|      3|	}
  580|       |
  581|  1.59M|	p = file->acl[operation];
  582|  1.59M|	if (p == (sc_acl_entry_t *) 1)
  ------------------
  |  Branch (582:6): [True: 53.4k, False: 1.54M]
  ------------------
  583|  53.4k|		return &e_never;
  584|  1.54M|	if (p == (sc_acl_entry_t *) 2)
  ------------------
  |  Branch (584:6): [True: 398k, False: 1.14M]
  ------------------
  585|   398k|		return &e_none;
  586|  1.14M|	if (p == (sc_acl_entry_t *) 3)
  ------------------
  |  Branch (586:6): [True: 4.11k, False: 1.14M]
  ------------------
  587|  4.11k|		return &e_unknown;
  588|       |
  589|  1.14M|	return file->acl[operation];
  590|  1.14M|}
sc_file_clear_acl_entries:
  593|  6.15M|{
  594|  6.15M|	sc_acl_entry_t *e;
  595|       |
  596|  6.15M|	if (file == NULL || operation >= SC_MAX_AC_OPS) {
  ------------------
  |  |  198|  6.15M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (596:6): [True: 0, False: 6.15M]
  |  Branch (596:22): [True: 0, False: 6.15M]
  ------------------
  597|      0|		return;
  598|      0|	}
  599|       |
  600|  6.15M|	e = file->acl[operation];
  601|  6.15M|	if (e == (sc_acl_entry_t *) 1 ||
  ------------------
  |  Branch (601:6): [True: 117k, False: 6.03M]
  ------------------
  602|  6.03M|	    e == (sc_acl_entry_t *) 2 ||
  ------------------
  |  Branch (602:6): [True: 1.07M, False: 4.96M]
  ------------------
  603|  4.96M|	    e == (sc_acl_entry_t *) 3) {
  ------------------
  |  Branch (603:6): [True: 6.05k, False: 4.95M]
  ------------------
  604|  1.19M|		file->acl[operation] = NULL;
  605|  1.19M|		return;
  606|  1.19M|	}
  607|       |
  608|  5.10M|	while (e != NULL) {
  ------------------
  |  Branch (608:9): [True: 146k, False: 4.95M]
  ------------------
  609|   146k|		sc_acl_entry_t *tmp = e->next;
  610|   146k|		free(e);
  611|   146k|		e = tmp;
  612|   146k|	}
  613|       |	file->acl[operation] = NULL;
  614|  4.95M|}
sc_file_new:
  617|   156k|{
  618|   156k|	sc_file_t *file = (sc_file_t *)calloc(1, sizeof(sc_file_t));
  619|   156k|	if (file == NULL)
  ------------------
  |  Branch (619:6): [True: 0, False: 156k]
  ------------------
  620|      0|		return NULL;
  621|       |
  622|   156k|	file->magic = SC_FILE_MAGIC;
  ------------------
  |  |   57|   156k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  623|   156k|	return file;
  624|   156k|}
sc_file_free:
  627|   601k|{
  628|   601k|	unsigned int i;
  629|   601k|	if (file == NULL || !sc_file_valid(file))
  ------------------
  |  Branch (629:6): [True: 445k, False: 156k]
  |  Branch (629:22): [True: 0, False: 156k]
  ------------------
  630|   445k|		return;
  631|   156k|	file->magic = 0;
  632|  5.01M|	for (i = 0; i < SC_MAX_AC_OPS; i++)
  ------------------
  |  |  198|  5.01M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (632:14): [True: 4.86M, False: 156k]
  ------------------
  633|  4.86M|		sc_file_clear_acl_entries(file, i);
  634|   156k|	if (file->sec_attr)
  ------------------
  |  Branch (634:6): [True: 11.8k, False: 145k]
  ------------------
  635|  11.8k|		free(file->sec_attr);
  636|   156k|	if (file->prop_attr)
  ------------------
  |  Branch (636:6): [True: 8.21k, False: 148k]
  ------------------
  637|  8.21k|		free(file->prop_attr);
  638|   156k|	if (file->type_attr)
  ------------------
  |  Branch (638:6): [True: 16.8k, False: 139k]
  ------------------
  639|  16.8k|		free(file->type_attr);
  640|   156k|	if (file->encoded_content)
  ------------------
  |  Branch (640:6): [True: 660, False: 156k]
  ------------------
  641|    660|		free(file->encoded_content);
  642|   156k|	free(file);
  643|   156k|}
sc_file_dup:
  646|  46.5k|{
  647|  46.5k|	sc_file_t *newf;
  648|  46.5k|	const sc_acl_entry_t *e;
  649|  46.5k|	unsigned int op;
  650|       |
  651|  46.5k|	*dest = NULL;
  652|  46.5k|	if (!sc_file_valid(src))
  ------------------
  |  Branch (652:6): [True: 0, False: 46.5k]
  ------------------
  653|      0|		return;
  654|  46.5k|	newf = sc_file_new();
  655|  46.5k|	if (newf == NULL)
  ------------------
  |  Branch (655:6): [True: 0, False: 46.5k]
  ------------------
  656|      0|		return;
  657|  46.5k|	*dest = newf;
  658|       |
  659|  46.5k|	memcpy(&newf->path, &src->path, sizeof(struct sc_path));
  660|  46.5k|	memcpy(&newf->name, &src->name, sizeof(src->name));
  661|  46.5k|	newf->namelen = src->namelen;
  662|  46.5k|	newf->type    = src->type;
  663|  46.5k|	newf->shareable    = src->shareable;
  664|  46.5k|	newf->ef_structure = src->ef_structure;
  665|  46.5k|	newf->size    = src->size;
  666|  46.5k|	newf->id      = src->id;
  667|  46.5k|	newf->status  = src->status;
  668|  1.49M|	for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|  1.49M|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (668:15): [True: 1.44M, False: 46.5k]
  ------------------
  669|  1.44M|		newf->acl[op] = NULL;
  670|  1.44M|		e = sc_file_get_acl_entry(src, op);
  671|  1.44M|		if (e != NULL) {
  ------------------
  |  Branch (671:7): [True: 326k, False: 1.11M]
  ------------------
  672|   326k|			if (sc_file_add_acl_entry(newf, op, e->method, e->key_ref) < 0)
  ------------------
  |  Branch (672:8): [True: 0, False: 326k]
  ------------------
  673|      0|				goto err;
  674|   326k|		}
  675|  1.44M|	}
  676|  46.5k|	newf->record_length = src->record_length;
  677|  46.5k|	newf->record_count  = src->record_count;
  678|       |
  679|  46.5k|	if (sc_file_set_sec_attr(newf, src->sec_attr, src->sec_attr_len) < 0)
  ------------------
  |  Branch (679:6): [True: 0, False: 46.5k]
  ------------------
  680|      0|		goto err;
  681|  46.5k|	if (sc_file_set_prop_attr(newf, src->prop_attr, src->prop_attr_len) < 0)
  ------------------
  |  Branch (681:6): [True: 0, False: 46.5k]
  ------------------
  682|      0|		goto err;
  683|  46.5k|	if (sc_file_set_type_attr(newf, src->type_attr, src->type_attr_len) < 0)
  ------------------
  |  Branch (683:6): [True: 0, False: 46.5k]
  ------------------
  684|      0|		goto err;
  685|  46.5k|	if (sc_file_set_content(newf, src->encoded_content, src->encoded_content_len) < 0)
  ------------------
  |  Branch (685:6): [True: 0, False: 46.5k]
  ------------------
  686|      0|		goto err;
  687|  46.5k|	return;
  688|  46.5k|err:
  689|      0|	sc_file_free(newf);
  690|       |	*dest = NULL;
  691|      0|}
sc_file_set_sec_attr:
  695|  58.6k|{
  696|  58.6k|	u8 *tmp;
  697|  58.6k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (697:6): [True: 0, False: 58.6k]
  ------------------
  698|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  699|      0|	}
  700|       |
  701|  58.6k|	if (sec_attr == NULL || sec_attr_len == 0) {
  ------------------
  |  Branch (701:6): [True: 46.5k, False: 12.1k]
  |  Branch (701:26): [True: 285, False: 11.8k]
  ------------------
  702|  46.8k|		if (file->sec_attr != NULL)
  ------------------
  |  Branch (702:7): [True: 3, False: 46.8k]
  ------------------
  703|      3|			free(file->sec_attr);
  704|  46.8k|		file->sec_attr = NULL;
  705|  46.8k|		file->sec_attr_len = 0;
  706|  46.8k|		return 0;
  707|  46.8k|	 }
  708|  11.8k|	tmp = (u8 *) realloc(file->sec_attr, sec_attr_len);
  709|  11.8k|	if (!tmp) {
  ------------------
  |  Branch (709:6): [True: 0, False: 11.8k]
  ------------------
  710|      0|		if (file->sec_attr)
  ------------------
  |  Branch (710:7): [True: 0, False: 0]
  ------------------
  711|      0|			free(file->sec_attr);
  712|      0|		file->sec_attr     = NULL;
  713|      0|		file->sec_attr_len = 0;
  714|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  715|      0|	}
  716|  11.8k|	file->sec_attr = tmp;
  717|  11.8k|	memcpy(file->sec_attr, sec_attr, sec_attr_len);
  718|  11.8k|	file->sec_attr_len = sec_attr_len;
  719|       |
  720|  11.8k|	return 0;
  721|  11.8k|}
sc_file_set_prop_attr:
  725|  55.6k|{
  726|  55.6k|	u8 *tmp;
  727|  55.6k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (727:6): [True: 0, False: 55.6k]
  ------------------
  728|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  729|      0|	}
  730|       |
  731|  55.6k|	if (prop_attr == NULL || prop_attr_len == 0) {
  ------------------
  |  Branch (731:6): [True: 46.5k, False: 9.09k]
  |  Branch (731:27): [True: 795, False: 8.30k]
  ------------------
  732|  47.3k|		if (file->prop_attr != NULL)
  ------------------
  |  Branch (732:7): [True: 18, False: 47.3k]
  ------------------
  733|     18|			free(file->prop_attr);
  734|  47.3k|		file->prop_attr = NULL;
  735|  47.3k|		file->prop_attr_len = 0;
  736|  47.3k|		return SC_SUCCESS;
  ------------------
  |  |   28|  47.3k|#define SC_SUCCESS				0
  ------------------
  737|  47.3k|	 }
  738|  8.30k|	tmp = (u8 *) realloc(file->prop_attr, prop_attr_len);
  739|  8.30k|	if (!tmp) {
  ------------------
  |  Branch (739:6): [True: 0, False: 8.30k]
  ------------------
  740|      0|		if (file->prop_attr)
  ------------------
  |  Branch (740:7): [True: 0, False: 0]
  ------------------
  741|      0|			free(file->prop_attr);
  742|      0|		file->prop_attr = NULL;
  743|      0|		file->prop_attr_len = 0;
  744|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  745|      0|	}
  746|  8.30k|	file->prop_attr = tmp;
  747|  8.30k|	memcpy(file->prop_attr, prop_attr, prop_attr_len);
  748|  8.30k|	file->prop_attr_len = prop_attr_len;
  749|       |
  750|  8.30k|	return SC_SUCCESS;
  ------------------
  |  |   28|  8.30k|#define SC_SUCCESS				0
  ------------------
  751|  8.30k|}
sc_file_set_type_attr:
  755|  60.6k|{
  756|  60.6k|	u8 *tmp;
  757|  60.6k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (757:6): [True: 0, False: 60.6k]
  ------------------
  758|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  759|      0|	}
  760|       |
  761|  60.6k|	if (type_attr == NULL || type_attr_len == 0) {
  ------------------
  |  Branch (761:6): [True: 43.7k, False: 16.9k]
  |  Branch (761:27): [True: 0, False: 16.9k]
  ------------------
  762|  43.7k|		if (file->type_attr != NULL)
  ------------------
  |  Branch (762:7): [True: 0, False: 43.7k]
  ------------------
  763|      0|			free(file->type_attr);
  764|  43.7k|		file->type_attr = NULL;
  765|  43.7k|		file->type_attr_len = 0;
  766|  43.7k|		return SC_SUCCESS;
  ------------------
  |  |   28|  43.7k|#define SC_SUCCESS				0
  ------------------
  767|  43.7k|	 }
  768|  16.9k|	tmp = (u8 *) realloc(file->type_attr, type_attr_len);
  769|  16.9k|	if (!tmp) {
  ------------------
  |  Branch (769:6): [True: 0, False: 16.9k]
  ------------------
  770|      0|		if (file->type_attr)
  ------------------
  |  Branch (770:7): [True: 0, False: 0]
  ------------------
  771|      0|			free(file->type_attr);
  772|      0|		file->type_attr = NULL;
  773|      0|		file->type_attr_len = 0;
  774|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  775|      0|	}
  776|  16.9k|	file->type_attr = tmp;
  777|  16.9k|	memcpy(file->type_attr, type_attr, type_attr_len);
  778|  16.9k|	file->type_attr_len = type_attr_len;
  779|       |
  780|  16.9k|	return SC_SUCCESS;
  ------------------
  |  |   28|  16.9k|#define SC_SUCCESS				0
  ------------------
  781|  16.9k|}
sc_file_set_content:
  786|  46.5k|{
  787|  46.5k|	u8 *tmp;
  788|  46.5k|	if (!sc_file_valid(file)) {
  ------------------
  |  Branch (788:6): [True: 0, False: 46.5k]
  ------------------
  789|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  790|      0|	}
  791|       |
  792|  46.5k|	if (content == NULL || content_len == 0) {
  ------------------
  |  Branch (792:6): [True: 46.0k, False: 512]
  |  Branch (792:25): [True: 2, False: 510]
  ------------------
  793|  46.0k|		if (file->encoded_content != NULL)
  ------------------
  |  Branch (793:7): [True: 0, False: 46.0k]
  ------------------
  794|      0|			free(file->encoded_content);
  795|  46.0k|		file->encoded_content = NULL;
  796|  46.0k|		file->encoded_content_len = 0;
  797|  46.0k|		return SC_SUCCESS;
  ------------------
  |  |   28|  46.0k|#define SC_SUCCESS				0
  ------------------
  798|  46.0k|	}
  799|       |
  800|    510|	tmp = (u8 *) realloc(file->encoded_content, content_len);
  801|    510|	if (!tmp) {
  ------------------
  |  Branch (801:6): [True: 0, False: 510]
  ------------------
  802|      0|		if (file->encoded_content)
  ------------------
  |  Branch (802:7): [True: 0, False: 0]
  ------------------
  803|      0|			free(file->encoded_content);
  804|      0|		file->encoded_content = NULL;
  805|      0|		file->encoded_content_len = 0;
  806|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  807|      0|	}
  808|       |
  809|    510|	file->encoded_content = tmp;
  810|    510|	memcpy(file->encoded_content, content, content_len);
  811|    510|	file->encoded_content_len = content_len;
  812|       |
  813|    510|	return SC_SUCCESS;
  ------------------
  |  |   28|    510|#define SC_SUCCESS				0
  ------------------
  814|    510|}
sc_file_valid:
  817|   424k|int sc_file_valid(const sc_file_t *file) {
  818|   424k|	if (file == NULL)
  ------------------
  |  Branch (818:6): [True: 0, False: 424k]
  ------------------
  819|      0|		return 0;
  820|   424k|	return file->magic == SC_FILE_MAGIC;
  ------------------
  |  |   57|   424k|#define SC_FILE_MAGIC			0x14426950
  ------------------
  821|   424k|}
_sc_parse_atr:
  824|  3.69k|{
  825|  3.69k|	u8 *p = reader->atr.value;
  826|  3.69k|	int atr_len = (int) reader->atr.len;
  827|  3.69k|	int n_hist, x;
  828|  3.69k|	int tx[4] = {-1, -1, -1, -1};
  829|  3.69k|	int i, FI, DI;
  830|  3.69k|	const int Fi_table[] = {
  831|  3.69k|		372, 372, 558, 744, 1116, 1488, 1860, -1,
  832|  3.69k|		-1, 512, 768, 1024, 1536, 2048, -1, -1 };
  833|  3.69k|	const int f_table[] = {
  834|  3.69k|		40, 50, 60, 80, 120, 160, 200, -1,
  835|  3.69k|		-1, 50, 75, 100, 150, 200, -1, -1 };
  836|  3.69k|	const int Di_table[] = {
  837|  3.69k|		-1, 1, 2, 4, 8, 16, 32, -1,
  838|  3.69k|		12, 20, -1, -1, -1, -1, -1, -1 };
  839|       |
  840|  3.69k|	reader->atr_info.hist_bytes_len = 0;
  841|  3.69k|	reader->atr_info.hist_bytes = NULL;
  842|       |
  843|  3.69k|	if (atr_len == 0) {
  ------------------
  |  Branch (843:6): [True: 469, False: 3.22k]
  ------------------
  844|    469|		sc_log(reader->ctx, "empty ATR - card not present?\n");
  ------------------
  |  |   71|    469|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  845|    469|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    469|#define SC_ERROR_INTERNAL			-1400
  ------------------
  846|    469|	}
  847|       |
  848|  3.22k|	if (p[0] != 0x3B && p[0] != 0x3F) {
  ------------------
  |  Branch (848:6): [True: 452, False: 2.77k]
  |  Branch (848:22): [True: 416, False: 36]
  ------------------
  849|    416|		sc_log(reader->ctx, "invalid sync byte in ATR: 0x%02X\n", p[0]);
  ------------------
  |  |   71|    416|#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|    416|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    416|#define SC_ERROR_INTERNAL			-1400
  ------------------
  851|    416|	}
  852|  2.80k|	n_hist = p[1] & 0x0F;
  853|  2.80k|	x = p[1] >> 4;
  854|  2.80k|	p += 2;
  855|  2.80k|	atr_len -= 2;
  856|  14.0k|	for (i = 0; i < 4 && atr_len > 0; i++) {
  ------------------
  |  Branch (856:14): [True: 11.2k, False: 2.80k]
  |  Branch (856:23): [True: 11.2k, False: 0]
  ------------------
  857|  11.2k|                if (x & (1 << i)) {
  ------------------
  |  Branch (857:21): [True: 8.54k, False: 2.69k]
  ------------------
  858|  8.54k|                        tx[i] = *p;
  859|  8.54k|                        p++;
  860|  8.54k|                        atr_len--;
  861|  8.54k|                } else
  862|  2.69k|                        tx[i] = -1;
  863|  11.2k|        }
  864|  2.80k|	if (tx[0] >= 0) {
  ------------------
  |  Branch (864:6): [True: 2.53k, False: 271]
  ------------------
  865|  2.53k|		reader->atr_info.FI = FI = tx[0] >> 4;
  866|  2.53k|		reader->atr_info.DI = DI = tx[0] & 0x0F;
  867|  2.53k|		reader->atr_info.Fi = Fi_table[FI];
  868|  2.53k|		reader->atr_info.f = f_table[FI];
  869|  2.53k|		reader->atr_info.Di = Di_table[DI];
  870|  2.53k|	} else {
  871|    271|		reader->atr_info.Fi = -1;
  872|    271|		reader->atr_info.f = -1;
  873|    271|		reader->atr_info.Di = -1;
  874|    271|	}
  875|  2.80k|	if (tx[2] >= 0)
  ------------------
  |  Branch (875:6): [True: 2.30k, False: 505]
  ------------------
  876|  2.30k|		reader->atr_info.N = tx[3];
  877|    505|	else
  878|    505|		reader->atr_info.N = -1;
  879|  6.46k|	while (tx[3] > 0 && tx[3] & 0xF0 && atr_len > 0) {
  ------------------
  |  Branch (879:9): [True: 3.89k, False: 2.57k]
  |  Branch (879:22): [True: 3.65k, False: 231]
  |  Branch (879:38): [True: 3.65k, False: 0]
  ------------------
  880|  3.65k|		x = tx[3] >> 4;
  881|  18.2k|		for (i = 0; i < 4 && atr_len > 0; i++) {
  ------------------
  |  Branch (881:15): [True: 14.6k, False: 3.65k]
  |  Branch (881:24): [True: 14.6k, False: 0]
  ------------------
  882|  14.6k|	                if (x & (1 << i)) {
  ------------------
  |  Branch (882:22): [True: 5.67k, False: 8.95k]
  ------------------
  883|  5.67k|	                        tx[i] = *p;
  884|  5.67k|	                        p++;
  885|  5.67k|	                        atr_len--;
  886|  5.67k|	                } else
  887|  8.95k|	                        tx[i] = -1;
  888|  14.6k|		}
  889|  3.65k|	}
  890|  2.80k|	if (atr_len <= 0)
  ------------------
  |  Branch (890:6): [True: 3, False: 2.80k]
  ------------------
  891|      3|		return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  892|  2.80k|	if (n_hist > atr_len)
  ------------------
  |  Branch (892:6): [True: 46, False: 2.76k]
  ------------------
  893|     46|		n_hist = atr_len;
  894|  2.80k|	reader->atr_info.hist_bytes_len = n_hist;
  895|  2.80k|	reader->atr_info.hist_bytes = p;
  896|  2.80k|	return SC_SUCCESS;
  ------------------
  |  |   28|  2.80k|#define SC_SUCCESS				0
  ------------------
  897|  2.80k|}
sc_mem_secure_alloc:
  900|     34|{
  901|     34|	void *p;
  902|       |
  903|       |#ifdef _WIN32
  904|       |	p = VirtualAlloc(NULL, len, MEM_COMMIT, PAGE_READWRITE);
  905|       |	if (p != NULL) {
  906|       |		VirtualLock(p, len);
  907|       |	}
  908|       |#else
  909|     34|	p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
  910|     34|	if (p != NULL) {
  ------------------
  |  Branch (910:6): [True: 34, False: 0]
  ------------------
  911|     34|		mlock(p, len);
  912|     34|	}
  913|     34|#endif
  914|       |
  915|     34|	return p;
  916|     34|}
sc_mem_secure_free:
  919|     34|{
  920|       |#ifdef _WIN32
  921|       |	VirtualUnlock(ptr, len);
  922|       |	VirtualFree(ptr, 0, MEM_RELEASE);
  923|       |#else
  924|     34|	munlock(ptr, len);
  925|     34|	munmap(ptr, len);
  926|     34|#endif
  927|     34|}
sc_mem_clear:
  930|  18.7k|{
  931|  18.7k|	if (len > 0)   {
  ------------------
  |  Branch (931:6): [True: 18.7k, False: 0]
  ------------------
  932|       |#ifdef HAVE_MEMSET_S
  933|       |		memset_s(ptr, len, 0, len);
  934|       |#elif _WIN32
  935|       |		SecureZeroMemory(ptr, len);
  936|       |#elif HAVE_EXPLICIT_BZERO
  937|       |		explicit_bzero(ptr, len);
  938|       |#elif ENABLE_OPENSSL
  939|       |		OPENSSL_cleanse(ptr, len);
  940|       |#else
  941|       |		memset(ptr, 0, len);
  942|       |#endif
  943|  18.7k|	}
  944|  18.7k|}
sc_compacttlv_find_tag:
 1058|    186|{
 1059|    186|	if (buf != NULL) {
  ------------------
  |  Branch (1059:6): [True: 186, False: 0]
  ------------------
 1060|    186|		size_t idx;
 1061|    186|		u8 plain_tag = tag & 0xF0;
 1062|    186|		size_t expected_len = tag & 0x0F;
 1063|       |
 1064|  10.5k|		for (idx = 0; idx < len; idx++) {
  ------------------
  |  Branch (1064:17): [True: 10.4k, False: 104]
  ------------------
 1065|  10.4k|			u8 ctag = buf[idx] & 0xF0;
 1066|  10.4k|			size_t ctag_len = buf[idx] & 0x0F;
 1067|  10.4k|			if (ctag == plain_tag && idx + ctag_len < len &&
  ------------------
  |  Branch (1067:8): [True: 1.48k, False: 8.94k]
  |  Branch (1067:29): [True: 1.43k, False: 50]
  ------------------
 1068|  1.43k|					(expected_len == 0 || expected_len == ctag_len)) {
  ------------------
  |  Branch (1068:7): [True: 57, False: 1.37k]
  |  Branch (1068:28): [True: 25, False: 1.34k]
  ------------------
 1069|     82|				if (outlen != NULL)
  ------------------
  |  Branch (1069:9): [True: 57, False: 25]
  ------------------
 1070|     57|					*outlen = ctag_len;
 1071|     82|				return buf + (idx + 1);
 1072|     82|			}
 1073|  10.3k|			idx += ctag_len;
 1074|  10.3k|		}
 1075|    186|	}
 1076|    104|	return NULL;
 1077|    186|}
sc_mutex_create:
 1082|  7.38k|{
 1083|  7.38k|	if (ctx == NULL)
  ------------------
  |  Branch (1083:6): [True: 0, False: 7.38k]
  ------------------
 1084|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1085|  7.38k|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->create_mutex != NULL)
  ------------------
  |  Branch (1085:6): [True: 0, False: 7.38k]
  |  Branch (1085:33): [True: 0, False: 0]
  ------------------
 1086|      0|		return ctx->thread_ctx->create_mutex(mutex);
 1087|  7.38k|	else
 1088|  7.38k|		return SC_SUCCESS;
  ------------------
  |  |   28|  7.38k|#define SC_SUCCESS				0
  ------------------
 1089|  7.38k|}
sc_mutex_lock:
 1092|  2.22M|{
 1093|  2.22M|	if (ctx == NULL)
  ------------------
  |  Branch (1093:6): [True: 0, False: 2.22M]
  ------------------
 1094|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1095|  2.22M|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->lock_mutex != NULL)
  ------------------
  |  Branch (1095:6): [True: 0, False: 2.22M]
  |  Branch (1095:33): [True: 0, False: 0]
  ------------------
 1096|      0|		return ctx->thread_ctx->lock_mutex(mutex);
 1097|  2.22M|	else
 1098|  2.22M|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.22M|#define SC_SUCCESS				0
  ------------------
 1099|  2.22M|}
sc_mutex_unlock:
 1102|  2.22M|{
 1103|  2.22M|	if (ctx == NULL)
  ------------------
  |  Branch (1103:6): [True: 0, False: 2.22M]
  ------------------
 1104|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1105|  2.22M|	if (ctx->thread_ctx != NULL && ctx->thread_ctx->unlock_mutex != NULL)
  ------------------
  |  Branch (1105:6): [True: 0, False: 2.22M]
  |  Branch (1105:33): [True: 0, False: 0]
  ------------------
 1106|      0|		return ctx->thread_ctx->unlock_mutex(mutex);
 1107|  2.22M|	else
 1108|  2.22M|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.22M|#define SC_SUCCESS				0
  ------------------
 1109|  2.22M|}

sc_verify:
  131|    394|{
  132|    394|	struct sc_pin_cmd_data data;
  133|       |
  134|    394|	memset(&data, 0, sizeof(data));
  135|    394|	data.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  422|    394|#define SC_PIN_CMD_VERIFY	0
  ------------------
  136|    394|	data.pin_type = type;
  137|    394|	data.pin_reference = ref;
  138|    394|	data.pin1.data = pin;
  139|    394|	data.pin1.len = pinlen;
  140|       |
  141|    394|	int r = sc_pin_cmd(card, &data);
  142|    394|	if (tries_left)
  ------------------
  |  Branch (142:6): [True: 394, False: 0]
  ------------------
  143|    394|		*tries_left = data.pin1.tries_left;
  144|       |
  145|    394|	return r;
  146|    394|}
sc_change_reference_data:
  159|    133|{
  160|    133|	struct sc_pin_cmd_data data;
  161|       |
  162|    133|	memset(&data, 0, sizeof(data));
  163|    133|	data.cmd = SC_PIN_CMD_CHANGE;
  ------------------
  |  |  423|    133|#define SC_PIN_CMD_CHANGE	1
  ------------------
  164|    133|	data.pin_type = type;
  165|    133|	data.pin_reference = ref;
  166|    133|	data.pin1.data = old;
  167|    133|	data.pin1.len = oldlen;
  168|    133|	data.pin2.data = newref;
  169|    133|	data.pin2.len = newlen;
  170|       |
  171|    133|	int r = sc_pin_cmd(card, &data);
  172|    133|	if (tries_left)
  ------------------
  |  Branch (172:6): [True: 0, False: 133]
  ------------------
  173|      0|		*tries_left = data.pin1.tries_left;
  174|       |
  175|    133|	return r;
  176|    133|}
sc_pin_cmd:
  204|  1.43k|{
  205|  1.43k|	int r, debug;
  206|       |
  207|  1.43k|	if (card == NULL) {
  ------------------
  |  Branch (207:6): [True: 0, False: 1.43k]
  ------------------
  208|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  209|      0|	}
  210|  1.43k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  1.43k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.43k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.43k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.43k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.43k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  211|       |
  212|  1.43k|	debug = card->ctx->debug;
  213|  1.43k|	if (data->cmd != SC_PIN_CMD_GET_INFO
  ------------------
  |  |  425|  2.86k|#define SC_PIN_CMD_GET_INFO	3
  ------------------
  |  Branch (213:6): [True: 555, False: 876]
  ------------------
  214|    555|			&& card->ctx->debug < SC_LOG_DEBUG_PIN) {
  ------------------
  |  Branch (214:7): [True: 555, False: 0]
  ------------------
  215|    555|		card->ctx->debug = 0;
  216|    555|	}
  217|       |
  218|  1.43k|	if (card->ops->pin_cmd) {
  ------------------
  |  Branch (218:6): [True: 1.43k, False: 0]
  ------------------
  219|  1.43k|		r = card->ops->pin_cmd(card, data);
  220|  1.43k|	} else if (!(data->flags & SC_PIN_CMD_USE_PINPAD)) {
  ------------------
  |  |  428|      0|#define SC_PIN_CMD_USE_PINPAD		0x0001
  ------------------
  |  Branch (220:13): [True: 0, False: 0]
  ------------------
  221|       |		/* Card driver doesn't support new style pin_cmd, fall
  222|       |		 * back to old interface */
  223|       |
  224|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  225|      0|		switch (data->cmd) {
  ------------------
  |  Branch (225:11): [True: 0, False: 0]
  ------------------
  226|      0|		case SC_PIN_CMD_VERIFY:
  ------------------
  |  |  422|      0|#define SC_PIN_CMD_VERIFY	0
  ------------------
  |  Branch (226:3): [True: 0, False: 0]
  ------------------
  227|      0|			if (card->ops->verify != NULL)
  ------------------
  |  Branch (227:8): [True: 0, False: 0]
  ------------------
  228|      0|				r = card->ops->verify(card,
  229|      0|					data->pin_type,
  230|      0|					data->pin_reference,
  231|      0|					data->pin1.data,
  232|      0|					(size_t) data->pin1.len,
  233|      0|					&data->pin1.tries_left);
  234|      0|			break;
  235|      0|		case SC_PIN_CMD_CHANGE:
  ------------------
  |  |  423|      0|#define SC_PIN_CMD_CHANGE	1
  ------------------
  |  Branch (235:3): [True: 0, False: 0]
  ------------------
  236|      0|			if (card->ops->change_reference_data != NULL)
  ------------------
  |  Branch (236:8): [True: 0, False: 0]
  ------------------
  237|      0|				r = card->ops->change_reference_data(card,
  238|      0|					data->pin_type,
  239|      0|					data->pin_reference,
  240|      0|					data->pin1.data,
  241|      0|					(size_t) data->pin1.len,
  242|      0|					data->pin2.data,
  243|      0|					(size_t) data->pin2.len,
  244|      0|					&data->pin1.tries_left);
  245|      0|			break;
  246|      0|		case SC_PIN_CMD_UNBLOCK:
  ------------------
  |  |  424|      0|#define SC_PIN_CMD_UNBLOCK	2
  ------------------
  |  Branch (246:3): [True: 0, False: 0]
  ------------------
  247|      0|			if (card->ops->reset_retry_counter != NULL)
  ------------------
  |  Branch (247:8): [True: 0, False: 0]
  ------------------
  248|      0|				r = card->ops->reset_retry_counter(card,
  249|      0|					data->pin_type,
  250|      0|					data->pin_reference,
  251|      0|					data->pin1.data,
  252|      0|					(size_t) data->pin1.len,
  253|      0|					data->pin2.data,
  254|      0|					(size_t) data->pin2.len);
  255|      0|			break;
  256|      0|		}
  257|      0|		if (r == SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (257:7): [True: 0, False: 0]
  ------------------
  258|      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__
  |  |  ------------------
  ------------------
  259|      0|					data->cmd);
  260|      0|	} else {
  261|      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__
  |  |  ------------------
  ------------------
  262|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  263|      0|	}
  264|  1.43k|	card->ctx->debug = debug;
  265|       |
  266|  1.43k|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, r);
  ------------------
  |  |  153|  1.43k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|  1.43k|	int _ret = r; \
  |  |  155|  1.43k|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 1.43k, False: 0]
  |  |  ------------------
  |  |  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|    653|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 653, False: 778]
  |  |  ------------------
  |  |  157|  1.43k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  158|  1.43k|	} else { \
  |  |  159|      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.43k|	return _ret; \
  |  |  163|  1.43k|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  267|  1.43k|}
sc_build_pin:
  281|    139|{
  282|    139|	size_t i = 0, j, pin_len = pin->len;
  283|       |
  284|    139|	if (pin->max_length && pin_len > pin->max_length)
  ------------------
  |  Branch (284:6): [True: 5, False: 134]
  |  Branch (284:25): [True: 0, False: 5]
  ------------------
  285|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  286|       |
  287|    139|	if (pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  434|    139|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (287:6): [True: 0, False: 139]
  ------------------
  288|      0|		while (pin_len > 0 && pin->data[pin_len - 1] == 0xFF)
  ------------------
  |  Branch (288:10): [True: 0, False: 0]
  |  Branch (288:25): [True: 0, False: 0]
  ------------------
  289|      0|			pin_len--;
  290|      0|		if (pin_len > 12)
  ------------------
  |  Branch (290:7): [True: 0, False: 0]
  ------------------
  291|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  292|      0|		for (i = 0; i < pin_len; i++) {
  ------------------
  |  Branch (292:15): [True: 0, False: 0]
  ------------------
  293|      0|			if (pin->data[i] < '0' || pin->data[i] > '9')
  ------------------
  |  Branch (293:8): [True: 0, False: 0]
  |  Branch (293:30): [True: 0, False: 0]
  ------------------
  294|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  295|      0|		}
  296|      0|		buf[0] = 0x20 | (u8) pin_len;
  297|      0|		buf++;
  298|      0|		buflen--;
  299|      0|	}
  300|       |
  301|       |	/* PIN given by application, encode if required */
  302|    139|	if (pin->encoding == SC_PIN_ENCODING_ASCII) {
  ------------------
  |  |  432|    139|#define SC_PIN_ENCODING_ASCII	0
  ------------------
  |  Branch (302:6): [True: 139, False: 0]
  ------------------
  303|    139|		if (pin_len > buflen)
  ------------------
  |  Branch (303:7): [True: 0, False: 139]
  ------------------
  304|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  305|    139|		memcpy(buf, pin->data, pin_len);
  306|    139|		i = pin_len;
  307|    139|	} else if (pin->encoding == SC_PIN_ENCODING_BCD || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  433|      0|#define SC_PIN_ENCODING_BCD	1
  ------------------
              	} else if (pin->encoding == SC_PIN_ENCODING_BCD || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  434|      0|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (307:13): [True: 0, False: 0]
  |  Branch (307:53): [True: 0, False: 0]
  ------------------
  308|      0|		if (pin_len > 2 * buflen)
  ------------------
  |  Branch (308:7): [True: 0, False: 0]
  ------------------
  309|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  310|      0|		for (i = j = 0; j < pin_len; j++) {
  ------------------
  |  Branch (310:19): [True: 0, False: 0]
  ------------------
  311|      0|			if (!isdigit(pin->data[j])) {
  ------------------
  |  Branch (311:8): [True: 0, False: 0]
  ------------------
  312|      0|				return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  313|      0|			}
  314|      0|			buf[i] <<= 4;
  315|      0|			buf[i] |= pin->data[j] & 0xf;
  316|      0|			if (j & 1)
  ------------------
  |  Branch (316:8): [True: 0, False: 0]
  ------------------
  317|      0|				i++;
  318|      0|		}
  319|      0|		if (j & 1) {
  ------------------
  |  Branch (319:7): [True: 0, False: 0]
  ------------------
  320|      0|			buf[i] <<= 4;
  321|      0|			buf[i] |= pin->pad_char & 0xf;
  322|      0|			i++;
  323|      0|		}
  324|      0|	}
  325|       |
  326|       |	/* Pad to maximum PIN length if requested */
  327|    139|	if (pad || pin->encoding == SC_PIN_ENCODING_GLP) {
  ------------------
  |  |  434|    133|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (327:6): [True: 6, False: 133]
  |  Branch (327:13): [True: 0, False: 133]
  ------------------
  328|      6|		size_t pad_length = pin->pad_length;
  329|      6|		u8     pad_char   = pin->encoding == SC_PIN_ENCODING_GLP ? 0xFF : pin->pad_char;
  ------------------
  |  |  434|      6|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (329:23): [True: 0, False: 6]
  ------------------
  330|       |
  331|      6|		if (pin->encoding == SC_PIN_ENCODING_BCD)
  ------------------
  |  |  433|      6|#define SC_PIN_ENCODING_BCD	1
  ------------------
  |  Branch (331:7): [True: 0, False: 6]
  ------------------
  332|      0|			pad_length >>= 1;
  333|      6|		if (pin->encoding == SC_PIN_ENCODING_GLP)
  ------------------
  |  |  434|      6|#define SC_PIN_ENCODING_GLP	2 /* Global Platform - Card Specification v2.0.1 */
  ------------------
  |  Branch (333:7): [True: 0, False: 6]
  ------------------
  334|      0|			pad_length = 8;
  335|       |
  336|      6|		if (pad_length > buflen)
  ------------------
  |  Branch (336:7): [True: 0, False: 6]
  ------------------
  337|      0|			return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
  338|       |
  339|      6|		if (pad_length && i < pad_length) {
  ------------------
  |  Branch (339:7): [True: 5, False: 1]
  |  Branch (339:21): [True: 3, False: 2]
  ------------------
  340|      3|			memset(buf + i, pad_char, pad_length - i);
  341|      3|			i = pad_length;
  342|      3|		}
  343|      6|	}
  344|       |
  345|    139|	return (int)i;
  346|    139|}

sc_simpletlv_read_tag:
   77|  24.7k|{
   78|  24.7k|	u8 tag;
   79|  24.7k|	size_t left = buflen, len;
   80|  24.7k|	const u8 *p = *buf;
   81|       |
   82|  24.7k|	*buf = NULL;
   83|       |
   84|  24.7k|	if (left < 2) {
  ------------------
  |  Branch (84:6): [True: 365, False: 24.4k]
  ------------------
   85|    365|		return SC_ERROR_INVALID_TLV_OBJECT;
  ------------------
  |  |   98|    365|#define SC_ERROR_INVALID_TLV_OBJECT		-1417
  ------------------
   86|    365|	}
   87|  24.4k|	tag = *p;
   88|  24.4k|	p++;
   89|  24.4k|	len = *p;
   90|  24.4k|	p++;
   91|  24.4k|	left -= 2;
   92|       |
   93|  24.4k|	if (len == 0xff) {
  ------------------
  |  Branch (93:6): [True: 723, False: 23.6k]
  ------------------
   94|       |		/* don't crash on bad data */
   95|    723|		if (left < 2) {
  ------------------
  |  Branch (95:7): [True: 64, False: 659]
  ------------------
   96|     64|			return SC_ERROR_INVALID_TLV_OBJECT;
  ------------------
  |  |   98|     64|#define SC_ERROR_INVALID_TLV_OBJECT		-1417
  ------------------
   97|     64|		}
   98|       |		/* skip two bytes (the size) */
   99|    659|		len = lebytes2ushort(p);
  100|    659|		p += 2;
  101|    659|		left -= 2;
  102|    659|	}
  103|       |
  104|  24.3k|	*tag_out = tag;
  105|  24.3k|	*taglen = len;
  106|  24.3k|	*buf = p;
  107|       |
  108|  24.3k|	if (len > left)
  ------------------
  |  Branch (108:6): [True: 804, False: 23.5k]
  ------------------
  109|    804|		return SC_ERROR_TLV_END_OF_CONTENTS;
  ------------------
  |  |   99|    804|#define SC_ERROR_TLV_END_OF_CONTENTS	-1418
  ------------------
  110|       |
  111|  23.5k|	return SC_SUCCESS;
  ------------------
  |  |   28|  23.5k|#define SC_SUCCESS				0
  ------------------
  112|  24.3k|}

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

sc_pkcs15init_get_authentic_ops:
  933|    126|{
  934|    126|	return &sc_pkcs15init_authentic_operations;
  935|    126|}
pkcs15-authentic.c:authentic_pkcs15_erase_card:
  138|    121|{
  139|    121|	struct sc_context *ctx = p15card->card->ctx;
  140|    121|	struct sc_file  *file = NULL;
  141|    121|	struct sc_pkcs15_df *df;
  142|    121|	int rv;
  143|       |
  144|    121|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    121|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    121|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    121|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    121|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 121]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  145|       |
  146|    121|	if (p15card->file_odf)   {
  ------------------
  |  Branch (146:6): [True: 4, False: 117]
  ------------------
  147|      4|		sc_log(ctx, "Select ODF path: %s", sc_print_path(&p15card->file_odf->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  148|      4|		rv = sc_select_file(p15card->card, &p15card->file_odf->path, NULL);
  149|      4|		LOG_TEST_RET(ctx, rv, "Erase application error: cannot select ODF path");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|      4|	}
  151|       |
  152|    134|	for (df = p15card->df_list; df; df = df->next)   {
  ------------------
  |  Branch (152:30): [True: 23, False: 111]
  ------------------
  153|     23|		struct sc_pkcs15_object *objs[32];
  154|     23|		unsigned obj_type = 0;
  155|     23|		int ii;
  156|       |
  157|     23|		if (df->type == SC_PKCS15_PRKDF)
  ------------------
  |  |  488|     23|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (157:7): [True: 7, False: 16]
  ------------------
  158|      7|			obj_type = SC_PKCS15_TYPE_PRKEY;
  ------------------
  |  |  418|      7|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  159|     16|		else if (df->type == SC_PKCS15_PUKDF)
  ------------------
  |  |  489|     16|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (159:12): [True: 1, False: 15]
  ------------------
  160|      1|			obj_type = SC_PKCS15_TYPE_PUBKEY;
  ------------------
  |  |  425|      1|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  161|     15|		else if (df->type == SC_PKCS15_CDF)
  ------------------
  |  |  492|     15|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (161:12): [True: 7, False: 8]
  ------------------
  162|      7|			obj_type = SC_PKCS15_TYPE_CERT;
  ------------------
  |  |  438|      7|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  163|      8|		else if (df->type == SC_PKCS15_DODF)
  ------------------
  |  |  495|      8|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (163:12): [True: 1, False: 7]
  ------------------
  164|      1|			obj_type = SC_PKCS15_TYPE_DATA_OBJECT;
  ------------------
  |  |  442|      1|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  165|      7|		else
  166|      7|			continue;
  167|       |
  168|     16|		if (df->enumerated)   {
  ------------------
  |  Branch (168:7): [True: 13, False: 3]
  ------------------
  169|     13|			rv = sc_pkcs15_get_objects(p15card, obj_type, objs, 32);
  170|     13|			LOG_TEST_RET(ctx, rv, "Failed to get PKCS#15 objects to remove");
  ------------------
  |  |  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: 0, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 13]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  171|       |
  172|     26|			for (ii=0; ii<rv; ii++) {
  ------------------
  |  Branch (172:15): [True: 13, False: 13]
  ------------------
  173|     13|				sc_pkcs15_remove_object(p15card, objs[ii]);
  174|     13|				sc_pkcs15_free_object(objs[ii]);
  175|     13|			}
  176|     13|		}
  177|       |
  178|     16|		rv = sc_select_file(p15card->card, &df->path, &file);
  179|     16|		if (rv == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|     16|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (179:7): [True: 0, False: 16]
  ------------------
  180|      0|			continue;
  181|     16|		LOG_TEST_RET(ctx, rv, "Cannot select object data file");
  ------------------
  |  |  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: 7, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|       |
  183|      9|		rv = sc_erase_binary(p15card->card, 0, file->size, 0);
  184|      9|		if (rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)   {
  ------------------
  |  |   61|      9|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (184:7): [True: 2, False: 7]
  ------------------
  185|      2|			rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      2|#define SC_AC_OP_UPDATE			23
  ------------------
  186|      2|			if (rv < 0)
  ------------------
  |  Branch (186:8): [True: 1, False: 1]
  ------------------
  187|      1|				sc_file_free(file);
  188|       |
  189|      2|			LOG_TEST_RET(ctx, rv, "'UPDATE' authentication 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  190|       |
  191|      1|			rv = sc_erase_binary(p15card->card, 0, file->size, 0);
  192|      1|		}
  193|       |
  194|      8|		sc_file_free(file);
  195|      8|		LOG_TEST_RET(ctx, rv, "Binary erase error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|       |
  197|      7|		profile->dirty = 1;
  198|      7|	}
  199|       |
  200|    111|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    111|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 111]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|    111|}
pkcs15-authentic.c:authentic_pkcs15_create_pin:
  898|    120|{
  899|    120|	LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    120|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    120|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    120|	int _ret = r; \
  |  |  |  |  155|    120|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 120, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    120|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    120|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 120, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    120|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    120|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    120|	return _ret; \
  |  |  |  |  163|    120|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  900|    120|}
pkcs15-authentic.c:authentic_pkcs15_select_key_reference:
  270|    105|{
  271|    105|	struct sc_context *ctx = p15card->card->ctx;
  272|       |
  273|    105|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  274|       |
  275|       |	/* In authentic PKCS#15 all crypto objects are locals */
  276|    105|	key_info->key_reference |= AUTHENTIC_OBJECT_REF_FLAG_LOCAL;
  ------------------
  |  |   49|    105|#define AUTHENTIC_OBJECT_REF_FLAG_LOCAL	0x80
  ------------------
  277|       |
  278|    105|	if (key_info->key_reference > AUTHENTIC_V3_CRYPTO_OBJECT_REF_MAX)
  ------------------
  |  |   41|    105|#define AUTHENTIC_V3_CRYPTO_OBJECT_REF_MAX	0xFF
  ------------------
  |  Branch (278:6): [True: 0, False: 105]
  ------------------
  279|    105|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  280|       |
  281|    105|	if (key_info->key_reference < AUTHENTIC_V3_CRYPTO_OBJECT_REF_MIN)
  ------------------
  |  |   40|    105|#define AUTHENTIC_V3_CRYPTO_OBJECT_REF_MIN	0x81
  ------------------
  |  Branch (281:6): [True: 105, False: 0]
  ------------------
  282|    105|		key_info->key_reference = AUTHENTIC_V3_CRYPTO_OBJECT_REF_MIN;
  ------------------
  |  |   40|    105|#define AUTHENTIC_V3_CRYPTO_OBJECT_REF_MIN	0x81
  ------------------
  283|       |
  284|    105|	sc_log(ctx, "returns key reference %i", key_info->key_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  285|    105|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 105]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  286|    105|}
pkcs15-authentic.c:authentic_pkcs15_create_key:
  518|    105|{
  519|    105|	struct sc_card *card = p15card->card;
  520|    105|	struct sc_context *ctx = card->ctx;
  521|    105|	struct sc_authentic_sdo *sdo = NULL;
  522|    105|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *) object->data;
  523|    105|	struct sc_file	*file_p_prvkey = NULL, *parent = NULL;
  524|    105|	size_t keybits = key_info->modulus_length;
  525|    105|	int	 rv;
  526|       |
  527|    105|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  528|    105|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  529|    105|	       "create private key(keybits:%"SC_FORMAT_LEN_SIZE_T"u,usage:%X,access:%X,ref:%X)",
  530|    105|	       keybits, key_info->usage, key_info->access_flags,
  531|    105|	       key_info->key_reference);
  532|    105|	if (keybits < 1024 || keybits > 2048 || (keybits % 256))
  ------------------
  |  Branch (532:6): [True: 0, False: 105]
  |  Branch (532:24): [True: 0, False: 105]
  |  Branch (532:42): [True: 0, False: 105]
  ------------------
  533|    105|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid RSA key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  534|       |
  535|    105|	rv = authentic_pkcs15_new_file(profile, card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file_p_prvkey);
  ------------------
  |  |  419|    105|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  536|    105|	LOG_TEST_RET(ctx, rv, "IasEcc pkcs15 new PRKEY_RSA file error");
  ------------------
  |  |  174|    105|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    105|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    105|	int _ret = (r); \
  |  |  |  |  168|    105|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 99, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|    105|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 6]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  537|       |
  538|      6|	key_info->key_reference |= AUTHENTIC_OBJECT_REF_FLAG_LOCAL;
  ------------------
  |  |   49|      6|#define AUTHENTIC_OBJECT_REF_FLAG_LOCAL	0x80
  ------------------
  539|       |
  540|      6|	rv = sc_select_file(card, &file_p_prvkey->path, &parent);
  541|      6|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|      6|#define SC_SUCCESS				0
  ------------------
  |  Branch (541:6): [True: 1, False: 5]
  ------------------
  542|      1|		sc_file_free(file_p_prvkey);
  543|      6|	LOG_TEST_RET(ctx, rv, "DF for the private objects not defined");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|       |
  545|      5|	rv = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_CRYPTO);
  ------------------
  |  |  173|      5|#define SC_AC_OP_CRYPTO			7
  ------------------
  546|      5|	sc_file_free(parent);
  547|      5|	if (rv != SC_SUCCESS)
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (547:6): [True: 2, False: 3]
  ------------------
  548|      2|		sc_file_free(file_p_prvkey);
  549|      5|	LOG_TEST_RET(ctx, rv, "SC_AC_OP_CRYPTO authentication failed for parent DF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  550|       |
  551|      3|	key_info->access_flags = SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE
  ------------------
  |  |  319|      3|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
  552|      3|		| SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE
  ------------------
  |  |  318|      3|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
  553|      3|		| SC_PKCS15_PRKEY_ACCESS_SENSITIVE;
  ------------------
  |  |  316|      3|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
  554|       |
  555|      3|	rv = authentic_sdo_allocate_prvkey(profile, card, key_info, &sdo);
  556|      3|	if (rv != SC_SUCCESS || sdo == NULL) {
  ------------------
  |  |   28|      6|#define SC_SUCCESS				0
  ------------------
  |  Branch (556:6): [True: 3, False: 0]
  |  Branch (556:26): [True: 0, False: 0]
  ------------------
  557|      3|		sc_log(ctx, "IasEcc: init SDO private key failed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  558|      3|		sc_file_free(file_p_prvkey);
  559|      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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|      3|	}
  561|       |
  562|      0|	rv = sc_card_ctl(card, SC_CARDCTL_AUTHENTIC_SDO_CREATE, sdo);
  563|      0|	if (rv == SC_ERROR_FILE_ALREADY_EXISTS)   {
  ------------------
  |  |   65|      0|#define SC_ERROR_FILE_ALREADY_EXISTS		-1215
  ------------------
  |  Branch (563:6): [True: 0, False: 0]
  ------------------
  564|      0|		unsigned long caps = p15card->card->caps;
  565|       |
  566|      0|		p15card->card->caps &= ~SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  564|      0|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  567|      0|		rv = sc_pkcs15init_authenticate(profile, p15card, file_p_prvkey, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      0|#define SC_AC_OP_DELETE			2
  ------------------
  568|      0|		p15card->card->caps = caps;
  569|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "SC_AC_OP_CRYPTO authentication failed for parent 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  570|       |
  571|      0|		rv = sc_card_ctl(card, SC_CARDCTL_AUTHENTIC_SDO_DELETE, sdo);
  572|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "SC_CARDCTL_AUTHENTIC_SDO_DELETE failed for private 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|       |
  574|      0|		rv = sc_card_ctl(card, SC_CARDCTL_AUTHENTIC_SDO_CREATE, sdo);
  575|      0|	}
  576|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "SC_CARDCTL_AUTHENTIC_SDO_CREATE 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  577|       |
  578|      0|	rv = authentic_pkcs15_fix_access(p15card, file_p_prvkey, object);
  579|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "cannot fix access rules for private 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  580|       |
  581|      0|	rv = authentic_pkcs15_fix_usage(p15card, object);
  582|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "cannot fix access rules for private 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|       |
  584|       |	/* Here fix the key's supported algorithms, if these ones will be implemented
  585|       |	 * (see src/libopensc/pkcs15-prkey.c).
  586|       |	 */
  587|       |
  588|      0|	sdo->file = file_p_prvkey;
  589|      0|	sc_log(ctx, "sdo->file:%p", sdo->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__
  |  |  ------------------
  ------------------
  590|       |
  591|      0|	rv = sc_pkcs15_allocate_object_content(ctx, object, (unsigned char *)sdo, sizeof(struct sc_authentic_sdo));
  592|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "Failed to allocate PrvKey SDO as object content");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  593|       |
  594|      0|err:
  595|      0|	if (sdo == NULL || sdo->file != file_p_prvkey)
  ------------------
  |  Branch (595:6): [True: 0, False: 0]
  |  Branch (595:21): [True: 0, False: 0]
  ------------------
  596|      0|		sc_file_free(file_p_prvkey);
  597|      0|	authentic_free_sdo_data(sdo);
  598|      0|	free(sdo);
  599|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  600|      0|}
pkcs15-authentic.c:authentic_pkcs15_new_file:
  210|    108|{
  211|    108|	struct sc_context *ctx = card->ctx;
  212|    108|	struct sc_file	*file = NULL;
  213|    108|	const char *t_name = NULL;
  214|    108|	int rv;
  215|       |
  216|    108|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    108|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    108|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    108|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    108|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 108]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|    108|	sc_log(ctx, "type %X; num %i", type, num);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  218|    108|	switch (type) {
  219|    108|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    108|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (219:3): [True: 108, False: 0]
  ------------------
  220|    108|			t_name = "template-private-key";
  221|    108|			break;
  222|      0|		case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (222:3): [True: 0, False: 108]
  ------------------
  223|      0|			t_name = "template-public-key";
  224|      0|			break;
  225|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (225:3): [True: 0, False: 108]
  ------------------
  226|      0|			t_name = "template-certificate";
  227|      0|			break;
  228|      0|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (228:3): [True: 0, False: 108]
  ------------------
  229|      0|			t_name = "template-public-data";
  230|      0|			break;
  231|      0|		default:
  ------------------
  |  Branch (231:3): [True: 0, False: 108]
  ------------------
  232|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Profile template 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  233|    108|	}
  234|       |
  235|    108|	sc_log(ctx, "df_info path '%s'", sc_print_path(&profile->df_info->file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  236|    108|	rv = sc_profile_get_file(profile, t_name, &file);
  237|    108|	LOG_TEST_RET(ctx, rv, "Error when getting file from template");
  ------------------
  |  |  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: 99, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  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|    108|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 9]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  238|       |
  239|      9|	sc_log(ctx, "file(type:%X), path(type:%X,path:%s)", file->type, file->path.type, sc_print_path(&file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  240|       |
  241|      9|	file->id = (file->id & 0xFF00) | (num & 0xFF);
  242|      9|	if (file->type != SC_FILE_TYPE_BSO)   {
  ------------------
  |  |  217|      9|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (242:6): [True: 9, False: 0]
  ------------------
  243|      9|		if (file->path.len == 0)   {
  ------------------
  |  Branch (243:7): [True: 7, False: 2]
  ------------------
  244|      7|			file->path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      7|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  245|      7|			file->path.len = 2;
  246|      7|		}
  247|      9|		file->path.value[file->path.len - 2] = (file->id >> 8) & 0xFF;
  248|      9|		file->path.value[file->path.len - 1] = file->id & 0xFF;
  249|      9|		file->path.count = -1;
  250|      9|	}
  251|       |
  252|      9|	sc_log(ctx, "file(size:%"SC_FORMAT_LEN_SIZE_T"u,type:%i/%i,id:%04X), path(type:%X,'%s')",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  253|      9|	       file->size, file->type, file->ef_structure, file->id,
  254|      9|	       file->path.type, sc_print_path(&file->path));
  255|      9|	if (out)
  ------------------
  |  Branch (255:6): [True: 9, False: 0]
  ------------------
  256|      9|		*out = file;
  257|      0|	else
  258|      0|		sc_file_free(file);
  259|       |
  260|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  261|      9|}
pkcs15-authentic.c:authentic_sdo_allocate_prvkey:
  331|      3|{
  332|      3|	struct sc_context *ctx = card->ctx;
  333|      3|	struct sc_authentic_sdo *sdo = NULL;
  334|      3|	struct sc_file *file = NULL;
  335|      3|	int rv;
  336|       |
  337|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  338|       |
  339|      3|	if (!out)
  ------------------
  |  Branch (339:6): [True: 0, False: 3]
  ------------------
  340|      3|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|      3|	if ((key_info->modulus_length % 256) || key_info->modulus_length < 1024 || key_info->modulus_length > 2048)
  ------------------
  |  Branch (342:6): [True: 0, False: 3]
  |  Branch (342:42): [True: 0, False: 3]
  |  Branch (342:77): [True: 0, False: 3]
  ------------------
  343|      3|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  344|       |
  345|      3|	rv = authentic_pkcs15_new_file(profile, card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
  ------------------
  |  |  419|      3|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  346|      3|	LOG_TEST_RET(ctx, rv, "Cannot instantiate new PRKEY-RSA file");
  ------------------
  |  |  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: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  347|       |
  348|      3|	sdo = calloc(1, sizeof(struct sc_authentic_sdo));
  349|      3|	if (!sdo) {
  ------------------
  |  Branch (349:6): [True: 0, False: 3]
  ------------------
  350|      0|		sc_file_free(file);
  351|      0|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate 'sc_authentic_sdo'");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  352|      0|	}
  353|       |
  354|      3|	sdo->magic = AUTHENTIC_SDO_MAGIC;
  ------------------
  |  |   45|      3|#define AUTHENTIC_SDO_MAGIC                _MAKE_AUTHENTIC_MAGIC('A', 'W', 'S', 'D')
  |  |  ------------------
  |  |  |  |   43|      3|#define _MAKE_AUTHENTIC_MAGIC(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | ((d)))
  |  |  ------------------
  ------------------
  355|      3|	sdo->docp.id = key_info->key_reference &  ~AUTHENTIC_OBJECT_REF_FLAG_LOCAL;
  ------------------
  |  |   49|      3|#define AUTHENTIC_OBJECT_REF_FLAG_LOCAL	0x80
  ------------------
  356|      3|	sdo->docp.mech = authentic_v3_rsa_mechs[(key_info->modulus_length - 1024) / 256];
  357|       |
  358|      3|	rv = authentic_docp_set_acls(card, file, authentic_v3_rsa_ac_ops,
  359|      3|			sizeof(authentic_v3_rsa_ac_ops)/sizeof(authentic_v3_rsa_ac_ops[0]), &sdo->docp);
  360|      3|	sc_file_free(file);
  361|      3|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
  |  Branch (361:6): [True: 3, False: 0]
  ------------------
  362|      3|		free(sdo);
  363|      3|		sc_log(ctx, "Cannot set key ACLs from file");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  364|      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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  365|      3|	}
  366|       |
  367|      0|	sc_log(ctx, "sdo(mech:%X,id:%X,acls:%s)", 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__
  |  |  ------------------
  ------------------
  368|      0|			sc_dump_hex(sdo->docp.acl_data, sdo->docp.acl_data_len));
  369|       |
  370|      0|	*out = sdo;
  371|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  372|      0|}
pkcs15-authentic.c:authentic_docp_set_acls:
  293|      3|{
  294|      3|	struct sc_context *ctx = card->ctx;
  295|      3|	unsigned ii, offs;
  296|       |
  297|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|      3|	if (ops_len > sizeof(docp->acl_data) / 2)
  ------------------
  |  Branch (298:6): [True: 0, False: 3]
  ------------------
  299|      3|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  300|       |
  301|     21|	for (ii=0, offs=0; ii<ops_len; ii++)   {
  ------------------
  |  Branch (301:21): [True: 18, False: 3]
  ------------------
  302|     18|		const struct sc_acl_entry *entry;
  303|       |
  304|     18|		entry = sc_file_get_acl_entry(file, *(ops + ii));
  305|     18|		if (entry->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|     18|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (305:7): [True: 3, False: 15]
  ------------------
  306|      3|			docp->acl_data[offs++] = 0x00;
  307|      3|			docp->acl_data[offs++] = 0x00;
  308|      3|		}
  309|     15|		else if (entry->method == SC_AC_NONE)   {
  ------------------
  |  |  150|     15|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (309:12): [True: 10, False: 5]
  ------------------
  310|     10|			docp->acl_data[offs++] = 0x00;
  311|     10|			docp->acl_data[offs++] = 0x00;
  312|     10|		}
  313|      5|		else if (entry->method == SC_AC_CHV)   {
  ------------------
  |  |  151|      5|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (313:12): [True: 0, False: 5]
  ------------------
  314|      0|			if (!(entry->key_ref & AUTHENTIC_V3_CREDENTIAL_ID_MASK)
  ------------------
  |  |   38|      0|#define AUTHENTIC_V3_CREDENTIAL_ID_MASK	7
  ------------------
  |  Branch (314:8): [True: 0, False: 0]
  ------------------
  315|      0|					|| (entry->key_ref & ~AUTHENTIC_V3_CREDENTIAL_ID_MASK))
  ------------------
  |  |   38|      0|#define AUTHENTIC_V3_CREDENTIAL_ID_MASK	7
  ------------------
  |  Branch (315:9): [True: 0, False: 0]
  ------------------
  316|      0|				LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Non supported Credential Reference");
  ------------------
  |  |  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|       |
  318|      0|			docp->acl_data[offs++] = 0x00;
  319|      0|			docp->acl_data[offs++] = 0x01 << (entry->key_ref - 1);
  320|      0|		}
  321|     18|	}
  322|       |
  323|      3|	docp->acl_data_len = offs;
  324|      3|	LOG_FUNC_RETURN(ctx, offs);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  325|      3|}
pkcs15-authentic.c:authentic_pkcs15_generate_key:
  609|      3|{
  610|      3|	struct sc_card *card = p15card->card;
  611|      3|	struct sc_context *ctx = card->ctx;
  612|      3|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *) object->data;
  613|      3|	size_t keybits = key_info->modulus_length;
  614|      3|	struct sc_authentic_sdo *sdo = NULL;
  615|      3|	unsigned char *tmp = NULL;
  616|      3|	size_t tmp_len;
  617|      3|	unsigned long caps;
  618|      3|	int rv;
  619|       |
  620|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  621|      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__
  |  |  ------------------
  ------------------
  622|      3|	       "generate key(bits:%"SC_FORMAT_LEN_SIZE_T"u,path:%s,AuthID:%s\n",
  623|      3|	       keybits, sc_print_path(&key_info->path),
  624|      3|	       sc_pkcs15_print_id(&object->auth_id));
  625|       |
  626|      3|	if (!object->content.value || object->content.len != sizeof(struct sc_authentic_sdo))
  ------------------
  |  Branch (626:6): [True: 3, False: 0]
  |  Branch (626:32): [True: 0, False: 0]
  ------------------
  627|      3|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid PrKey SDO data");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  628|      0|	else if (keybits < 1024 || keybits > 2048 || (keybits % 256))
  ------------------
  |  Branch (628:11): [True: 0, False: 0]
  |  Branch (628:29): [True: 0, False: 0]
  |  Branch (628:47): [True: 0, False: 0]
  ------------------
  629|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid RSA key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|       |
  631|      0|	sdo = (struct sc_authentic_sdo *)object->content.value;
  632|      0|	if (sdo->magic != AUTHENTIC_SDO_MAGIC)
  ------------------
  |  |   45|      0|#define AUTHENTIC_SDO_MAGIC                _MAKE_AUTHENTIC_MAGIC('A', 'W', 'S', 'D')
  |  |  ------------------
  |  |  |  |   43|      0|#define _MAKE_AUTHENTIC_MAGIC(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | ((d)))
  |  |  ------------------
  ------------------
  |  Branch (632:6): [True: 0, False: 0]
  ------------------
  633|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "'Magic' control failed for SDO PrvKey");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  634|       |
  635|      0|	rv = sc_select_file(card, &key_info->path, NULL);
  636|      0|	LOG_TEST_RET(ctx, rv, "failed to select parent DF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  637|       |
  638|      0|	caps = card->caps;
  639|      0|	card->caps &= ~SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  564|      0|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  640|      0|	rv = sc_pkcs15init_authenticate(profile, p15card, sdo->file, SC_AC_OP_GENERATE);
  ------------------
  |  |  192|      0|#define SC_AC_OP_GENERATE		26
  ------------------
  641|      0|	card->caps = caps;
  642|      0|	LOG_TEST_RET(ctx, rv, "SC_AC_OP_GENERATE authentication 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|       |
  644|      0|	key_info->access_flags |= SC_PKCS15_PRKEY_ACCESS_LOCAL;
  ------------------
  |  |  320|      0|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  645|       |
  646|      0|	rv = sc_card_ctl(card, SC_CARDCTL_AUTHENTIC_SDO_GENERATE, sdo);
  647|      0|	LOG_TEST_RET(ctx, rv, "generate 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  648|       |
  649|      0|	pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  650|       |	//FIXME: allocate/copy/free to reduce memory leakage
  651|      0|	pubkey->u.rsa.modulus = sdo->data.prvkey->u.rsa.modulus;
  652|      0|	pubkey->u.rsa.exponent = sdo->data.prvkey->u.rsa.exponent;
  653|      0|	sdo->data.prvkey = NULL;
  654|       |
  655|      0|	rv = sc_pkcs15_encode_pubkey(ctx, pubkey, &tmp, &tmp_len);
  656|      0|	LOG_TEST_RET(ctx, rv, "encode public 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  657|       |
  658|       |	/*
  659|       |	 * Here algorithms supported by key have to be fixed, if it will be implemented
  660|       |	 * (see src/libopensc/pkcs15-prkey.c).
  661|       |	 */
  662|       |
  663|      0|	authentic_free_sdo_data(sdo);
  664|       |
  665|      0|	rv = sc_pkcs15_allocate_object_content(ctx, object, tmp, tmp_len);
  666|      0|	LOG_TEST_RET(ctx, rv, "Failed to allocate public key as object content");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  667|       |
  668|      0|	free(tmp);
  669|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  670|      0|}
pkcs15-authentic.c:authentic_emu_update_tokeninfo:
  852|      6|{
  853|      6|	struct sc_context *ctx = p15card->card->ctx;
  854|      6|	struct sc_file *file = NULL;
  855|      6|	struct sc_path path;
  856|      6|	unsigned char buffer[8];
  857|      6|	int rv;
  858|      6|	size_t len;
  859|       |
  860|      6|	sc_format_path(AUTHENTIC_CACHE_TIMESTAMP_PATH, &path);
  ------------------
  |  |   47|      6|#define AUTHENTIC_CACHE_TIMESTAMP_PATH "3F0050159999"
  ------------------
  861|      6|	rv = sc_select_file(p15card->card, &path, &file);
  862|      6|	if (!rv) {
  ------------------
  |  Branch (862:6): [True: 5, False: 1]
  ------------------
  863|      5|		rv = sc_get_challenge(p15card->card, buffer, sizeof(buffer));
  864|      5|		if (rv < 0) {
  ------------------
  |  Branch (864:7): [True: 4, False: 1]
  ------------------
  865|      4|			sc_file_free(file);
  866|      4|			LOG_TEST_RET(ctx, rv, "Get challenge error");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|      4|		}
  868|       |
  869|      1|		len = file->size > sizeof(buffer) ? sizeof(buffer) : file->size;
  ------------------
  |  Branch (869:9): [True: 1, False: 0]
  ------------------
  870|      1|		rv = sc_update_binary(p15card->card, 0, buffer, len, 0);
  871|      1|		sc_file_free(file);
  872|      1|		LOG_TEST_RET(ctx, rv, "Update binary 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  873|      1|	}
  874|       |
  875|      1|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  876|      1|}
pkcs15-authentic.c:authentic_emu_store_data:
  833|    121|{
  834|    121|	struct sc_context *ctx = p15card->card->ctx;
  835|    121|	int rv = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|    121|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  836|       |
  837|    121|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    121|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    121|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    121|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    121|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 121]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  838|       |
  839|    121|	switch (object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    121|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (839:10): [True: 0, False: 121]
  ------------------
  840|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (840:2): [True: 0, False: 121]
  ------------------
  841|      0|		rv = authentic_store_pubkey(p15card, profile, object, data, path);
  842|      0|		break;
  843|    121|	}
  844|       |
  845|    121|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    121|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    121|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    121|	int _ret = r; \
  |  |  |  |  155|    121|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 121, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    121|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    121|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 121, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    121|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    121|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    121|	return _ret; \
  |  |  |  |  163|    121|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  846|    121|}

sc_pkcs15init_get_cardos_ops:
  941|    237|{
  942|    237|	return &sc_pkcs15init_cardos_operations;
  943|    237|}
pkcs15-cardos.c:cardos_erase:
  126|    143|{
  127|    143|	return sc_pkcs15init_erase_card_recursively(p15card, profile);
  128|    143|}
pkcs15-cardos.c:cardos_create_dir:
  135|     60|{
  136|     60|	int	r;
  137|       |
  138|       |	/* Create the application DF */
  139|     60|	if ((r = sc_pkcs15init_create_file(profile, p15card, df)) < 0)
  ------------------
  |  Branch (139:6): [True: 44, False: 16]
  ------------------
  140|     44|		return r;
  141|       |
  142|     16|	if ((r = sc_select_file(p15card->card, &df->path, NULL)) < 0)
  ------------------
  |  Branch (142:6): [True: 1, False: 15]
  ------------------
  143|      1|		return r;
  144|       |
  145|       |	/* Create a default security environment for this DF.
  146|       |	 * This SE automatically becomes the current SE when the
  147|       |	 * DF is selected. */
  148|     15|	if ((r = cardos_create_sec_env(profile, p15card->card, 0x01, 0x00)) < 0)
  ------------------
  |  Branch (148:6): [True: 5, False: 10]
  ------------------
  149|      5|		return r;
  150|       |
  151|     10|	return 0;
  152|     15|}
pkcs15-cardos.c:cardos_create_sec_env:
  577|     15|{
  578|     15|	struct sc_cardctl_cardos_obj_info args;
  579|     15|	struct tlv	tlv;
  580|     15|	unsigned char	buffer[64];
  581|     15|	int		r;
  582|       |
  583|     15|	tlv_init(&tlv, buffer, sizeof(buffer));
  584|     15|	if (tlv_next(&tlv, 0x83) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (584:6): [True: 0, False: 15]
  ------------------
  585|     15|	    || tlv_add(&tlv, se_id) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (585:9): [True: 0, False: 15]
  ------------------
  586|     15|	    || tlv_next(&tlv, 0x86) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (586:9): [True: 0, False: 15]
  ------------------
  587|     15|	    || tlv_add(&tlv, 0) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (587:9): [True: 0, False: 15]
  ------------------
  588|     15|	    || tlv_add(&tlv, 0) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (588:9): [True: 0, False: 15]
  ------------------
  589|     15|	    || tlv_next(&tlv, 0x8f) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (589:9): [True: 0, False: 15]
  ------------------
  590|     15|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (590:9): [True: 0, False: 15]
  ------------------
  591|     15|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (591:9): [True: 0, False: 15]
  ------------------
  592|     15|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (592:9): [True: 0, False: 15]
  ------------------
  593|     15|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (593:9): [True: 0, False: 15]
  ------------------
  594|     15|	    || tlv_add(&tlv, key_id) != SC_SUCCESS
  ------------------
  |  |   28|     30|#define SC_SUCCESS				0
  ------------------
  |  Branch (594:9): [True: 0, False: 15]
  ------------------
  595|     15|	    || tlv_add(&tlv, key_id) != SC_SUCCESS)
  ------------------
  |  |   28|     15|#define SC_SUCCESS				0
  ------------------
  |  Branch (595:9): [True: 0, False: 15]
  ------------------
  596|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  597|       |
  598|     15|	args.data = buffer;
  599|     15|	args.len = tlv_len(&tlv);
  600|       |
  601|       |	/* ensure we are in the correct lifecycle */
  602|     15|	r = sc_pkcs15init_set_lifecycle(card, SC_CARDCTRL_LIFECYCLE_ADMIN);
  603|     15|	if (r < 0 && r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|      3|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (603:6): [True: 3, False: 12]
  |  Branch (603:15): [True: 2, False: 1]
  ------------------
  604|      2|		return r;
  605|       |
  606|     13|	return sc_card_ctl(card, SC_CARDCTL_CARDOS_PUT_DATA_SECI, &args);
  607|     15|}
pkcs15-cardos.c:tlv_init:
   88|     78|{
   89|     78|	tlv->base = base;
   90|     78|	tlv->end = base + size;
   91|     78|	tlv->current = tlv->next = base;
   92|     78|}
pkcs15-cardos.c:tlv_next:
   95|    297|{
   96|    297|	if (tlv->next + 2 >= tlv->end)
  ------------------
  |  Branch (96:6): [True: 0, False: 297]
  ------------------
   97|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
   98|    297|	tlv->current = tlv->next;
   99|    297|	*(tlv->next++) = tag;
  100|    297|	*(tlv->next++) = 0;
  101|    297|	return SC_SUCCESS;
  ------------------
  |  |   28|    297|#define SC_SUCCESS				0
  ------------------
  102|    297|}
pkcs15-cardos.c:tlv_add:
  105|  1.68k|{
  106|  1.68k|	if (tlv->next + 1 >= tlv->end)
  ------------------
  |  Branch (106:6): [True: 1, False: 1.68k]
  ------------------
  107|      1|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      1|#define SC_ERROR_INTERNAL			-1400
  ------------------
  108|  1.68k|	*(tlv->next++) = val;
  109|  1.68k|	tlv->current[1]++;
  110|  1.68k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.68k|#define SC_SUCCESS				0
  ------------------
  111|  1.68k|}
pkcs15-cardos.c:tlv_len:
  115|     77|{
  116|     77|	return tlv->next - tlv->base;
  117|     77|}
pkcs15-cardos.c:cardos_select_pin_reference:
  161|    209|{
  162|    209|	int	preferred, current;
  163|       |
  164|    209|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    209|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (164:6): [True: 0, False: 209]
  ------------------
  165|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  166|       |
  167|    209|	if ((current = auth_info->attrs.pin.reference) < 0)
  ------------------
  |  Branch (167:6): [True: 206, False: 3]
  ------------------
  168|    206|		current = CARDOS_PIN_ID_MIN;
  ------------------
  |  |   71|    206|#define CARDOS_PIN_ID_MIN	1
  ------------------
  169|       |
  170|    209|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|    209|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (170:6): [True: 11, False: 198]
  ------------------
  171|     11|		preferred = 1;
  172|     11|		if (current > preferred)
  ------------------
  |  Branch (172:7): [True: 0, False: 11]
  ------------------
  173|      0|			return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  174|    198|	} else {
  175|    198|		preferred = current;
  176|       |		/* PINs are even numbered, PUKs are odd */
  177|    198|		if (!(preferred & 1))
  ------------------
  |  Branch (177:7): [True: 2, False: 196]
  ------------------
  178|      2|			preferred++;
  179|    198|	}
  180|       |
  181|    209|	if (preferred > CARDOS_PIN_ID_MAX)
  ------------------
  |  |   72|    209|#define CARDOS_PIN_ID_MAX	15
  ------------------
  |  Branch (181:6): [True: 3, False: 206]
  ------------------
  182|      3|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      3|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  183|    206|	auth_info->attrs.pin.reference = preferred;
  184|       |
  185|    206|	return SC_SUCCESS;
  ------------------
  |  |   28|    206|#define SC_SUCCESS				0
  ------------------
  186|    209|}
pkcs15-cardos.c:cardos_create_pin:
  196|    153|{
  197|    153|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  198|    153|	struct sc_card *card = p15card->card;
  199|    153|	unsigned int	puk_id = CARDOS_AC_NEVER;
  ------------------
  |  |   75|    153|#define CARDOS_AC_NEVER		0xFF
  ------------------
  200|    153|	int		r;
  201|       |
  202|    153|	if (!pin || !pin_len)
  ------------------
  |  Branch (202:6): [True: 0, False: 153]
  |  Branch (202:14): [True: 0, False: 153]
  ------------------
  203|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  204|       |
  205|    153|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    153|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (205:6): [True: 0, False: 153]
  ------------------
  206|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  207|       |
  208|    153|	r = sc_select_file(card, auth_info->attrs.pin.reference & 0x80 ? &df->path : sc_get_mf_path(), NULL);
  ------------------
  |  Branch (208:27): [True: 0, False: 153]
  ------------------
  209|    153|	if (r < 0)
  ------------------
  |  Branch (209:6): [True: 95, False: 58]
  ------------------
  210|     95|		return r;
  211|       |
  212|     58|	if (puk && puk_len) {
  ------------------
  |  Branch (212:6): [True: 56, False: 2]
  |  Branch (212:13): [True: 56, False: 0]
  ------------------
  213|     56|		struct sc_pkcs15_auth_info puk_ainfo = {0};
  214|       |
  215|     56|		sc_profile_get_pin_info(profile,
  216|     56|				SC_PKCS15INIT_USER_PUK, &puk_ainfo);
  ------------------
  |  |  172|     56|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  217|     56|		puk_ainfo.attrs.pin.reference = puk_id = auth_info->attrs.pin.reference + 1;
  218|     56|		r = cardos_store_pin(profile, card,
  219|     56|				&puk_ainfo, CARDOS_AC_NEVER,
  ------------------
  |  |   75|     56|#define CARDOS_AC_NEVER		0xFF
  ------------------
  220|     56|				puk, puk_len);
  221|     56|	}
  222|       |
  223|     58|	if (r >= 0) {
  ------------------
  |  Branch (223:6): [True: 7, False: 51]
  ------------------
  224|      7|		r = cardos_store_pin(profile, card,
  225|      7|				auth_info, puk_id, pin, pin_len);
  226|      7|	}
  227|       |
  228|     58|	return r;
  229|    153|}
pkcs15-cardos.c:cardos_store_pin:
  472|     63|{
  473|     63|	struct sc_cardctl_cardos_obj_info args;
  474|     63|	unsigned char	buffer[256];
  475|     63|	unsigned char	pinpadded[256];
  476|     63|	struct tlv	tlv;
  477|     63|	unsigned int	attempts, maxlen;
  478|     63|	u8 minlen;
  479|     63|	int		r, hasverifyrc;
  480|       |
  481|     63|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     63|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (481:6): [True: 0, False: 63]
  ------------------
  482|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  483|       |
  484|       |	/* We need to do padding because pkcs15-lib.c does it.
  485|       |	 * Would be nice to have a flag in the profile that says
  486|       |	 * "no padding required". */
  487|     63|	maxlen = MIN(profile->pin_maxlen, sizeof(pinpadded));
  ------------------
  |  |   39|     63|# define MIN(a, b)	(((a) < (b))? (a) : (b))
  |  |  ------------------
  |  |  |  Branch (39:21): [True: 62, False: 1]
  |  |  ------------------
  ------------------
  488|     63|	if (pin_len > maxlen) {
  ------------------
  |  Branch (488:6): [True: 0, False: 63]
  ------------------
  489|      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__
  |  |  ------------------
  ------------------
  490|      0|			 "invalid pin length: %"SC_FORMAT_LEN_SIZE_T"u (max %u)\n",
  491|      0|			 pin_len, maxlen);
  492|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  493|      0|	}
  494|     63|	memcpy(pinpadded, pin, pin_len);
  495|    313|	while (pin_len < maxlen)
  ------------------
  |  Branch (495:9): [True: 250, False: 63]
  ------------------
  496|    250|		pinpadded[pin_len++] = profile->pin_pad_char;
  497|     63|	pin = pinpadded;
  498|       |
  499|     63|	attempts = auth_info->tries_left;
  500|     63|	minlen = (u8)auth_info->attrs.pin.min_length;
  501|       |
  502|     63|	tlv_init(&tlv, buffer, sizeof(buffer));
  503|       |
  504|       |	/* object address: class, id */
  505|     63|	if (tlv_next(&tlv, 0x83) != SC_SUCCESS
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  |  Branch (505:6): [True: 0, False: 63]
  ------------------
  506|     63|	    || tlv_add(&tlv, 0x00) != SC_SUCCESS /* class byte: usage TEST, k=0 */
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  |  Branch (506:9): [True: 0, False: 63]
  ------------------
  507|     63|	    || tlv_add(&tlv, auth_info->attrs.pin.reference & 0x7f) != SC_SUCCESS)
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  |  Branch (507:9): [True: 0, False: 63]
  ------------------
  508|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  509|       |
  510|       |	/* parameters */
  511|     63|	if (tlv_next(&tlv, 0x85)
  ------------------
  |  Branch (511:6): [True: 0, False: 63]
  ------------------
  512|     63|	    || tlv_add(&tlv, 0x02) /* options byte */)
  ------------------
  |  Branch (512:9): [True: 0, False: 63]
  ------------------
  513|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  514|       |
  515|     63|	hasverifyrc = cardos_have_verifyrc_package(card);
  516|     63|	if (hasverifyrc == 1)
  ------------------
  |  Branch (516:6): [True: 0, False: 63]
  ------------------
  517|       |		/* Use 9 byte OCI parameters to be able to set VerifyRC bit	*/
  518|      0|		if (tlv_add(&tlv, 0x04) != SC_SUCCESS /* options_2 byte with bit 2 set to return CurrentErrorCounter */)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (518:7): [True: 0, False: 0]
  ------------------
  519|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  520|       |
  521|     63|	if (tlv_add(&tlv, attempts & 0xf) != SC_SUCCESS /* flags byte */
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  |  Branch (521:6): [True: 0, False: 63]
  ------------------
  522|     63|	    || tlv_add(&tlv, CARDOS_ALGO_PIN) != SC_SUCCESS /* algorithm = pin-test */
  ------------------
  |  |   85|     63|#define CARDOS_ALGO_PIN			0x87
  ------------------
              	    || tlv_add(&tlv, CARDOS_ALGO_PIN) != SC_SUCCESS /* algorithm = pin-test */
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  |  Branch (522:9): [True: 0, False: 63]
  ------------------
  523|     63|	    || tlv_add(&tlv, attempts & 0xf) != SC_SUCCESS /* errcount = attempts */)
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  |  Branch (523:9): [True: 0, False: 63]
  ------------------
  524|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  525|       |
  526|       |	/* usecount: not documented, but seems to work like this:
  527|       |	 *  -	value of 0xff means pin can be presented any number
  528|       |	 *	of times
  529|       |	 *  -	anything less: max # of times before BS object is blocked.
  530|       |	 */
  531|     63|	if (tlv_add(&tlv, 0xff) != SC_SUCCESS)
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  |  Branch (531:6): [True: 0, False: 63]
  ------------------
  532|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  533|       |
  534|       |	/* DEK: not documented, no idea what it means */
  535|     63|	if (tlv_add(&tlv, 0xff) != SC_SUCCESS)
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  |  Branch (535:6): [True: 0, False: 63]
  ------------------
  536|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  537|       |
  538|       |	/* ARA counter: number of times the test object can be used before
  539|       |	 *              another verification is required (~ user consent)
  540|       |	 *              (0x00 unlimited usage)
  541|       |	 */
  542|     63|	if (tlv_add(&tlv, 0x00) != SC_SUCCESS
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  |  Branch (542:6): [True: 0, False: 63]
  ------------------
  543|     63|	    || tlv_add(&tlv, minlen) != SC_SUCCESS /* minlen */)
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  |  Branch (543:9): [True: 0, False: 63]
  ------------------
  544|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  545|       |
  546|       |	/* AC conditions */
  547|     63|	if (tlv_next(&tlv, 0x86) != SC_SUCCESS
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  |  Branch (547:6): [True: 0, False: 63]
  ------------------
  548|     63|	    || tlv_add(&tlv, 0x00) != SC_SUCCESS /* use: always */
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  |  Branch (548:9): [True: 0, False: 63]
  ------------------
  549|     63|	    || tlv_add(&tlv, auth_info->attrs.pin.reference) != SC_SUCCESS /* change: PIN */
  ------------------
  |  |   28|    126|#define SC_SUCCESS				0
  ------------------
  |  Branch (549:9): [True: 0, False: 63]
  ------------------
  550|     63|	    || tlv_add(&tlv, puk_id) != SC_SUCCESS /* unblock: PUK */)
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  |  Branch (550:9): [True: 0, False: 63]
  ------------------
  551|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  552|       |
  553|       |	/* data: PIN */
  554|     63|	if (tlv_next(&tlv, 0x8f) != SC_SUCCESS)
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  |  Branch (554:6): [True: 0, False: 63]
  ------------------
  555|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  556|    793|	while (pin_len--)
  ------------------
  |  Branch (556:9): [True: 731, False: 62]
  ------------------
  557|    731|		if (tlv_add(&tlv, *pin++) != SC_SUCCESS)
  ------------------
  |  |   28|    731|#define SC_SUCCESS				0
  ------------------
  |  Branch (557:7): [True: 1, False: 730]
  ------------------
  558|      1|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|     64|#define SC_ERROR_INTERNAL			-1400
  ------------------
  559|       |
  560|     62|	args.data = buffer;
  561|     62|	args.len = tlv_len(&tlv);
  562|       |
  563|       |	/* ensure we are in the correct lifecycle */
  564|     62|	r = sc_pkcs15init_set_lifecycle(card, SC_CARDCTRL_LIFECYCLE_ADMIN);
  565|     62|	if (r < 0 && r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|     53|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (565:6): [True: 53, False: 9]
  |  Branch (565:15): [True: 53, False: 0]
  ------------------
  566|     53|		return r;
  567|       |
  568|      9|	return sc_card_ctl(card, SC_CARDCTL_CARDOS_PUT_DATA_OCI, &args);
  569|     62|}
pkcs15-cardos.c:cardos_have_verifyrc_package:
  872|     63|{
  873|     63|	sc_apdu_t apdu;
  874|     63|        u8        rbuf[SC_MAX_APDU_BUFFER_SIZE];
  875|     63|        int       r;
  876|     63|	const u8  *p = rbuf, *q, *pp;
  877|     63|	size_t    len, tlen = 0, ilen = 0;
  878|       |
  879|     63|	sc_format_apdu(card, &apdu, SC_APDU_CASE_2_SHORT, 0xca, 0x01, 0x88);
  ------------------
  |  |  292|     63|#define SC_APDU_CASE_2_SHORT		0x02
  ------------------
  880|     63|	apdu.resp    = rbuf;
  881|     63|	apdu.resplen = sizeof(rbuf);
  882|     63|	apdu.lc = 0;
  883|     63|	apdu.le = 256;
  884|     63|	r = sc_transmit_apdu(card, &apdu);
  885|     63|	LOG_TEST_RET(card->ctx, r, "APDU transmit failed");
  ------------------
  |  |  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: 1, False: 62]
  |  |  |  |  ------------------
  |  |  |  |  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|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 62]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  886|       |
  887|     62|	if ((len = apdu.resplen) == 0)
  ------------------
  |  Branch (887:6): [True: 30, False: 32]
  ------------------
  888|       |		/* looks like no package has been installed  */
  889|     30|		return 0;
  890|       |
  891|     32|	while (len != 0) {
  ------------------
  |  Branch (891:9): [True: 32, False: 0]
  ------------------
  892|     32|		pp = sc_asn1_find_tag(card->ctx, p, len, 0xe1, &tlen);
  893|     32|		if (pp == NULL)
  ------------------
  |  Branch (893:7): [True: 32, False: 0]
  ------------------
  894|     32|			return 0;
  895|      0|		if (card->type == SC_CARD_TYPE_CARDOS_M4_3)	{
  ------------------
  |  Branch (895:7): [True: 0, False: 0]
  ------------------
  896|       |			/* the verifyRC package on CardOS 4.3B use Manufacturer ID 0x01	*/
  897|       |			/* and Package Number 0x07					*/
  898|      0|			q = sc_asn1_find_tag(card->ctx, pp, tlen, 0x01, &ilen);
  899|      0|			if (q == NULL || ilen != 4)
  ------------------
  |  Branch (899:8): [True: 0, False: 0]
  |  Branch (899:21): [True: 0, False: 0]
  ------------------
  900|      0|				return 0;
  901|      0|			if (q[0] == 0x07)
  ------------------
  |  Branch (901:8): [True: 0, False: 0]
  ------------------
  902|      0|				return 1;
  903|      0|		} else if (card->type == SC_CARD_TYPE_CARDOS_M4_4)	{
  ------------------
  |  Branch (903:14): [True: 0, False: 0]
  ------------------
  904|       |			/* the verifyRC package on CardOS 4.4 use Manufacturer ID 0x03	*/
  905|       |			/* and Package Number 0x02					*/
  906|      0|			q = sc_asn1_find_tag(card->ctx, pp, tlen, 0x03, &ilen);
  907|      0|			if (q == NULL || ilen != 4)
  ------------------
  |  Branch (907:8): [True: 0, False: 0]
  |  Branch (907:21): [True: 0, False: 0]
  ------------------
  908|      0|				return 0;
  909|      0|			if (q[0] == 0x02)
  ------------------
  |  Branch (909:8): [True: 0, False: 0]
  ------------------
  910|      0|				return 1;
  911|      0|		} else	{
  912|      0|			return 0;
  913|      0|		}
  914|      0|		p   += tlen;
  915|      0|		len -= tlen + 2;
  916|      0|	}
  917|       |
  918|      0|	return 0;
  919|     32|}
pkcs15-cardos.c:cardos_select_key_reference:
  237|    103|{
  238|    103|	if (key_info->key_reference < CARDOS_KEY_ID_MIN)
  ------------------
  |  |   73|    103|#define CARDOS_KEY_ID_MIN	16
  ------------------
  |  Branch (238:6): [True: 103, False: 0]
  ------------------
  239|    103|		key_info->key_reference = CARDOS_KEY_ID_MIN;
  ------------------
  |  |   73|    103|#define CARDOS_KEY_ID_MIN	16
  ------------------
  240|    103|	if (key_info->key_reference > CARDOS_KEY_ID_MAX)
  ------------------
  |  |   74|    103|#define CARDOS_KEY_ID_MAX	31
  ------------------
  |  Branch (240:6): [True: 0, False: 103]
  ------------------
  241|      0|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  242|    103|	return 0;
  243|    103|}
pkcs15-cardos.c:cardos_create_key:
  252|    103|{
  253|    103|	return 0;
  254|    103|}
pkcs15-cardos.c:cardos_key_algorithm:
  620|    103|{
  621|       |	/* if it is sign and decipher, we use decipher and emulate sign */
  622|    103|	if (usage & USAGE_ANY_DECIPHER) {
  ------------------
  |  |  616|    103|#define USAGE_ANY_DECIPHER	(SC_PKCS15_PRKEY_USAGE_DECRYPT|\
  |  |  ------------------
  |  |  |  |  306|    103|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  |  |  ------------------
  |  |  617|    103|				 SC_PKCS15_PRKEY_USAGE_UNWRAP)
  |  |  ------------------
  |  |  |  |  310|    103|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  |  |  ------------------
  ------------------
  |  Branch (622:6): [True: 0, False: 103]
  ------------------
  623|      0|		if (keylen <= 1024)
  ------------------
  |  Branch (623:7): [True: 0, False: 0]
  ------------------
  624|      0|			*algop = CARDOS_ALGO_RSA_PURE;
  ------------------
  |  |   78|      0|#define CARDOS_ALGO_RSA_PURE		0x0C
  ------------------
  625|      0|		else
  626|      0|			*algop = CARDOS_ALGO_EXT_RSA_PURE;
  ------------------
  |  |   83|      0|#define CARDOS_ALGO_EXT_RSA_PURE	0x0a
  ------------------
  627|      0|		return 0;
  628|      0|	}
  629|    103|	if (usage & USAGE_ANY_SIGN) {
  ------------------
  |  |  614|    103|#define USAGE_ANY_SIGN		(SC_PKCS15_PRKEY_USAGE_SIGN|\
  |  |  ------------------
  |  |  |  |  307|    103|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  |  |  ------------------
  |  |  615|    103|				 SC_PKCS15_PRKEY_USAGE_NONREPUDIATION)
  |  |  ------------------
  |  |  |  |  314|    103|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  |  |  ------------------
  ------------------
  |  Branch (629:6): [True: 103, False: 0]
  ------------------
  630|    103|		if (keylen <= 1024)
  ------------------
  |  Branch (630:7): [True: 103, False: 0]
  ------------------
  631|    103|			*algop = CARDOS_ALGO_RSA_PURE_SIG;
  ------------------
  |  |   80|    103|#define CARDOS_ALGO_RSA_PURE_SIG	0x8C
  ------------------
  632|      0|		else
  633|      0|			*algop = CARDOS_ALGO_EXT_RSA_SIG_PURE;
  ------------------
  |  |   84|      0|#define CARDOS_ALGO_EXT_RSA_SIG_PURE	0x8a
  ------------------
  634|    103|		return 0;
  635|    103|	}
  636|      0|	return -1;
  637|    103|}
pkcs15-cardos.c:cardos_generate_key:
  327|    103|{
  328|    103|	struct sc_context *ctx = p15card->card->ctx;
  329|    103|	struct sc_pkcs15_prkey_info *key_info = (sc_pkcs15_prkey_info_t *) obj->data;
  330|    103|	struct sc_pkcs15_prkey_rsa key_obj;
  331|    103|	struct sc_cardctl_cardos_genkey_info args;
  332|    103|	struct sc_file	*temp;
  333|    103|	u8		abignum[256];
  334|    103|	int		algorithm = 0, r, delete_it = 0, use_ext_rsa = 0;
  335|    103|	size_t		keybits, rsa_max_size;
  336|    103|	int             pin_id = -1;
  337|       |
  338|    103|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|    103|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (338:6): [True: 0, False: 103]
  ------------------
  339|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  340|       |
  341|    103|	rsa_max_size = (sc_card_find_rsa_alg(p15card->card, 2048) != NULL) ? 2048 : 1024;
  ------------------
  |  Branch (341:17): [True: 36, False: 67]
  ------------------
  342|    103|	keybits = key_info->modulus_length & ~7UL;
  343|    103|	if (keybits > rsa_max_size) {
  ------------------
  |  Branch (343:6): [True: 0, False: 103]
  ------------------
  344|      0|		sc_log(ctx,  "Unable to generate key, max size is %lu",
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  345|      0|			(unsigned long) rsa_max_size);
  346|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  347|      0|	}
  348|       |
  349|    103|	if (keybits > 1024)
  ------------------
  |  Branch (349:6): [True: 0, False: 103]
  ------------------
  350|      0|		use_ext_rsa = 1;
  351|       |
  352|    103|	if (cardos_key_algorithm(key_info->usage, keybits, &algorithm) < 0) {
  ------------------
  |  Branch (352:6): [True: 0, False: 103]
  ------------------
  353|      0|		sc_log(ctx,  "CardOS does not support 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__
  |  |  ------------------
  ------------------
  354|      0|			       "that can both sign _and_ decrypt.");
  355|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  356|      0|	}
  357|       |
  358|    103|	if (sc_profile_get_file(profile, "tempfile", &temp) < 0) {
  ------------------
  |  Branch (358:6): [True: 103, False: 0]
  ------------------
  359|    103|		sc_log(ctx,  "Profile doesn't define temporary file "
  ------------------
  |  |   71|    103|#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|    103|				"for key generation.");
  361|    103|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    103|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  362|    103|	}
  363|       |
  364|      0|	pin_id = sc_pkcs15init_get_pin_reference(p15card, profile,
  365|      0|			SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
  ------------------
  |  |  155|      0|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
              			SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
  ------------------
  |  |  171|      0|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  366|      0|	if (pin_id >= 0) {
  ------------------
  |  Branch (366:6): [True: 0, False: 0]
  ------------------
  367|      0|		r = sc_pkcs15init_verify_secret(profile, p15card, NULL, SC_AC_CHV, pin_id);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  368|      0|		if (r < 0)
  ------------------
  |  Branch (368:7): [True: 0, False: 0]
  ------------------
  369|      0|			return r;
  370|      0|	}
  371|      0|	if (use_ext_rsa == 0)
  ------------------
  |  Branch (371:6): [True: 0, False: 0]
  ------------------
  372|      0|		temp->ef_structure = SC_FILE_EF_LINEAR_VARIABLE_TLV;
  ------------------
  |  |  225|      0|#define SC_FILE_EF_LINEAR_VARIABLE_TLV	0x05
  ------------------
  373|      0|	else
  374|      0|		temp->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      0|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  375|       |
  376|      0|	if ((r = sc_pkcs15init_create_file(profile, p15card, temp)) < 0)
  ------------------
  |  Branch (376:6): [True: 0, False: 0]
  ------------------
  377|      0|		goto out;
  378|      0|	delete_it = 1;
  379|       |
  380|      0|	init_key_object(&key_obj, abignum, keybits >> 3);
  381|       |
  382|      0|	r = cardos_put_key(profile, p15card, algorithm, key_info, &key_obj);
  383|      0|	if (r < 0)
  ------------------
  |  Branch (383:6): [True: 0, False: 0]
  ------------------
  384|      0|		goto out;
  385|       |
  386|      0|	memset(&args, 0, sizeof(args));
  387|      0|	args.key_id = key_info->key_reference;
  388|      0|	args.key_bits = keybits;
  389|      0|	args.fid = temp->id;
  390|      0|	r = sc_card_ctl(p15card->card, SC_CARDCTL_CARDOS_GENERATE_KEY, &args);
  391|      0|	if (r < 0)
  ------------------
  |  Branch (391:6): [True: 0, False: 0]
  ------------------
  392|      0|		goto out;
  393|       |
  394|      0|	r = cardos_extract_pubkey(p15card->card, pubkey, temp, use_ext_rsa);
  395|      0|out:
  396|      0|	if (delete_it != 0)
  ------------------
  |  Branch (396:6): [True: 0, False: 0]
  ------------------
  397|      0|		sc_pkcs15init_rmdir(p15card, profile, temp);
  398|      0|	sc_file_free(temp);
  399|       |
  400|      0|	if (r < 0) {
  ------------------
  |  Branch (400:6): [True: 0, False: 0]
  ------------------
  401|      0|		if (pubkey->u.rsa.modulus.data)
  ------------------
  |  Branch (401:7): [True: 0, False: 0]
  ------------------
  402|      0|			free (pubkey->u.rsa.modulus.data);
  403|      0|		if (pubkey->u.rsa.exponent.data)
  ------------------
  |  Branch (403:7): [True: 0, False: 0]
  ------------------
  404|      0|			free (pubkey->u.rsa.exponent.data);
  405|      0|	}
  406|      0|	return r;
  407|      0|}

sc_pkcs15init_get_cryptoflex_ops:
  955|     28|{
  956|     28|	return &sc_pkcs15init_cryptoflex_operations;
  957|     28|}
sc_pkcs15init_get_cyberflex_ops:
  961|     16|{
  962|     16|	return &sc_pkcs15init_cyberflex_operations;
  963|     16|}
pkcs15-cflex.c:cflex_erase_card:
   87|     29|{
   88|     29|	struct sc_context *ctx = p15card->card->ctx;
   89|     29|	sc_file_t  *df = profile->df_info->file, *dir, *userpinfile = NULL;
   90|     29|	int             r;
   91|       |
   92|     29|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     29|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   93|       |	/* Delete EF(DIR). This may not be very nice
   94|       |         * against other applications that use this file, but
   95|       |         * extremely useful for testing :)
   96|       |         * Note we need to delete if before the DF because we create
   97|       |         * it *after* the DF.
   98|       |         * */
   99|     29|        if (sc_profile_get_file(profile, "DIR", &dir) >= 0) {
  ------------------
  |  Branch (99:13): [True: 9, False: 20]
  ------------------
  100|      9|                r = cflex_delete_file(profile, p15card, dir);
  101|      9|                sc_file_free(dir);
  102|      9|                if (r < 0 && r != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      6|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (102:21): [True: 6, False: 3]
  |  Branch (102:30): [True: 5, False: 1]
  ------------------
  103|      5|                        goto out;
  104|      9|        }
  105|       |
  106|     24|	r=cflex_delete_file(profile, p15card, df);
  107|       |
  108|       |	/* If the user pin file isn't in a sub-DF of the pkcs15 DF, delete it */
  109|     24|	if (sc_profile_get_file(profile, "pinfile-1", &userpinfile) >= 0 &&
  ------------------
  |  Branch (109:6): [True: 0, False: 24]
  ------------------
  110|      0|	    userpinfile->path.len <= profile->df_info->file->path.len + 2 &&
  ------------------
  |  Branch (110:6): [True: 0, False: 0]
  ------------------
  111|      0|	    memcmp(userpinfile->path.value, profile->df_info->file->path.value,
  ------------------
  |  Branch (111:6): [True: 0, False: 0]
  ------------------
  112|      0|	           userpinfile->path.len) != 0) {
  113|      0|           	r = cflex_delete_file(profile, p15card, userpinfile);
  114|      0|		sc_file_free(userpinfile);
  115|      0|		userpinfile=NULL;
  116|      0|	}
  117|       |
  118|       |
  119|     29|out:	/* Forget all cached keys, the pin files on card are all gone. */
  120|     29|	sc_file_free(userpinfile);
  121|       |
  122|     29|        sc_free_apps(p15card->card);
  123|     29|        if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|     29|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (123:13): [True: 0, False: 29]
  ------------------
  124|      0|                r=0;
  125|       |
  126|     29|	SC_FUNC_RETURN(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|     27|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 27, False: 2]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  127|     29|}
pkcs15-cflex.c:cflex_delete_file:
   53|     33|{
   54|     33|        sc_path_t  path;
   55|     33|        sc_file_t  *parent;
   56|     33|        int             r = 0;
   57|       |        /* Select the parent DF */
   58|     33|        path = df->path;
   59|     33|		if (path.len < 2) {
  ------------------
  |  Branch (59:7): [True: 4, False: 29]
  ------------------
   60|      4|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      4|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   61|      4|		}
   62|     29|        path.len -= 2;
   63|     29|        r = sc_select_file(p15card->card, &path, &parent);
   64|     29|        if (r < 0)
  ------------------
  |  Branch (64:13): [True: 23, False: 6]
  ------------------
   65|     23|                return r;
   66|       |
   67|      6|        r = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      6|#define SC_AC_OP_DELETE			2
  ------------------
   68|      6|        sc_file_free(parent);
   69|      6|        if (r < 0)
  ------------------
  |  Branch (69:13): [True: 0, False: 6]
  ------------------
   70|      0|                return r;
   71|       |
   72|       |	/* cryptoflex has no ERASE AC */
   73|      6|        memset(&path, 0, sizeof(path));
   74|      6|        path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      6|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
   75|      6|        path.value[0] = df->id >> 8;
   76|      6|        path.value[1] = df->id & 0xFF;
   77|      6|        path.len = 2;
   78|       |
   79|      6|	r = sc_delete_file(p15card->card, &path);
   80|      6|	return r;
   81|      6|}
pkcs15-cflex.c:cryptoflex_init_card:
  135|     12|{
  136|     12|	sc_path_t	path;
  137|     12|	sc_file_t	*file;
  138|     12|	u8		buf[32];
  139|     12|	char		serial[128];
  140|     12|	size_t		len;
  141|     12|	int		r;
  142|       |
  143|     12|	sc_format_path("3F000002", &path);
  144|     12|	if ((r = sc_select_file(p15card->card, &path, &file)) < 0) {
  ------------------
  |  Branch (144:6): [True: 3, False: 9]
  ------------------
  145|      3|		if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      3|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (145:7): [True: 0, False: 3]
  ------------------
  146|      0|			return 0;
  147|      3|		return r;
  148|      3|	}
  149|       |
  150|      9|	if ((len = file->size) > sizeof(buf))
  ------------------
  |  Branch (150:6): [True: 0, False: 9]
  ------------------
  151|      0|		len = sizeof(buf);
  152|      9|	sc_file_free(file);
  153|      9|	if ((r = sc_read_binary(p15card->card, 0, buf, len, 0)) < 0)
  ------------------
  |  Branch (153:6): [True: 0, False: 9]
  ------------------
  154|      0|		return r;
  155|      9|	len = r;
  156|      9|	if (len == 0)
  ------------------
  |  Branch (156:6): [True: 9, False: 0]
  ------------------
  157|      9|		return 0;
  158|       |
  159|      0|	if ((r = sc_bin_to_hex(buf, len, serial, sizeof(serial), '\0')) < 0)
  ------------------
  |  Branch (159:6): [True: 0, False: 0]
  ------------------
  160|      0|		return r;
  161|      0|	sc_pkcs15init_set_serial(profile, serial);
  162|      0|	return 0;
  163|      0|}
pkcs15-cflex.c:cflex_create_dir:
  170|      9|{
  171|       |	/* Create the application DF */
  172|      9|	return sc_pkcs15init_create_file(profile, p15card, df);
  173|      9|}
pkcs15-cflex.c:cflex_select_pin_reference:
  191|     46|{
  192|     46|	int	preferred;
  193|       |
  194|     46|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     46|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (194:6): [True: 0, False: 46]
  ------------------
  195|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  196|       |
  197|     46|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|     46|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (197:6): [True: 0, False: 46]
  ------------------
  198|      0|		preferred = 2;
  199|     46|	} else {
  200|     46|		preferred = 1;
  201|     46|	}
  202|     46|	if (auth_info->attrs.pin.reference <= preferred) {
  ------------------
  |  Branch (202:6): [True: 43, False: 3]
  ------------------
  203|     43|		auth_info->attrs.pin.reference = preferred;
  204|     43|		return 0;
  205|     43|	}
  206|       |
  207|      3|	if (auth_info->attrs.pin.reference > 2)
  ------------------
  |  Branch (207:6): [True: 3, False: 0]
  ------------------
  208|      3|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      3|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  209|       |
  210|       |	/* Caller, please select a different PIN reference */
  211|      0|	return SC_ERROR_INVALID_PIN_REFERENCE;
  ------------------
  |  |  111|      0|#define SC_ERROR_INVALID_PIN_REFERENCE		-1509
  ------------------
  212|      3|}
pkcs15-cflex.c:cflex_create_pin:
  223|     29|{
  224|     29|	struct sc_context *ctx = p15card->card->ctx;
  225|     29|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  226|     29|	struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
  227|     29|	sc_file_t	*dummies[2];
  228|     29|	int		ndummies, pin_type, puk_type, r;
  229|     29|	sc_file_t       *file = NULL;
  230|       |
  231|     29|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     29|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  232|       |
  233|     29|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     29|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (233:6): [True: 0, False: 29]
  ------------------
  234|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  235|       |
  236|       |	/* If the profile doesn't specify a reference for this PIN, guess */
  237|     29|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|     29|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (237:6): [True: 0, False: 29]
  ------------------
  238|      0|		pin_type = SC_PKCS15INIT_SO_PIN;
  ------------------
  |  |  169|      0|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  239|      0|		puk_type = SC_PKCS15INIT_SO_PUK;
  ------------------
  |  |  170|      0|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  240|      0|		if (pin_attrs->reference != 2)
  ------------------
  |  Branch (240:7): [True: 0, False: 0]
  ------------------
  241|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  242|     29|	} else {
  243|     29|		pin_type = SC_PKCS15INIT_USER_PIN;
  ------------------
  |  |  171|     29|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  244|     29|		puk_type = SC_PKCS15INIT_USER_PUK;
  ------------------
  |  |  172|     29|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  245|     29|		if (pin_attrs->reference != 1)
  ------------------
  |  Branch (245:7): [True: 0, False: 29]
  ------------------
  246|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  247|     29|	}
  248|       |
  249|       |	/* Get file definition from the profile */
  250|     29|	if (sc_profile_get_file(profile, (pin_attrs->reference == 1)? "CHV1" : "CHV2", &file) < 0
  ------------------
  |  Branch (250:6): [True: 29, False: 0]
  |  Branch (250:35): [True: 29, False: 0]
  ------------------
  251|     29|			&& sc_profile_get_file(profile, "CHV", &file) < 0)
  ------------------
  |  Branch (251:7): [True: 27, False: 2]
  ------------------
  252|     29|		LOG_TEST_RET(ctx, SC_ERROR_FILE_NOT_FOUND, "profile does not define pin file ACLs");
  ------------------
  |  |  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: 27, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  253|       |
  254|      2|	ndummies = cflex_create_dummy_chvs(profile, p15card, file, SC_AC_OP_CREATE, dummies);
  ------------------
  |  |  169|      2|#define SC_AC_OP_CREATE			3
  ------------------
  255|      2|	sc_file_free(file);
  256|      2|	LOG_TEST_RET(ctx, ndummies, "Unable to create dummy CHV file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  257|       |
  258|      2|	r = cflex_create_pin_file(profile, p15card, &df->path, pin_attrs->reference,
  259|      2|			pin, pin_len, sc_profile_get_pin_retries(profile, pin_type),
  260|      2|			puk, puk_len, sc_profile_get_pin_retries(profile, puk_type),
  261|      2|			NULL, 0);
  262|       |
  263|      2|	cflex_delete_dummy_chvs(profile, p15card, ndummies, dummies);
  264|      2|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  265|      2|}
pkcs15-cflex.c:cflex_create_dummy_chvs:
  440|      4|{
  441|      4|	struct sc_context *ctx = p15card->card->ctx;
  442|      4|	const sc_acl_entry_t *acl;
  443|      4|	int		r = 0, ndummies = 0;
  444|       |
  445|      4|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  446|       |	/* See if the DF is supposed to be PIN protected, and if
  447|       |	 * it is, whether that CHV file actually exists. If it doesn't,
  448|       |	 * create it.
  449|       |	 */
  450|      4|	acl = sc_file_get_acl_entry(file, op);
  451|      8|	for (; acl; acl = acl->next) {
  ------------------
  |  Branch (451:9): [True: 4, False: 4]
  ------------------
  452|      4|		sc_path_t	parent, ef;
  453|       |
  454|      4|		if (acl->method != SC_AC_CHV)
  ------------------
  |  |  151|      4|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (454:7): [True: 4, False: 0]
  ------------------
  455|      4|			continue;
  456|       |
  457|      0|		parent = file->path;
  458|      0|		parent.len -= 2;
  459|       |
  460|      0|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  461|      0|		while (parent.len >= 2 && r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (461:10): [True: 0, False: 0]
  |  Branch (461:29): [True: 0, False: 0]
  ------------------
  462|      0|			ef = parent;
  463|      0|			ef.value[ef.len++] = acl->key_ref - 1;
  464|      0|			ef.value[ef.len++] = 0;
  465|      0|			parent.len -= 2;
  466|       |
  467|      0|			if (ef.len == parent.len
  ------------------
  |  Branch (467:8): [True: 0, False: 0]
  ------------------
  468|      0|			 && !memcmp(ef.value, parent.value, ef.len))
  ------------------
  |  Branch (468:8): [True: 0, False: 0]
  ------------------
  469|      0|				continue;
  470|       |
  471|      0|			r = sc_select_file(p15card->card, &ef, NULL);
  472|      0|		}
  473|       |
  474|       |		/* If a valid EF(CHVx) was found, we're fine */
  475|      0|		if (r == 0)
  ------------------
  |  Branch (475:7): [True: 0, False: 0]
  ------------------
  476|      0|			continue;
  477|      0|		if (r != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (477:7): [True: 0, False: 0]
  ------------------
  478|      0|			break;
  479|       |
  480|       |		/* Create a CHV file in the MF */
  481|      0|		parent = file->path;
  482|      0|		parent.len = 2;
  483|      0|		r = cflex_create_empty_pin_file(profile, p15card, &parent,
  484|      0|				acl->key_ref, &dummies[ndummies]);
  485|      0|		if (r < 0)
  ------------------
  |  Branch (485:7): [True: 0, False: 0]
  ------------------
  486|      0|			break;
  487|      0|		ndummies++;
  488|      0|	}
  489|       |
  490|      4|	if (r < 0) {
  ------------------
  |  Branch (490:6): [True: 0, False: 4]
  ------------------
  491|      0|		cflex_delete_dummy_chvs(profile, p15card, ndummies, dummies);
  492|      0|		return r;
  493|      0|	}
  494|       |
  495|      4|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, ndummies);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  496|      4|}
pkcs15-cflex.c:cflex_create_pin_file:
  528|      2|{
  529|      2|	struct sc_context *ctx = p15card->card->ctx;
  530|      2|	struct sc_pkcs15_object *pin_obj = NULL;
  531|      2|	unsigned char	buffer[23];
  532|      2|	sc_path_t	path;
  533|      2|	sc_file_t	*dummies[2], *file;
  534|      2|	int		r, ndummies;
  535|       |
  536|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  537|      2|	if (file_ret)
  ------------------
  |  Branch (537:6): [True: 0, False: 2]
  ------------------
  538|      0|		*file_ret = NULL;
  539|       |
  540|       |	/* Build the CHV path */
  541|      2|	path = *df_path;
  542|      2|	if (path.len > SC_MAX_PATH_SIZE - 2) {
  ------------------
  |  |   47|      2|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (542:6): [True: 0, False: 2]
  ------------------
  543|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  544|      0|	}
  545|      2|	path.value[path.len++] = ref - 1;
  546|      2|	path.value[path.len++] = 0;
  547|       |
  548|       |	/* See if the CHV already exists */
  549|      2|	r = sc_select_file(p15card->card, &path, NULL);
  550|      2|	if (r >= 0)
  ------------------
  |  Branch (550:6): [True: 0, False: 2]
  ------------------
  551|      0|		return SC_ERROR_FILE_ALREADY_EXISTS;
  ------------------
  |  |   65|      0|#define SC_ERROR_FILE_ALREADY_EXISTS		-1215
  ------------------
  552|       |
  553|       |	/* Get the file definition from the profile */
  554|      2|	if (sc_profile_get_file_by_path(profile, &path, &file) < 0
  ------------------
  |  Branch (554:6): [True: 2, False: 0]
  ------------------
  555|      2|			&& sc_profile_get_file(profile, (ref == 1)? "CHV1" : "CHV2", &file) < 0
  ------------------
  |  Branch (555:7): [True: 2, False: 0]
  |  Branch (555:36): [True: 2, False: 0]
  ------------------
  556|      2|			&& sc_profile_get_file(profile, "CHV", &file) < 0)
  ------------------
  |  Branch (556:7): [True: 0, False: 2]
  ------------------
  557|      2|		LOG_TEST_RET(ctx, SC_ERROR_FILE_NOT_FOUND, "profile does not define pin file 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  558|       |
  559|      2|	file->path = path;
  560|      2|	file->size = 23;
  561|      2|	file->id = (ref == 1)? 0x0000 : 0x0100;
  ------------------
  |  Branch (561:13): [True: 2, False: 0]
  ------------------
  562|       |
  563|      2|	if (unprotected)   {
  ------------------
  |  Branch (563:6): [True: 0, False: 2]
  ------------------
  564|      0|		sc_file_add_acl_entry(file, SC_AC_OP_UPDATE,
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  565|      0|				SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
              				SC_AC_NONE, SC_AC_KEY_REF_NONE);
  ------------------
  |  |  204|      0|#define SC_AC_KEY_REF_NONE	0xFFFFFFFF
  ------------------
  566|      0|	}
  567|       |
  568|       |	/* Build the contents of the file */
  569|      2|	buffer[0] = buffer[1] = buffer[2] = 0xFF;
  570|      2|	put_pin(profile, buffer + 3, pin, pin_len, pin_tries);
  571|      2|	put_pin(profile, buffer + 13, puk, puk_len, puk_tries);
  572|       |
  573|       |	/* For updating the file, create a dummy CHV files if
  574|       |	 * necessary */
  575|      2|	ndummies = cflex_create_dummy_chvs(profile, p15card,
  576|      2|				file, SC_AC_OP_UPDATE, dummies);
  ------------------
  |  |  189|      2|#define SC_AC_OP_UPDATE			23
  ------------------
  577|      2|	if (ndummies < 0)
  ------------------
  |  Branch (577:6): [True: 0, False: 2]
  ------------------
  578|      0|		sc_file_free(file);
  579|      2|	LOG_TEST_RET(ctx, ndummies, "Unable to create dummy CHV file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  580|       |
  581|      2|	if (!unprotected)   {
  ------------------
  |  Branch (581:6): [True: 2, False: 0]
  ------------------
  582|      2|		struct sc_pin_cmd_data pin_cmd;
  583|       |
  584|      2|		memset(&pin_cmd, 0, sizeof(pin_cmd));
  585|      2|		pin_cmd.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  422|      2|#define SC_PIN_CMD_VERIFY	0
  ------------------
  586|      2|		pin_cmd.pin_type = SC_AC_CHV;
  ------------------
  |  |  151|      2|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  587|      2|		pin_cmd.pin_reference = ref;
  588|      2|		pin_cmd.pin1.data = dummy_pin_value;
  589|      2|		pin_cmd.pin1.len = sizeof(dummy_pin_value);
  590|       |
  591|      2|		r = sc_pin_cmd(p15card->card, &pin_cmd);
  592|      2|		if (r < 0)
  ------------------
  |  Branch (592:7): [True: 0, False: 2]
  ------------------
  593|      0|			sc_file_free(file);
  594|      2|		LOG_TEST_RET(ctx, r, "Cannot verify dummy PIN");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  595|      2|	};
  596|       |
  597|      2|	if (ref == 2)   {
  ------------------
  |  Branch (597:6): [True: 0, False: 2]
  ------------------
  598|       |		/* Cache dummy SOPIN value */
  599|      0|		r = sc_pkcs15_find_pin_by_type_and_reference(p15card, NULL, SC_AC_CHV, ref, &pin_obj);
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  600|      0|		if (!r && pin_obj)
  ------------------
  |  Branch (600:7): [True: 0, False: 0]
  |  Branch (600:13): [True: 0, False: 0]
  ------------------
  601|      0|			sc_pkcs15_pincache_add(p15card, pin_obj, dummy_pin_value, sizeof(dummy_pin_value));
  602|      0|	}
  603|       |
  604|      2|	r = sc_pkcs15init_create_file(profile, p15card, file);
  605|      2|	if (r < 0)
  ------------------
  |  Branch (605:6): [True: 2, False: 0]
  ------------------
  606|      2|		sc_file_free(file);
  607|      2|	LOG_TEST_RET(ctx, r, "Failed to create PIN file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  608|       |
  609|      0|	r = sc_update_binary(p15card->card, 0, buffer, 23, 0);
  610|      0|	if (r < 0 || file_ret == NULL)
  ------------------
  |  Branch (610:6): [True: 0, False: 0]
  |  Branch (610:15): [True: 0, False: 0]
  ------------------
  611|      0|		sc_file_free(file);
  612|      0|	else
  613|      0|		*file_ret = file;
  614|      0|	LOG_TEST_RET(ctx, r, "Failed to update PIN 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  615|       |
  616|       |	/* Delete the dummy CHV files */
  617|      0|	cflex_delete_dummy_chvs(profile, p15card, ndummies, dummies);
  618|       |
  619|      0|	if (pin_obj)   {
  ------------------
  |  Branch (619:6): [True: 0, False: 0]
  ------------------
  620|       |		/* Cache new SOPIN value */
  621|      0|		sc_pkcs15_pincache_add(p15card, pin_obj, pin, pin_len);
  622|      0|	}
  623|       |
  624|      0|	SC_FUNC_RETURN(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]
  |  |  ------------------
  ------------------
  625|      0|}
pkcs15-cflex.c:put_pin:
  513|      4|{
  514|      4|	if (len > 8)
  ------------------
  |  Branch (514:6): [True: 0, False: 4]
  ------------------
  515|      0|		len = 8;
  516|      4|	memset(buf, profile->pin_pad_char, 8);
  517|      4|	memcpy(buf, pin, len);
  518|      4|	buf[8] = retry;
  519|      4|	buf[9] = retry;
  520|      4|}
pkcs15-cflex.c:cflex_delete_dummy_chvs:
  501|      2|{
  502|      2|	while (ndummies--) {
  ------------------
  |  Branch (502:9): [True: 0, False: 2]
  ------------------
  503|      0|		cflex_delete_file(profile, p15card, dummies[ndummies]);
  504|      0|		sc_file_free(dummies[ndummies]);
  505|      0|	}
  506|      2|}
pkcs15-cflex.c:cflex_create_key:
  272|    109|{
  273|    109|	sc_pkcs15_prkey_info_t *key_info = (sc_pkcs15_prkey_info_t *) obj->data;
  274|    109|	sc_file_t	*prkf = NULL, *pukf = NULL;
  275|    109|	size_t		size;
  276|    109|	int		r;
  277|       |
  278|    109|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
  ------------------
  |  |  419|    109|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (278:6): [True: 87, False: 22]
  ------------------
  279|     87|		sc_log(p15card->card->ctx,  "Cryptoflex supports only RSA keys.");
  ------------------
  |  |   71|     87|#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|     87|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     87|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  281|     87|	}
  282|       |
  283|       |	/* Get the public and private key file */
  284|     22|	r = cflex_get_keyfiles(profile, p15card->card,  &key_info->path, &prkf, &pukf);
  285|     22|	if (r < 0)
  ------------------
  |  Branch (285:6): [True: 22, False: 0]
  ------------------
  286|     22|		return r;
  287|       |
  288|       |	/* Adjust the file sizes, if necessary */
  289|      0|	switch (key_info->modulus_length) {
  290|      0|	case  512: size = 166; break;
  ------------------
  |  Branch (290:2): [True: 0, False: 0]
  ------------------
  291|      0|	case  768: size = 246; break;
  ------------------
  |  Branch (291:2): [True: 0, False: 0]
  ------------------
  292|      0|	case 1024: size = 326; break;
  ------------------
  |  Branch (292:2): [True: 0, False: 0]
  ------------------
  293|      0|	case 2048: size = 646; break;
  ------------------
  |  Branch (293:2): [True: 0, False: 0]
  ------------------
  294|      0|	default:
  ------------------
  |  Branch (294:2): [True: 0, False: 0]
  ------------------
  295|      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__
  |  |  ------------------
  ------------------
  296|      0|			 "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n",
  297|      0|			 key_info->modulus_length);
  298|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  299|      0|		goto out;
  300|      0|	}
  301|       |
  302|      0|	if (prkf && prkf->size < size)
  ------------------
  |  Branch (302:6): [True: 0, False: 0]
  |  Branch (302:14): [True: 0, False: 0]
  ------------------
  303|      0|		prkf->size = size;
  304|      0|	if (pukf && pukf->size < size + 4)
  ------------------
  |  Branch (304:6): [True: 0, False: 0]
  |  Branch (304:14): [True: 0, False: 0]
  ------------------
  305|      0|		pukf->size = size + 4;
  306|       |
  307|       |	/* Now create the files */
  308|      0|	if ((r = sc_pkcs15init_create_file(profile, p15card, prkf)) < 0
  ------------------
  |  Branch (308:6): [True: 0, False: 0]
  ------------------
  309|      0|	 || (r = sc_pkcs15init_create_file(profile, p15card, pukf)) < 0)
  ------------------
  |  Branch (309:6): [True: 0, False: 0]
  ------------------
  310|      0|		goto out;
  311|       |
  312|      0|	key_info->key_reference = 0;
  313|       |
  314|      0|out:	sc_file_free(prkf);
  315|      0|	sc_file_free(pukf);
  316|      0|	return r;
  317|      0|}
pkcs15-cflex.c:cflex_get_keyfiles:
  654|     22|{
  655|     22|	sc_path_t	path = *df_path;
  656|     22|	int		r;
  657|       |
  658|     22|	if (path.len <= 2) {
  ------------------
  |  Branch (658:6): [True: 4, False: 18]
  ------------------
  659|      4|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  660|      4|	}
  661|       |
  662|       |	/* Get the private key file */
  663|     18|	r = sc_profile_get_file_by_path(profile, &path, prkf);
  664|     18|	if (r < 0) {
  ------------------
  |  Branch (664:6): [True: 0, False: 18]
  ------------------
  665|      0|		char pbuf[SC_MAX_PATH_STRING_SIZE];
  666|       |
  667|      0|		r = sc_path_print(pbuf, sizeof(pbuf), &path);
  668|      0|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (668:7): [True: 0, False: 0]
  ------------------
  669|      0|			pbuf[0] = '\0';
  670|       |
  671|      0|		sc_log(card->ctx,  "Cannot find private key file info "
  ------------------
  |  |   71|      0|#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|      0|				"in profile (path=%s).", pbuf);
  673|      0|		return r;
  674|      0|	}
  675|       |
  676|       |	/* Get the public key file */
  677|     18|	path.len -= 2;
  678|     18|	sc_append_file_id(&path, 0x1012);
  679|     18|	r = sc_profile_get_file_by_path(profile, &path, pukf);
  680|     18|	if (r < 0) {
  ------------------
  |  Branch (680:6): [True: 18, False: 0]
  ------------------
  681|     18|		sc_log(card->ctx,  "Cannot find public key file info in profile.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  682|     18|		sc_file_free(*prkf);
  683|     18|		return r;
  684|     18|	}
  685|       |
  686|      0|	return 0;
  687|     18|}

sc_pkcs15init_get_entersafe_ops:
  538|     33|{
  539|     33|	return &sc_pkcs15init_entersafe_operations;
  540|     33|}
pkcs15-entersafe.c:entersafe_erase_card:
   64|      1|{
   65|      1|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   66|       |
   67|      1|	if (sc_select_file(p15card->card, sc_get_mf_path(), NULL) < 0)
  ------------------
  |  Branch (67:6): [True: 1, False: 0]
  ------------------
   68|      1|		return SC_SUCCESS;
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
   69|       |
   70|      0|	return sc_card_ctl(p15card->card,SC_CARDCTL_ERASE_CARD,0);
   71|      1|}
pkcs15-entersafe.c:entersafe_init_card:
   74|      7|{
   75|      7|	struct sc_card *card = p15card->card;
   76|      7|	int ret;
   77|       |
   78|      7|	{/* MF */
   79|      7|		 sc_file_t *mf_file;
   80|      7|		 sc_entersafe_create_data mf_data = {0};
   81|       |
   82|      7|		 SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   83|       |
   84|      7|		 ret = sc_profile_get_file(profile, "MF", &mf_file);
   85|      7|		 LOG_TEST_RET(card->ctx,ret,"Get MF info 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: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   86|       |
   87|      7|		 mf_data.type = SC_ENTERSAFE_MF_DATA;
  ------------------
  |  |  664|      7|#define	SC_ENTERSAFE_MF_DATA	0x01
  ------------------
   88|      7|		 mf_data.data.df.file_id[0]=0x3F;
   89|      7|		 mf_data.data.df.file_id[1]=0x00;
   90|      7|		 mf_data.data.df.file_count=0x04;
   91|      7|		 mf_data.data.df.flag=0x11;
   92|      7|		 mf_data.data.df.ikf_size[0]=(mf_file->size>>8)&0xFF;
   93|      7|		 mf_data.data.df.ikf_size[1]=mf_file->size&0xFF;
   94|      7|		 mf_data.data.df.create_ac=0x10;
   95|      7|		 mf_data.data.df.append_ac=0xC0;
   96|      7|		 mf_data.data.df.lock_ac=0x10;
   97|      7|		 memcpy(mf_data.data.df.aid,mf_file->name,mf_file->namelen);
   98|      7|		 sc_file_free(mf_file);
   99|       |
  100|      7|		 ret = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_CREATE_FILE, &mf_data);
  101|      7|		 LOG_TEST_RET(card->ctx,ret,"Create MF 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: 0, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  102|      7|	}
  103|       |
  104|      7|	{/* EF(DIR) */
  105|      7|		 sc_file_t *dir_file;
  106|      7|		 size_t fid,size;
  107|      7|		 sc_entersafe_create_data ef_data;
  108|      7|		 u8 *buff=0;
  109|       |
  110|       |		 /* get dir profile */
  111|      7|		 ret = sc_profile_get_file(profile, "dir", &dir_file);
  112|      7|		 LOG_TEST_RET(card->ctx,ret,"Get EF(DIR) info 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|      6|		 fid=dir_file->id;
  114|      6|		 size=dir_file->size;
  115|      6|		 sc_file_free(dir_file);
  116|       |
  117|      6|		 ef_data.type=SC_ENTERSAFE_EF_DATA;
  ------------------
  |  |  666|      6|#define SC_ENTERSAFE_EF_DATA	0x04
  ------------------
  118|      6|		 ef_data.data.ef.file_id[0]=(fid>>8)&0xFF;
  119|      6|		 ef_data.data.ef.file_id[1]=fid&0xFF;
  120|      6|		 ef_data.data.ef.size[0]=(size>>8)&0xFF;
  121|      6|		 ef_data.data.ef.size[1]=size&0xFF;
  122|      6|		 ef_data.data.ef.attr[0]=0x00;
  123|      6|		 ef_data.data.ef.attr[1]=0x00;
  124|      6|		 ef_data.data.ef.name=0x00;
  125|      6|		 memset(ef_data.data.ef.ac,0x10,sizeof(ef_data.data.ef.ac));
  126|      6|		 memset(ef_data.data.ef.sm,0x00,sizeof(ef_data.data.ef.sm));
  127|       |
  128|      6|		 ret = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_CREATE_FILE, &ef_data);
  129|      6|		 LOG_TEST_RET(card->ctx,ret,"Create EF(DIR) 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|       |
  131|       |
  132|       |		 /* fill file by 0 */
  133|      6|		 if (size > MAX_FILE_SIZE)
  ------------------
  |  |  229|      6|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (133:8): [True: 0, False: 6]
  ------------------
  134|      6|			 LOG_TEST_RET(card->ctx, SC_ERROR_INVALID_DATA, "Initialize EF(DIR) failed with file size too large");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  135|      6|		 buff = calloc(1,size);
  136|      6|		 if(!buff)
  ------------------
  |  Branch (136:7): [True: 0, False: 6]
  ------------------
  137|      0|			  SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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]
  |  |  ------------------
  ------------------
  138|      6|		 memset(buff,0,size);
  139|       |
  140|      6|		 ret = sc_update_binary(card,0,buff,size,0);
  141|      6|		 free(buff);
  142|      6|		 LOG_TEST_RET(card->ctx,ret,"Initialize EF(DIR) 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  143|      6|	}
  144|       |
  145|      0|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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]
  |  |  ------------------
  ------------------
  146|       |
  147|      0|}
pkcs15-entersafe.c:entersafe_pin_reference:
  253|     10|{
  254|     10|	SC_FUNC_CALLED(p15card->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]
  |  |  ------------------
  ------------------
  255|       |
  256|     10|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     10|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (256:6): [True: 0, False: 10]
  ------------------
  257|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  258|       |
  259|     10|	if (auth_info->attrs.pin.reference < ENTERSAFE_USER_PIN_ID)
  ------------------
  |  |  668|     10|#define ENTERSAFE_USER_PIN_ID  0x01
  ------------------
  |  Branch (259:6): [True: 8, False: 2]
  ------------------
  260|      8|		 auth_info->attrs.pin.reference = ENTERSAFE_USER_PIN_ID;
  ------------------
  |  |  668|      8|#define ENTERSAFE_USER_PIN_ID  0x01
  ------------------
  261|     10|	if (auth_info->attrs.pin.reference > ENTERSAFE_USER_PIN_ID)
  ------------------
  |  |  668|     10|#define ENTERSAFE_USER_PIN_ID  0x01
  ------------------
  |  Branch (261:6): [True: 2, False: 8]
  ------------------
  262|      2|		 return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      2|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  263|       |
  264|      8|	SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE,SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  265|      8|}
pkcs15-entersafe.c:entersafe_create_pin:
  271|      1|{
  272|      1|	struct sc_card *card = p15card->card;
  273|      1|	int	r;
  274|      1|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  275|       |
  276|      1|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  277|       |
  278|      1|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      1|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (278:6): [True: 0, False: 1]
  ------------------
  279|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  280|       |
  281|      1|	{/*pin*/
  282|      1|		 sc_entersafe_wkey_data  data;
  283|       |
  284|      1|		 if (!pin || !pin_len || pin_len > 16)
  ------------------
  |  Branch (284:8): [True: 0, False: 1]
  |  Branch (284:16): [True: 0, False: 1]
  |  Branch (284:28): [True: 0, False: 1]
  ------------------
  285|      0|			  return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  286|       |
  287|      1|		 data.key_id = auth_info->attrs.pin.reference;
  288|      1|		 data.usage=0x0B;
  289|      1|		 data.key_data.symmetric.EC=0x33;
  290|      1|		 data.key_data.symmetric.ver=0x00;
  291|       |		 /* pad pin with 0 */
  292|      1|		 memset(data.key_data.symmetric.key_val, 0, sizeof(data.key_data.symmetric.key_val));
  293|      1|		 memcpy(data.key_data.symmetric.key_val, pin, pin_len);
  294|      1|		 data.key_data.symmetric.key_len=16;
  295|       |
  296|      1|		 r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_WRITE_KEY, &data);
  297|      1|		 if (r < 0)
  ------------------
  |  Branch (297:8): [True: 0, False: 1]
  ------------------
  298|      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]
  |  |  ------------------
  ------------------
  299|       |
  300|       |		 /* Cache new PIN value. */
  301|      1|		 sc_pkcs15_pincache_add(p15card, pin_obj, pin, pin_len);
  302|      1|	}
  303|       |
  304|      0|	{/*puk*/
  305|      1|		 sc_entersafe_wkey_data  data;
  306|       |
  307|      1|		 if (!puk || !puk_len || puk_len > 16)
  ------------------
  |  Branch (307:8): [True: 0, False: 1]
  |  Branch (307:16): [True: 0, False: 1]
  |  Branch (307:28): [True: 0, False: 1]
  ------------------
  308|      0|			  return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  309|       |
  310|      1|		 data.key_id = auth_info->attrs.pin.reference+1;
  311|      1|		 data.usage=0x0B;
  312|      1|		 data.key_data.symmetric.EC=0x33;
  313|      1|		 data.key_data.symmetric.ver=0x00;
  314|       |		 /* pad pin with 0 */
  315|      1|		 memset(data.key_data.symmetric.key_val, 0, sizeof(data.key_data.symmetric.key_val));
  316|      1|		 memcpy(data.key_data.symmetric.key_val, puk, puk_len);
  317|      1|		 data.key_data.symmetric.key_len=16;
  318|       |
  319|      1|		 r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_WRITE_KEY, &data);
  320|      1|	}
  321|       |
  322|       |
  323|      1|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
  324|      1|}
pkcs15-entersafe.c:entersafe_key_reference:
  328|      1|{
  329|      1|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  330|      1|	if (prkey->key_reference < ENTERSAFE_MIN_KEY_ID)
  ------------------
  |  |  670|      1|#define ENTERSAFE_MIN_KEY_ID 0x01
  ------------------
  |  Branch (330:6): [True: 1, False: 0]
  ------------------
  331|      1|		prkey->key_reference = ENTERSAFE_MIN_KEY_ID;
  ------------------
  |  |  670|      1|#define ENTERSAFE_MIN_KEY_ID 0x01
  ------------------
  332|      1|	if (prkey->key_reference > ENTERSAFE_MAX_KEY_ID)
  ------------------
  |  |  671|      1|#define ENTERSAFE_MAX_KEY_ID 0x09
  ------------------
  |  Branch (332:6): [True: 0, False: 1]
  ------------------
  333|      0|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  334|      1|	SC_FUNC_RETURN(p15card->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]
  |  |  ------------------
  ------------------
  335|      1|}
pkcs15-entersafe.c:entersafe_create_key:
  339|      1|{
  340|      1|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  341|      1|	SC_FUNC_RETURN(p15card->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]
  |  |  ------------------
  ------------------
  342|      1|}
pkcs15-entersafe.c:entersafe_generate_key:
  397|      1|{
  398|      1|	int r;
  399|      1|	sc_entersafe_gen_key_data	gendat;
  400|      1|	sc_pkcs15_prkey_info_t *kinfo = (sc_pkcs15_prkey_info_t *) obj->data;
  401|      1|	sc_card_t *card = p15card->card;
  402|      1|	sc_file_t              *tfile;
  403|      1|	const sc_acl_entry_t   *acl_entry;
  404|       |
  405|      1|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)obj->data;
  406|      1|	size_t keybits = key_info->modulus_length;
  407|       |
  408|      1|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  409|       |
  410|      1|	if ( obj->type != SC_PKCS15_TYPE_PRKEY_RSA )
  ------------------
  |  |  419|      1|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (410:7): [True: 0, False: 1]
  ------------------
  411|      0|	{
  412|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  413|      0|	}
  414|       |
  415|       |	/* Disable RSA:512bits */
  416|      1|	if ( ( keybits < 1024 ) ||
  ------------------
  |  Branch (416:7): [True: 0, False: 1]
  ------------------
  417|      1|		 ( keybits > 2048 ) ||
  ------------------
  |  Branch (417:4): [True: 0, False: 1]
  ------------------
  418|      1|		 ( keybits % 0x20 ) )
  ------------------
  |  Branch (418:4): [True: 0, False: 1]
  ------------------
  419|      0|	{
  420|      0|		sc_debug(card->ctx,
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  421|      0|			 SC_LOG_DEBUG_NORMAL,
  422|      0|			 "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n",
  423|      0|			 keybits);
  424|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  425|      0|	}
  426|       |
  427|      1|	r = sc_profile_get_file(profile, "PKCS15-AODF", &tfile);
  428|      1|	if (r < 0)
  ------------------
  |  Branch (428:6): [True: 1, False: 0]
  ------------------
  429|      1|		 return r;
  430|      0|	acl_entry = sc_file_get_acl_entry(tfile, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  431|      0|	if (acl_entry->method  != SC_AC_NONE) {
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (431:6): [True: 0, False: 0]
  ------------------
  432|      0|		 r = sc_pkcs15init_authenticate(profile, p15card, tfile, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  433|      0|		 if(r<0)
  ------------------
  |  Branch (433:7): [True: 0, False: 0]
  ------------------
  434|      0|			  r = SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  435|      0|	}
  436|      0|	sc_file_free(tfile);
  437|      0|	LOG_TEST_RET(card->ctx, r, "can't verify pin");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  438|       |
  439|       |	/* generate key pair */
  440|      0|	gendat.key_id     = (u8) kinfo->key_reference;
  441|      0|	gendat.key_length = (size_t) kinfo->modulus_length;
  442|      0|	gendat.modulus    = NULL;
  443|      0|	r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_GENERATE_KEY, &gendat);
  444|      0|	LOG_TEST_RET(card->ctx, r, "EnterSafe generate RSA key pair 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|       |
  446|       |	/* get the modulus via READ PUBLIC KEY */
  447|      0|	if (pubkey) {
  ------------------
  |  Branch (447:6): [True: 0, False: 0]
  ------------------
  448|      0|		u8 *buf;
  449|      0|		struct sc_pkcs15_pubkey_rsa *rsa = &pubkey->u.rsa;
  450|       |		/* set the modulus */
  451|      0|		rsa->modulus.data = gendat.modulus;
  452|      0|		rsa->modulus.len  = kinfo->modulus_length >> 3;
  453|       |		/* set the exponent (always 0x10001) */
  454|      0|		buf = malloc(3);
  455|      0|		if (!buf)
  ------------------
  |  Branch (455:7): [True: 0, False: 0]
  ------------------
  456|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  457|      0|		buf[0] = 0x01;
  458|      0|		buf[1] = 0x00;
  459|      0|		buf[2] = 0x01;
  460|      0|		rsa->exponent.data = buf;
  461|      0|		rsa->exponent.len  = 3;
  462|       |
  463|      0|		pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  464|      0|	} else
  465|       |		/* free public key */
  466|      0|		free(gendat.modulus);
  467|       |
  468|      0|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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]
  |  |  ------------------
  ------------------
  469|      0|}
pkcs15-entersafe.c:entersafe_sanity_check:
  473|      1|{
  474|      1|	struct sc_context *ctx = p15card->card->ctx;
  475|      1|	struct sc_pkcs15_auth_info profile_auth = {0};
  476|      1|	struct sc_pkcs15_object *objs[32];
  477|      1|	int rv, nn, ii, update_df = 0;
  478|       |
  479|      1|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  480|       |
  481|      1|	sc_log(ctx,  "Check and if needed update PinFlags");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  482|      1|	rv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
  ------------------
  |  |  445|      1|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  483|      1|	LOG_TEST_RET(ctx, rv, "Failed to get PINs");
  ------------------
  |  |  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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  484|      1|	nn = rv;
  485|       |
  486|      1|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_USER_PIN, &profile_auth);
  ------------------
  |  |  171|      1|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  487|      1|	LOG_TEST_RET(ctx, rv, "Failed to get PIN info");
  ------------------
  |  |  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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  488|       |
  489|      1|	for (ii=0; ii<nn; ii++) {
  ------------------
  |  Branch (489:13): [True: 0, False: 1]
  ------------------
  490|      0|		struct sc_pkcs15_auth_info *ainfo = (struct sc_pkcs15_auth_info *) objs[ii]->data;
  491|      0|		struct sc_pkcs15_pin_attributes *pin_attrs = &ainfo->attrs.pin;
  492|       |
  493|      0|		if (ainfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (493:7): [True: 0, False: 0]
  ------------------
  494|      0|			continue;
  495|       |
  496|      0|		if (pin_attrs->reference == profile_auth.attrs.pin.reference
  ------------------
  |  Branch (496:7): [True: 0, False: 0]
  ------------------
  497|      0|				&& pin_attrs->flags != profile_auth.attrs.pin.flags)   {
  ------------------
  |  Branch (497:8): [True: 0, False: 0]
  ------------------
  498|      0|			sc_log(ctx,  "Set flags of '%s'(flags:%X,ref:%i,id:%s) to %X", objs[ii]->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__
  |  |  ------------------
  ------------------
  499|      0|					pin_attrs->flags, pin_attrs->reference, sc_pkcs15_print_id(&ainfo->auth_id),
  500|      0|					profile_auth.attrs.pin.flags);
  501|      0|			pin_attrs->flags = profile_auth.attrs.pin.flags;
  502|      0|			update_df = 1;
  503|      0|		}
  504|      0|	}
  505|      1|	if (update_df)   {
  ------------------
  |  Branch (505:6): [True: 0, False: 1]
  ------------------
  506|      0|		struct sc_pkcs15_df *df = p15card->df_list;
  507|       |
  508|      0|		while (df != NULL && df->type != SC_PKCS15_AODF)
  ------------------
  |  |  496|      0|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (508:10): [True: 0, False: 0]
  |  Branch (508:24): [True: 0, False: 0]
  ------------------
  509|      0|			df = df->next;
  510|      0|		if (!df)
  ------------------
  |  Branch (510:7): [True: 0, False: 0]
  ------------------
  511|      0|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "Cannot find AODF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  512|      0|		rv = sc_pkcs15init_update_any_df(p15card, profile, df, 0);
  513|      0|		LOG_TEST_RET(ctx, rv, "Update AODF 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  514|      0|	}
  515|       |
  516|      1|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, rv);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  517|      1|}

sc_pkcs15init_get_epass2003_ops:
  802|    121|{
  803|    121|	return &sc_pkcs15init_epass2003_operations;
  804|    121|}
pkcs15-epass2003.c:epass2003_pkcs15_erase_card:
   37|     72|{
   38|     72|	SC_FUNC_CALLED(p15card->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]
  |  |  ------------------
  ------------------
   39|       |
   40|     72|	if (sc_select_file(p15card->card, sc_get_mf_path(), NULL) < 0)
  ------------------
  |  Branch (40:6): [True: 66, False: 6]
  ------------------
   41|     66|		return SC_SUCCESS;
  ------------------
  |  |   28|     66|#define SC_SUCCESS				0
  ------------------
   42|       |
   43|      6|	return sc_card_ctl(p15card->card, SC_CARDCTL_ERASE_CARD, 0);
   44|     72|}
pkcs15-epass2003.c:epass2003_pkcs15_init_card:
   48|      1|{
   49|      1|	struct sc_card *card = p15card->card;
   50|      1|	int ret;
   51|       |
   52|      1|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   53|      1|	sc_do_log(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL,NULL,0,NULL,
   54|      1|			"ePass2003 doesn't support SO-PIN and SO-PUK. You can unblock key with PUK. \n");
   55|      1|	{			/* MF */
   56|      1|		struct sc_file *mf_file;
   57|      1|		struct sc_file *skey_file;
   58|       |
   59|      1|		ret = sc_profile_get_file(profile, "MF", &mf_file);
   60|      1|		LOG_TEST_RET(card->ctx, ret,
  ------------------
  |  |  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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   61|      1|			    "Get MF info failed");
   62|      1|		ret = sc_create_file(card, mf_file);
   63|      1|		sc_file_free(mf_file);
   64|      1|		LOG_TEST_RET(card->ctx, ret,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   65|      0|			    "Create MF failed");
   66|       |
   67|      0|		ret = sc_profile_get_file(profile, "SKey-MF", &skey_file);
   68|      0|		LOG_TEST_RET(card->ctx, ret,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   69|      0|			    "Get SKey info failed");
   70|      0|		ret = sc_create_file(card, skey_file);
   71|      0|		sc_file_free(skey_file);
   72|      0|		LOG_TEST_RET(card->ctx, ret,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   73|      0|			    "Create SKey failed");
   74|       |
   75|      0|	}
   76|       |
   77|      0|	{			/* EF(DIR) */
   78|      0|		struct sc_file *dir_file;
   79|       |
   80|       |		/* get dir profile */
   81|      0|		ret = sc_profile_get_file(profile, "DIR", &dir_file);
   82|      0|		LOG_TEST_RET(card->ctx, ret,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   83|      0|			    "Get EF(DIR) info failed");
   84|      0|		ret = sc_create_file(card, dir_file);
   85|      0|		sc_file_free(dir_file);
   86|      0|		LOG_TEST_RET(card->ctx, ret,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   87|      0|			    "Create EF(DIR) failed");
   88|       |
   89|      0|		sc_free_apps(card);
   90|      0|	}
   91|      0|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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]
  |  |  ------------------
  ------------------
   92|      0|}
pkcs15-epass2003.c:epass2003_pkcs15_pin_reference:
  194|     76|{
  195|     76|	SC_FUNC_CALLED(p15card->card->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]
  |  |  ------------------
  ------------------
  196|       |
  197|     76|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     76|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (197:6): [True: 0, False: 76]
  ------------------
  198|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  199|       |
  200|     76|	if (auth_info->attrs.pin.reference < ENTERSAFE_USER_PIN_ID
  ------------------
  |  |  668|    152|#define ENTERSAFE_USER_PIN_ID  0x01
  ------------------
  |  Branch (200:6): [True: 71, False: 5]
  ------------------
  201|      5|	    || auth_info->attrs.pin.reference > ENTERSAFE_SO_PIN_ID)
  ------------------
  |  |  669|      5|#define ENTERSAFE_SO_PIN_ID 0x02
  ------------------
  |  Branch (201:9): [True: 3, False: 2]
  ------------------
  202|     74|		return SC_ERROR_INVALID_PIN_REFERENCE;
  ------------------
  |  |  111|     74|#define SC_ERROR_INVALID_PIN_REFERENCE		-1509
  ------------------
  203|       |
  204|      2|	SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  205|      2|}
pkcs15-epass2003.c:epass2003_pkcs15_create_pin:
  213|      1|{
  214|      1|	struct sc_card *card = p15card->card;
  215|      1|	int r;
  216|      1|	struct sc_pkcs15_auth_info *auth_info;
  217|       |
  218|      1|	if (NULL == pin_obj)
  ------------------
  |  Branch (218:6): [True: 0, False: 1]
  ------------------
  219|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  220|       |
  221|      1|	auth_info = (struct sc_pkcs15_auth_info *)pin_obj->data;
  222|       |
  223|      1|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  224|       |
  225|      1|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      1|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (225:6): [True: 0, False: 1]
  ------------------
  226|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  227|       |
  228|      1|	{			/*pin */
  229|      1|		sc_epass2003_wkey_data data;
  230|      1|		int id;
  231|       |
  232|      1|		if (!pin || !pin_len || pin_len > 16)
  ------------------
  |  Branch (232:7): [True: 0, False: 1]
  |  Branch (232:15): [True: 0, False: 1]
  |  Branch (232:27): [True: 0, False: 1]
  ------------------
  233|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  234|       |
  235|      1|		data.type = SC_EPASS2003_SECRET_PIN;
  ------------------
  |  |  730|      1|#define	SC_EPASS2003_SECRET_PIN	0x00000022
  ------------------
  236|      1|		data.key_data.es_secret.kid = auth_info->attrs.pin.reference;
  237|      1|		data.key_data.es_secret.ac[0] =
  238|      1|		    EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE;
  ------------------
  |  |  737|      1|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              		    EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE;
  ------------------
  |  |  732|      1|#define EPASS2003_AC_EVERYONE		0x00
  ------------------
  239|      1|		data.key_data.es_secret.ac[1] =
  240|      1|		    EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER;
  ------------------
  |  |  737|      1|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              		    EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_USER;
  ------------------
  |  |  733|      1|#define EPASS2003_AC_USER		0x06
  ------------------
  241|       |
  242|      1|		r = sc_profile_get_pin_id(profile, 2, &id);
  243|      1|		LOG_TEST_RET(card->ctx, r,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  244|      0|			    "Get User PIN id error!");
  245|      0|		data.key_data.es_secret.EC =
  246|      0|		    sc_profile_get_pin_retries(profile, id);
  247|       |
  248|       |		/* pad pin with 0 */
  249|      0|		memset(data.key_data.es_secret.key_val, 0,
  250|      0|		       sizeof(data.key_data.es_secret.key_val));
  251|      0|		memcpy(data.key_data.es_secret.key_val, pin, pin_len);
  252|      0|		data.key_data.es_secret.key_len = pin_len;
  253|       |
  254|      0|		r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_WRITE_KEY, &data);
  255|      0|		if (r < 0)
  ------------------
  |  Branch (255:7): [True: 0, False: 0]
  ------------------
  256|      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]
  |  |  ------------------
  ------------------
  257|      0|		if (pin_obj) {
  ------------------
  |  Branch (257:7): [True: 0, False: 0]
  ------------------
  258|       |			/* Cache new PIN value. */
  259|      0|			sc_pkcs15_pincache_add(p15card, pin_obj, pin, pin_len);
  260|      0|		}
  261|      0|	}
  262|       |
  263|      0|	{			/*puk */
  264|      0|		sc_epass2003_wkey_data data;
  265|      0|		int id;
  266|       |
  267|      0|		if (!puk || !puk_len || puk_len > 16)
  ------------------
  |  Branch (267:7): [True: 0, False: 0]
  |  Branch (267:15): [True: 0, False: 0]
  |  Branch (267:27): [True: 0, False: 0]
  ------------------
  268|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  269|       |
  270|      0|		data.type = SC_EPASS2003_SECRET_PIN;
  ------------------
  |  |  730|      0|#define	SC_EPASS2003_SECRET_PIN	0x00000022
  ------------------
  271|      0|		data.key_data.es_secret.kid =
  272|      0|		    auth_info->attrs.pin.reference + 1;
  273|      0|		data.key_data.es_secret.ac[0] =
  274|      0|		    EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE;
  ------------------
  |  |  737|      0|#define EPASS2003_AC_MAC_NOLESS		0x90
  ------------------
              		    EPASS2003_AC_MAC_NOLESS | EPASS2003_AC_EVERYONE;
  ------------------
  |  |  732|      0|#define EPASS2003_AC_EVERYONE		0x00
  ------------------
  275|      0|		data.key_data.es_secret.ac[1] =
  276|      0|		    EPASS2003_AC_MAC_EQUAL | EPASS2003_AC_SO;
  ------------------
  |  |  739|      0|#define EPASS2003_AC_MAC_EQUAL		0xB0
  ------------------
              		    EPASS2003_AC_MAC_EQUAL | EPASS2003_AC_SO;
  ------------------
  |  |  734|      0|#define EPASS2003_AC_SO			0x08
  ------------------
  277|       |
  278|      0|		r = sc_profile_get_pin_id(profile, 1, &id);
  279|      0|		LOG_TEST_RET(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  280|      0|			    "Get User PIN id error!");
  281|      0|		data.key_data.es_secret.EC =
  282|      0|		    sc_profile_get_pin_retries(profile, id);
  283|       |
  284|       |		/* pad pin with 0 */
  285|      0|		memset(data.key_data.es_secret.key_val, 0,
  286|      0|		       sizeof(data.key_data.es_secret.key_val));
  287|      0|		memcpy(data.key_data.es_secret.key_val, puk, puk_len);
  288|      0|		data.key_data.es_secret.key_len = puk_len;
  289|       |
  290|      0|		r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_WRITE_KEY, &data);
  291|      0|	}
  292|       |
  293|      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]
  |  |  ------------------
  ------------------
  294|      0|}
pkcs15-epass2003.c:epass2003_pkcs15_key_reference:
  299|    140|{
  300|    140|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  301|    140|	if (prkey->path.len == 0)
  ------------------
  |  Branch (301:6): [True: 32, False: 108]
  ------------------
  302|     32|		SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  303|    108|	prkey->key_reference = prkey->path.value[prkey->path.len - 1];
  304|    108|	SC_FUNC_RETURN(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  305|    108|}
pkcs15-epass2003.c:epass2003_pkcs15_create_key:
  404|    108|{
  405|    108|	struct sc_card *card = p15card->card;
  406|       |
  407|    108|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    108|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    108|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    108|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 108]
  |  |  ------------------
  ------------------
  408|    108|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  409|    108|}
pkcs15-epass2003.c:cosm_new_file:
  311|    164|{
  312|    164|	struct sc_file *file = NULL;
  313|    164|	const char *_template = NULL, *desc = NULL;
  314|    164|	unsigned int structure = 0xFFFFFFFF;
  315|       |
  316|    164|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    164|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    164|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    164|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 164]
  |  |  ------------------
  ------------------
  317|    164|	sc_log(card->ctx,  "type %X; num %i\n", type,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  318|    164|		 num);
  319|    164|	while (1) {
  ------------------
  |  Branch (319:9): [True: 164, Folded]
  ------------------
  320|    164|		switch (type) {
  ------------------
  |  Branch (320:11): [True: 164, False: 0]
  ------------------
  321|     54|		case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     54|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (321:3): [True: 54, False: 110]
  ------------------
  322|     54|			desc = "EC private key";
  323|     54|			_template = "private-key";
  324|     54|			structure = SC_CARDCTL_OBERTHUR_KEY_EC_CRT;
  325|     54|			break;
  326|     23|		case SC_PKCS15_TYPE_PUBKEY_EC:
  ------------------
  |  |  428|     23|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  |  Branch (326:3): [True: 23, False: 141]
  ------------------
  327|     23|			desc = "EC public key";
  328|     23|			_template = "public-key";
  329|     23|			structure = SC_CARDCTL_OBERTHUR_KEY_EC_PUBLIC;
  330|     23|			break;
  331|     54|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|     54|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (331:3): [True: 54, False: 110]
  ------------------
  332|     54|			desc = "RSA private key";
  333|     54|			_template = "private-key";
  334|     54|			structure = SC_CARDCTL_OBERTHUR_KEY_RSA_CRT;
  335|     54|			break;
  336|     33|		case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|     33|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (336:3): [True: 33, False: 131]
  ------------------
  337|     33|			desc = "RSA public key";
  338|     33|			_template = "public-key";
  339|     33|			structure = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
  340|     33|			break;
  341|      0|		case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (341:3): [True: 0, False: 164]
  ------------------
  342|      0|			desc = "extractable private key";
  343|      0|			_template = "extractable-key";
  344|      0|			break;
  345|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (345:3): [True: 0, False: 164]
  ------------------
  346|      0|			desc = "certificate";
  347|      0|			_template = "certificate";
  348|      0|			break;
  349|      0|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (349:3): [True: 0, False: 164]
  ------------------
  350|      0|			desc = "data object";
  351|      0|			_template = "data";
  352|      0|			break;
  353|    164|		}
  354|    164|		if (_template)
  ------------------
  |  Branch (354:7): [True: 164, False: 0]
  ------------------
  355|    164|			break;
  356|       |		/* If this is a specific type such as
  357|       |		 * SC_PKCS15_TYPE_CERT_FOOBAR, fall back to
  358|       |		 * the generic class (SC_PKCS15_TYPE_CERT)
  359|       |		 */
  360|      0|		if (!(type & ~SC_PKCS15_TYPE_CLASS_MASK)) {
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (360:7): [True: 0, False: 0]
  ------------------
  361|      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__
  |  |  ------------------
  ------------------
  362|      0|				 "File type %X not supported by card driver",
  363|      0|				 type);
  364|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  365|      0|		}
  366|      0|		type &= SC_PKCS15_TYPE_CLASS_MASK;
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  367|      0|	}
  368|       |
  369|    164|	sc_log(card->ctx,  "template %s; num %i\n",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  370|    164|		 _template, num);
  371|    164|	if (sc_profile_get_file(profile, _template, &file) < 0) {
  ------------------
  |  Branch (371:6): [True: 21, False: 143]
  ------------------
  372|     21|		sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  373|     21|			 "Profile doesn't define %s template '%s'\n", desc,
  374|     21|			 _template);
  375|     21|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     21|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  376|     21|	}
  377|       |
  378|    143|	if (file->path.len < 1) {
  ------------------
  |  Branch (378:6): [True: 0, False: 143]
  ------------------
  379|      0|		sc_file_free(file);
  380|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  381|      0|	}
  382|       |
  383|    143|	file->id &= 0xFF00;
  384|    143|	file->id |= (num & 0x00FF);
  385|       |
  386|    143|	file->path.value[file->path.len - 1] = (num & 0xFF);
  387|    143|	file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|    143|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  388|    143|	file->ef_structure = structure;
  389|       |
  390|    143|	sc_log(card->ctx,
  ------------------
  |  |   71|    143|#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|    143|		 "file size %"SC_FORMAT_LEN_SIZE_T"u; ef type %i/%i; id %04X, path_len %"SC_FORMAT_LEN_SIZE_T"u\n",
  392|    143|		 file->size, file->type, file->ef_structure, file->id,
  393|    143|		 file->path.len);
  394|    143|	sc_log(card->ctx,  "file path: %s",
  ------------------
  |  |   71|    143|#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|    143|		 sc_print_path(&(file->path)));
  396|    143|	*out = file;
  397|       |
  398|    143|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_SUCCESS);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  399|    143|}
pkcs15-epass2003.c:epass2003_pkcs15_generate_key:
  502|    108|{
  503|    108|	struct sc_card *card = p15card->card;
  504|    108|	int r;
  505|    108|	sc_epass2003_gen_key_data gendat;
  506|    108|	struct sc_pkcs15_prkey_info *key_info =
  507|    108|	    (struct sc_pkcs15_prkey_info *)obj->data;
  508|    108|	int idx = key_info->key_reference;
  509|    108|	size_t keybits = key_info->modulus_length;
  510|    108|	struct sc_file *tfile = NULL, *pukf = NULL;
  511|    108|	struct sc_path path;
  512|    108|	struct sc_file *file = NULL;
  513|    108|	int fidl = 0;
  514|       |
  515|    108|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    108|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    108|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    108|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 108]
  |  |  ------------------
  ------------------
  516|       |
  517|    108|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA && obj->type != SC_PKCS15_TYPE_PRKEY_EC)
  ------------------
  |  |  419|    216|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
              	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA && obj->type != SC_PKCS15_TYPE_PRKEY_EC)
  ------------------
  |  |  421|     54|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (517:6): [True: 54, False: 54]
  |  Branch (517:47): [True: 0, False: 54]
  ------------------
  518|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  519|       |
  520|    108|	if(obj->type == SC_PKCS15_TYPE_PRKEY_EC && keybits == 0)
  ------------------
  |  |  421|    216|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (520:5): [True: 54, False: 54]
  |  Branch (520:45): [True: 54, False: 0]
  ------------------
  521|     54|		keybits = 256; 	//EC key length is 256 ...
  522|       |
  523|       |	/* allocate key object */
  524|    108|	r = cosm_new_file(profile, card, obj->type, idx, &file); //replace SC_PKCS15_TYPE_PRKEY_RSA with obj->type
  525|    108|	SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  176|    108|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|    108|	int _ret = (r); \
  |  |  178|    108|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 12, False: 96]
  |  |  ------------------
  |  |  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|    108|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 96]
  |  |  ------------------
  ------------------
  526|    108|		    "create key: failed to allocate new key object");
  527|     96|	file->size = keybits;
  528|     96|	sc_log(card->ctx,  "private key path: %s",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  529|     96|		 sc_print_path(&file->path));
  530|     96|	sc_log(card->ctx,  "private key_info path: %s",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  531|     96|		 sc_print_path(&(key_info->path)));
  532|       |
  533|     96|	r = sc_pkcs15init_authenticate(profile, p15card, file,
  534|     96|				       SC_AC_OP_DELETE);
  ------------------
  |  |  168|     96|#define SC_AC_OP_DELETE			2
  ------------------
  535|     96|	SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  536|     96|		    "generate key: pkcs15init_authenticate(SC_AC_OP_DELETE) failed");
  537|       |
  538|     96|	sc_delete_file(p15card->card, &file->path);
  539|       |	/* create */
  540|     96|	r = sc_pkcs15init_create_file(profile, p15card, file);
  541|     96|	SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  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: 33, False: 63]
  |  |  ------------------
  |  |  179|     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
  |  |  ------------------
  |  |  180|     33|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  181|     33|		goto err; \
  |  |  182|     33|	} \
  |  |  183|     96|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 63]
  |  |  ------------------
  ------------------
  542|     96|		    "create key: failed to create key file");
  543|       |
  544|     63|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  545|     63|		 "index %u; keybits %"SC_FORMAT_LEN_SIZE_T"u\n",
  546|     63|		 idx, keybits);
  547|     63|	if (keybits < 1024 || keybits > 2048 || (keybits % 0x20)) {
  ------------------
  |  Branch (547:6): [True: 27, False: 36]
  |  Branch (547:24): [True: 0, False: 36]
  |  Branch (547:42): [True: 0, False: 36]
  ------------------
  548|     27|		if(obj->type == SC_PKCS15_TYPE_PRKEY_EC && keybits == 256)
  ------------------
  |  |  421|     54|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (548:6): [True: 27, False: 0]
  |  Branch (548:46): [True: 27, False: 0]
  ------------------
  549|     27|		{
  550|     27|			sc_log(card->ctx, "current Alg is EC,Only support 256 ..\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__
  |  |  ------------------
  ------------------
  551|     27|		}
  552|      0|		else
  553|      0|		{
  554|      0|			sc_debug(card->ctx, SC_LOG_DEBUG_VERBOSE_TOOL,
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  555|      0|				 "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u\n",
  556|      0|				 keybits);
  557|      0|			r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  558|      0|			goto err;
  559|      0|		}
  560|     27|	}
  561|       |
  562|     63|	path = key_info->path;
  563|     63|	path.len -= 2;
  564|       |
  565|     63|	r = sc_select_file(card, &path, &tfile);
  566|     63|	SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  176|     63|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     63|	int _ret = (r); \
  |  |  178|     63|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 7, False: 56]
  |  |  ------------------
  |  |  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|     63|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 56]
  |  |  ------------------
  ------------------
  567|     63|		    "generate key: no private object DF");
  568|       |
  569|     56|	r = sc_pkcs15init_authenticate(profile, p15card, tfile,
  570|     56|				       SC_AC_OP_CRYPTO);
  ------------------
  |  |  173|     56|#define SC_AC_OP_CRYPTO			7
  ------------------
  571|     56|	SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  176|     56|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     56|	int _ret = (r); \
  |  |  178|     56|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 0, False: 56]
  |  |  ------------------
  |  |  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|     56|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 56]
  |  |  ------------------
  ------------------
  572|     56|		    "generate key: pkcs15init_authenticate(SC_AC_OP_CRYPTO) failed");
  573|       |
  574|     56|	r = sc_pkcs15init_authenticate(profile, p15card, tfile,
  575|     56|				       SC_AC_OP_CREATE);
  ------------------
  |  |  169|     56|#define SC_AC_OP_CREATE			3
  ------------------
  576|     56|	SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  176|     56|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     56|	int _ret = (r); \
  |  |  178|     56|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 0, False: 56]
  |  |  ------------------
  |  |  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|     56|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 56]
  |  |  ------------------
  ------------------
  577|     56|		    "generate key: pkcs15init_authenticate(SC_AC_OP_CREATE) failed");
  578|       |
  579|     56|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA )
  ------------------
  |  |  419|     56|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (579:6): [True: 23, False: 33]
  ------------------
  580|     23|	{
  581|     23|		r = cosm_new_file(profile, card, SC_PKCS15_TYPE_PUBKEY_EC, idx, &pukf);
  ------------------
  |  |  428|     23|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  582|     23|	}
  583|     33|	else
  584|     33|	{
  585|     33|		r = cosm_new_file(profile, card, SC_PKCS15_TYPE_PUBKEY_RSA, idx, &pukf);
  ------------------
  |  |  426|     33|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  586|     33|	}
  587|       |
  588|     56|	if (r < 0) {
  ------------------
  |  Branch (588:6): [True: 9, False: 47]
  ------------------
  589|      9|		sc_log(card->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__
  |  |  ------------------
  ------------------
  590|      9|			 "generate key: create temporary pukf failed\n");
  591|      9|		goto err;
  592|      9|	}
  593|       |
  594|     47|	pukf->size = keybits;
  595|     47|	pukf->id = pukf->path.value[pukf->path.len - 2] * 0x100
  596|     47|	    + pukf->path.value[pukf->path.len - 1];
  597|       |
  598|     47|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  599|     47|		 "public key size %"SC_FORMAT_LEN_SIZE_T"u; ef type %i/%i; id %04X; path: %s",
  600|     47|		 pukf->size, pukf->type, pukf->ef_structure, pukf->id,
  601|     47|		 sc_print_path(&pukf->path));
  602|       |
  603|     47|	r = sc_select_file(p15card->card, &pukf->path, NULL);
  604|       |	/* if exist, delete */
  605|     47|	if (r == SC_SUCCESS) {
  ------------------
  |  |   28|     47|#define SC_SUCCESS				0
  ------------------
  |  Branch (605:6): [True: 34, False: 13]
  ------------------
  606|     34|		r = sc_pkcs15init_authenticate(profile, p15card, pukf,
  607|     34|		       SC_AC_OP_DELETE);
  ------------------
  |  |  168|     34|#define SC_AC_OP_DELETE			2
  ------------------
  608|     34|		SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  176|     34|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     34|	int _ret = (r); \
  |  |  178|     34|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 0, False: 34]
  |  |  ------------------
  |  |  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|     34|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 34]
  |  |  ------------------
  ------------------
  609|     34|		    "generate key - pubkey: pkcs15init_authenticate(SC_AC_OP_DELETE) failed");
  610|       |
  611|     34|		r = sc_pkcs15init_delete_by_path(profile, p15card, &pukf->path);
  612|     34|		if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     34|#define SC_SUCCESS				0
  ------------------
  |  Branch (612:7): [True: 26, False: 8]
  ------------------
  613|     26|			sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  614|     26|				 "generate key: failed to delete existing key file\n");
  615|     26|			goto err;
  616|     26|		}
  617|     34|	}
  618|       |	/* create */
  619|     21|	r = sc_pkcs15init_create_file(profile, p15card, pukf);
  620|     21|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     21|#define SC_SUCCESS				0
  ------------------
  |  Branch (620:6): [True: 12, False: 9]
  ------------------
  621|     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__
  |  |  ------------------
  ------------------
  622|     12|			 "generate key: pukf create file failed\n");
  623|     12|		goto err;
  624|     12|	}
  625|       |
  626|      9|	r = sc_pkcs15init_authenticate(profile, p15card, pukf,
  627|      9|				       SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      9|#define SC_AC_OP_UPDATE			23
  ------------------
  628|      9|	SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  176|      9|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|      9|	int _ret = (r); \
  |  |  178|      9|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 0, False: 9]
  |  |  ------------------
  |  |  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|      9|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 9]
  |  |  ------------------
  ------------------
  629|      9|		    "generate key - pubkey: pkcs15init_authenticate(SC_AC_OP_UPDATE) failed");
  630|       |
  631|       |	/* generate key pair */
  632|      9|	fidl = (file->id & 0xff) * FID_STEP;
  ------------------
  |  |  741|      9|#define FID_STEP 0x20
  ------------------
  633|      9|	file->id = (file->id & 0xff00) + fidl;
  634|      9|	pukf->id = (pukf->id & 0xff00) + fidl;
  635|      9|	gendat.prkey_id = file->id;
  636|      9|	gendat.pukey_id = pukf->id;
  637|      9|	gendat.key_length = keybits;
  638|      9|	gendat.modulus = NULL;
  639|      9|	gendat.modulus_len = 0;
  640|      9|	r = sc_card_ctl(card, SC_CARDCTL_ENTERSAFE_GENERATE_KEY, &gendat);
  641|      9|	SC_TEST_GOTO_ERR(card->ctx, SC_LOG_DEBUG_VERBOSE, r,
  ------------------
  |  |  176|      9|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|      9|	int _ret = (r); \
  |  |  178|      9|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 5, False: 4]
  |  |  ------------------
  |  |  179|      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
  |  |  ------------------
  |  |  180|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  181|      5|		goto err; \
  |  |  182|      5|	} \
  |  |  183|      9|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 4]
  |  |  ------------------
  ------------------
  642|      9|		    "generate RSA key pair failed");
  643|       |
  644|      4|	if (!gendat.modulus) {
  ------------------
  |  Branch (644:6): [True: 0, False: 4]
  ------------------
  645|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  646|      0|		goto err;
  647|      0|	}
  648|       |
  649|       |	/* get the modulus */
  650|      4|	if (pubkey && (obj->type == SC_PKCS15_TYPE_PRKEY_RSA)) {
  ------------------
  |  |  419|      4|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (650:6): [True: 4, False: 0]
  |  Branch (650:16): [True: 4, False: 0]
  ------------------
  651|      4|		u8 *buf;
  652|      4|		struct sc_pkcs15_pubkey_rsa *rsa = &pubkey->u.rsa;
  653|       |		/* set the modulus */
  654|      4|		rsa->modulus.data = gendat.modulus;
  655|      4|		rsa->modulus.len = keybits >> 3;
  656|       |		/* set the exponent (always 0x10001) */
  657|      4|		buf = (u8 *) malloc(3);
  658|      4|		if (!buf) {
  ------------------
  |  Branch (658:7): [True: 0, False: 4]
  ------------------
  659|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  660|      0|			goto err;
  661|      0|		}
  662|      4|		buf[0] = 0x01;
  663|      4|		buf[1] = 0x00;
  664|      4|		buf[2] = 0x01;
  665|      4|		rsa->exponent.data = buf;
  666|      4|		rsa->exponent.len = 3;
  667|       |
  668|      4|		pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      4|#define SC_ALGORITHM_RSA		0
  ------------------
  669|      4|	}
  670|      0|	else if(pubkey && (obj->type == SC_PKCS15_TYPE_PRKEY_EC)){
  ------------------
  |  |  421|      0|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (670:10): [True: 0, False: 0]
  |  Branch (670:20): [True: 0, False: 0]
  ------------------
  671|      0|		struct sc_ec_parameters *ecparams = (struct
  672|      0|				sc_ec_parameters *)key_info->params.data;
  673|      0|		pubkey->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
  674|      0|		pubkey->u.ec.ecpointQ.value = (u8 *)malloc(gendat.modulus_len + 1);
  675|      0|		if (!pubkey->u.ec.ecpointQ.value) {
  ------------------
  |  Branch (675:7): [True: 0, False: 0]
  ------------------
  676|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  677|      0|			goto err;
  678|      0|		}
  679|       |
  680|      0|		pubkey->u.ec.ecpointQ.value[0] = 0x04;
  681|      0|		memcpy(&pubkey->u.ec.ecpointQ.value[1], gendat.modulus, gendat.modulus_len);
  682|      0|		pubkey->u.ec.ecpointQ.len = gendat.modulus_len + 1;
  683|      0|		free(gendat.modulus);
  684|       |
  685|      0|		free(pubkey->u.ec.params.named_curve);
  686|      0|		pubkey->u.ec.params.named_curve = NULL;
  687|       |
  688|      0|		free(pubkey->u.ec.params.der.value);
  689|      0|		pubkey->u.ec.params.der.value = NULL;
  690|      0|		pubkey->u.ec.params.der.len = 0;
  691|      0|		pubkey->u.ec.params.named_curve = strdup(ecparams->named_curve);
  692|       |
  693|      0|		if (!pubkey->u.ec.params.named_curve){
  ------------------
  |  Branch (693:7): [True: 0, False: 0]
  ------------------
  694|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  695|      0|			goto err;
  696|      0|		}
  697|       |
  698|      0|		r = sc_pkcs15_fix_ec_parameters(card->ctx, &pubkey->u.ec.params);
  699|      0|	}
  700|      0|	else
  701|       |		/* free public key */
  702|      0|		free(gendat.modulus);
  703|       |
  704|    108|err:
  705|    108|	sc_file_free(pukf);
  706|    108|	sc_file_free(file);
  707|    108|	sc_file_free(tfile);
  708|       |
  709|    108|	if(r < 0 && pubkey->u.ec.ecpointQ.value)
  ------------------
  |  Branch (709:5): [True: 104, False: 4]
  |  Branch (709:14): [True: 0, False: 104]
  ------------------
  710|      0|	{
  711|      0|		free(pubkey->u.ec.ecpointQ.value);
  712|      0|		pubkey->u.ec.ecpointQ.value = NULL;
  713|      0|		pubkey->u.ec.ecpointQ.len = 0;
  714|      0|	}
  715|       |
  716|    108|	SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, 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|    104|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 104, False: 4]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  717|    108|}
pkcs15-epass2003.c:epass2003_pkcs15_sanity_check:
  730|     72|{
  731|     72|	struct sc_context *ctx = p15card->card->ctx;
  732|     72|	struct sc_pkcs15_auth_info profile_auth = {0};
  733|     72|	struct sc_pkcs15_object *objs[32];
  734|     72|	int rv, nn, ii, update_df = 0;
  735|       |
  736|     72|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  737|       |
  738|     72|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  739|     72|		 "Check and if needed update PinFlags");
  740|     72|	rv = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, objs, 32);
  ------------------
  |  |  445|     72|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  741|     72|	LOG_TEST_RET(ctx, rv, "Failed to get PINs");
  ------------------
  |  |  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: 0, False: 72]
  |  |  |  |  ------------------
  |  |  |  |  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|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 72]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  742|     72|	nn = rv;
  743|       |
  744|     72|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_USER_PIN, &profile_auth);
  ------------------
  |  |  171|     72|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  745|     72|	LOG_TEST_RET(ctx, rv, "Failed to get PIN info");
  ------------------
  |  |  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: 0, False: 72]
  |  |  |  |  ------------------
  |  |  |  |  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|     72|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 72]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  746|       |
  747|     72|	for (ii = 0; ii < nn; ii++) {
  ------------------
  |  Branch (747:15): [True: 0, False: 72]
  ------------------
  748|      0|		struct sc_pkcs15_auth_info *ainfo =
  749|      0|		    (struct sc_pkcs15_auth_info *)objs[ii]->data;
  750|      0|		struct sc_pkcs15_pin_attributes *pin_attrs = &ainfo->attrs.pin;
  751|       |
  752|      0|		if (ainfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      0|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (752:7): [True: 0, False: 0]
  ------------------
  753|      0|			continue;
  754|       |
  755|      0|		if (pin_attrs->reference == profile_auth.attrs.pin.reference
  ------------------
  |  Branch (755:7): [True: 0, False: 0]
  ------------------
  756|      0|		    && pin_attrs->flags != profile_auth.attrs.pin.flags) {
  ------------------
  |  Branch (756:10): [True: 0, False: 0]
  ------------------
  757|      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__
  |  |  ------------------
  ------------------
  758|      0|				 "Set flags of '%s'(flags:%X,ref:%i,id:%s) to %X",
  759|      0|				 objs[ii]->label, pin_attrs->flags,
  760|      0|				 pin_attrs->reference,
  761|      0|				 sc_pkcs15_print_id(&ainfo->auth_id),
  762|      0|				 profile_auth.attrs.pin.flags);
  763|      0|			pin_attrs->flags = profile_auth.attrs.pin.flags;
  764|      0|			update_df = 1;
  765|      0|		}
  766|      0|	}
  767|     72|	if (update_df) {
  ------------------
  |  Branch (767:6): [True: 0, False: 72]
  ------------------
  768|      0|		struct sc_pkcs15_df *df = p15card->df_list;
  769|       |
  770|      0|		while (df != NULL && df->type != SC_PKCS15_AODF)
  ------------------
  |  |  496|      0|#define SC_PKCS15_AODF			8
  ------------------
  |  Branch (770:10): [True: 0, False: 0]
  |  Branch (770:24): [True: 0, False: 0]
  ------------------
  771|      0|			df = df->next;
  772|      0|		if (!df)
  ------------------
  |  Branch (772:7): [True: 0, False: 0]
  ------------------
  773|      0|			LOG_TEST_RET(ctx,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  774|      0|				    SC_ERROR_OBJECT_NOT_FOUND,
  775|      0|				    "Cannot find AODF");
  776|      0|		rv = sc_pkcs15init_update_any_df(p15card, profile, df, 0);
  777|      0|		LOG_TEST_RET(ctx, rv, "Update AODF 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  778|      0|	}
  779|       |
  780|     72|	SC_FUNC_RETURN(ctx, SC_LOG_DEBUG_VERBOSE, rv);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  781|     72|}

sc_pkcs15init_get_gids_ops:
  190|     27|{
  191|     27|	return &sc_pkcs15init_gids_operations;
  192|     27|}
pkcs15-gids.c:gids_select_key_reference:
   46|     17|{
   47|     17|	sc_card_t *card = p15card->card;
   48|     17|	LOG_FUNC_RETURN(card->ctx, sc_card_ctl(card, SC_CARDCTL_GIDS_SELECT_KEY_REFERENCE, key_info));
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   49|     17|}
pkcs15-gids.c:gids_emu_update_any_df:
  108|     12|{
  109|     12|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|     12|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |	/* After storing object, pkcs15init will call this function to update DF.
  111|       |	 * But GIDS has no other DF than GIDS-Application, so we do nothing. */
  112|     12|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  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|      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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  113|     12|}
pkcs15-gids.c:gids_emu_store_data:
  133|     17|                              struct sc_path *path) {
  134|     17|	sc_card_t *card = p15card->card;
  135|     17|	int r;
  136|       |
  137|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  138|       |
  139|     17|	switch (object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|     17|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  140|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (140:2): [True: 0, False: 17]
  ------------------
  141|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (141:2): [True: 0, False: 17]
  ------------------
  142|       |		/* For these two type, store_data just don't need to do anything.
  143|       |		 * All have been done already before this function is called */
  144|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  145|      0|		break;
  146|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (146:2): [True: 0, False: 17]
  ------------------
  147|      0|		r = gids_save_certificate(p15card, object, path);
  148|      0|		break;
  149|     17|	default:
  ------------------
  |  Branch (149:2): [True: 17, False: 0]
  ------------------
  150|     17|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|     17|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  151|     17|		break;
  152|     17|	}
  153|     17|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  154|     17|}

iasecc_pkcs15_delete_file:
   75|     16|{
   76|     16|	struct sc_context *ctx = p15card->card->ctx;
   77|     16|	struct sc_card *card = p15card->card;
   78|     16|	struct sc_path  path;
   79|     16|	unsigned long caps = card->caps;
   80|     16|	int rv = 0;
   81|       |
   82|     16|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   83|       |
   84|     16|	sc_log(ctx, "iasecc_pkcs15_delete_file() id %04X\n", df->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__
  |  |  ------------------
  ------------------
   85|       |
   86|     16|	card->caps |= SC_CARD_CAP_USE_FCI_AC;
  ------------------
  |  |  564|     16|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
   87|     16|	rv = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     16|#define SC_AC_OP_DELETE			2
  ------------------
   88|     16|	card->caps = caps;
   89|       |
   90|     16|	LOG_TEST_RET(ctx, rv, "Cannot authenticate SC_AC_OP_DELETE");
  ------------------
  |  |  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: 4, False: 12]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 12]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|       |
   92|     12|	memset(&path, 0, sizeof(path));
   93|     12|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     12|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
   94|     12|	path.value[0] = df->id >> 8;
   95|     12|	path.value[1] = df->id & 0xFF;
   96|     12|	path.len = 2;
   97|       |
   98|     12|	rv = sc_delete_file(card, &path);
   99|     12|	LOG_FUNC_RETURN(ctx, 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: 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|      9|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  100|     12|}
sc_pkcs15init_get_iasecc_ops:
 1898|    207|{
 1899|    207|	return &sc_pkcs15init_iasecc_operations;
 1900|    207|}
pkcs15-iasecc.c:iasecc_pkcs15_erase_card:
  109|    156|{
  110|    156|	struct sc_context *ctx = p15card->card->ctx;
  111|    156|	struct sc_file  *file = NULL;
  112|    156|	struct sc_path  path;
  113|    156|	struct sc_pkcs15_df *df;
  114|    156|	int rv;
  115|       |
  116|    156|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    156|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    156|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    156|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    156|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 156]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  117|       |
  118|    156|	if (p15card->app && p15card->app->ddo.aid.len)   {
  ------------------
  |  Branch (118:6): [True: 0, False: 156]
  |  Branch (118:22): [True: 0, False: 0]
  ------------------
  119|      0|		memset(&path, 0, sizeof(struct sc_path));
  120|      0|		path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  121|      0|		memcpy(path.value, p15card->app->ddo.aid.value, p15card->app->ddo.aid.len);
  122|      0|		path.len = p15card->app->ddo.aid.len;
  123|       |
  124|      0|		sc_log(ctx, "Select DDO AID: %s", 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__
  |  |  ------------------
  ------------------
  125|      0|		rv = sc_select_file(p15card->card, &path, NULL);
  126|      0|		LOG_TEST_RET(ctx, rv, "Erase application error: cannot select DDO AID");
  ------------------
  |  |  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|      0|	}
  128|       |
  129|    156|	for (df = p15card->df_list; df; df = df->next)   {
  ------------------
  |  Branch (129:30): [True: 0, False: 156]
  ------------------
  130|      0|		struct sc_pkcs15_object *objs[32];
  131|      0|		unsigned obj_type = 0;
  132|      0|		int ii;
  133|       |
  134|      0|		if (df->type == SC_PKCS15_PRKDF)
  ------------------
  |  |  488|      0|#define SC_PKCS15_PRKDF			0
  ------------------
  |  Branch (134:7): [True: 0, False: 0]
  ------------------
  135|      0|			obj_type = SC_PKCS15_TYPE_PRKEY;
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  136|      0|		else if (df->type == SC_PKCS15_PUKDF)
  ------------------
  |  |  489|      0|#define SC_PKCS15_PUKDF			1
  ------------------
  |  Branch (136:12): [True: 0, False: 0]
  ------------------
  137|      0|			obj_type = SC_PKCS15_TYPE_PUBKEY;
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  138|      0|		else if (df->type == SC_PKCS15_CDF)
  ------------------
  |  |  492|      0|#define SC_PKCS15_CDF			4
  ------------------
  |  Branch (138:12): [True: 0, False: 0]
  ------------------
  139|      0|			obj_type = SC_PKCS15_TYPE_CERT;
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  140|      0|		else if (df->type == SC_PKCS15_DODF)
  ------------------
  |  |  495|      0|#define SC_PKCS15_DODF			7
  ------------------
  |  Branch (140:12): [True: 0, False: 0]
  ------------------
  141|      0|			obj_type = SC_PKCS15_TYPE_DATA_OBJECT;
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  142|      0|		else
  143|      0|			continue;
  144|       |
  145|      0|		rv = sc_pkcs15_get_objects(p15card, obj_type, objs, 32);
  146|      0|		LOG_TEST_RET(ctx, rv, "Failed to get PKCS#15 objects to remove");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  147|       |
  148|      0|		for (ii=0; ii<rv; ii++)   {
  ------------------
  |  Branch (148:14): [True: 0, False: 0]
  ------------------
  149|      0|			if (obj_type == SC_PKCS15_TYPE_CERT)   {
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (149:8): [True: 0, False: 0]
  ------------------
  150|      0|				struct sc_path path = ((struct sc_pkcs15_cert_info *)(objs[ii]->data))->path;
  151|      0|				rv = sc_delete_file(p15card->card, &path);
  152|      0|			}
  153|      0|			else if (obj_type == SC_PKCS15_TYPE_DATA_OBJECT)   {
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (153:13): [True: 0, False: 0]
  ------------------
  154|      0|				struct sc_path path = ((struct sc_pkcs15_data_info *)(objs[ii]->data))->path;
  155|      0|				rv = sc_delete_file(p15card->card, &path);
  156|      0|			}
  157|       |
  158|      0|			sc_pkcs15_remove_object(p15card, objs[ii]);
  159|      0|			sc_pkcs15_free_object(objs[ii]);
  160|      0|		}
  161|       |
  162|      0|		rv = sc_select_file(p15card->card, &df->path, &file);
  163|      0|		if (rv == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (163:7): [True: 0, False: 0]
  ------------------
  164|      0|			continue;
  165|      0|		LOG_TEST_RET(ctx, rv, "Cannot select object 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|       |
  167|      0|		profile->dirty = 1;
  168|       |
  169|      0|		rv = sc_erase_binary(p15card->card, 0, file->size, 0);
  170|      0|		if (rv == SC_ERROR_SECURITY_STATUS_NOT_SATISFIED)   {
  ------------------
  |  |   61|      0|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
  |  Branch (170:7): [True: 0, False: 0]
  ------------------
  171|      0|			rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  172|      0|			LOG_TEST_RET(ctx, rv, "SC_AC_OP_UPDATE authentication 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  173|       |
  174|      0|			rv = sc_erase_binary(p15card->card, 0, file->size, 0);
  175|      0|		}
  176|      0|		LOG_TEST_RET(ctx, rv, "Binary erase 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  177|       |
  178|      0|		sc_file_free(file);
  179|      0|	}
  180|       |
  181|    156|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    156|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    156|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    156|	int _ret = r; \
  |  |  |  |  155|    156|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 156, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    156|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 156]
  |  |  |  |  ------------------
  |  |  |  |  157|    156|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    156|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    156|	return _ret; \
  |  |  |  |  163|    156|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  182|    156|}
pkcs15-iasecc.c:iasecc_pkcs15_select_key_reference:
  259|    155|{
  260|    155|	struct sc_context *ctx = p15card->card->ctx;
  261|    155|	struct sc_card *card = p15card->card;
  262|    155|	struct sc_file  *file = NULL;
  263|    155|	int rv = 0, idx = key_info->key_reference & ~IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|    155|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  264|       |
  265|    155|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    155|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    155|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    155|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    155|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 155]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  266|    155|	sc_log(ctx, "'seed' key reference %i; path %s", key_info->key_reference & ~IASECC_OBJECT_REF_LOCAL,
  ------------------
  |  |   71|    155|#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)
  |  |  ------------------
  |  |  |  |  266|    155|	sc_log(ctx, "'seed' key reference %i; path %s", key_info->key_reference & ~IASECC_OBJECT_REF_LOCAL,
  |  |  |  |  ------------------
  |  |  |  |  |  |   59|    155|#define IASECC_OBJECT_REF_LOCAL		0x80
  |  |  |  |  ------------------
  |  |  |  |  267|    155|			sc_print_path(&key_info->path));
  |  |  ------------------
  ------------------
  267|    155|			sc_print_path(&key_info->path));
  268|       |
  269|    155|	rv = sc_select_file(card, &key_info->path, &file);
  270|    155|	sc_file_free(file);
  271|    155|	LOG_TEST_RET(ctx, rv, "Cannot select DF to select key reference in");
  ------------------
  |  |  174|    155|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    155|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    155|	int _ret = (r); \
  |  |  |  |  168|    155|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 150, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  169|    150|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    150|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    150|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    150|		return _ret; \
  |  |  |  |  172|    150|	} \
  |  |  |  |  173|    155|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  272|       |
  273|       |	/* 1 <= ObjReference <= 31 */
  274|      5|	if (idx < IASECC_OBJECT_REF_MIN)
  ------------------
  |  |   62|      5|#define IASECC_OBJECT_REF_MIN	0x01
  ------------------
  |  Branch (274:6): [True: 5, False: 0]
  ------------------
  275|      5|		idx = IASECC_OBJECT_REF_MIN;
  ------------------
  |  |   62|      5|#define IASECC_OBJECT_REF_MIN	0x01
  ------------------
  276|       |
  277|       |	/* Look for the suitable slot */
  278|      5|	if (idx <= IASECC_OBJECT_REF_MAX)   {
  ------------------
  |  |   63|      5|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (278:6): [True: 5, False: 0]
  ------------------
  279|      5|		struct iasecc_ctl_get_free_reference ctl_data;
  280|       |
  281|      5|		ctl_data.key_size = key_info->modulus_length;
  282|      5|		ctl_data.usage = key_info->usage;
  283|      5|		ctl_data.access = key_info->access_flags;
  284|      5|		ctl_data.index = idx;
  285|       |
  286|      5|		rv = sc_card_ctl(card, SC_CARDCTL_IASECC_GET_FREE_KEY_REFERENCE, &ctl_data);
  287|      5|		if (!rv)
  ------------------
  |  Branch (287:7): [True: 3, False: 2]
  ------------------
  288|      3|			sc_log(ctx, "found allocated slot %i", idx);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  289|      2|		else if (rv == SC_ERROR_DATA_OBJECT_NOT_FOUND && idx <= IASECC_OBJECT_REF_MAX)
  ------------------
  |  |   66|      4|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
              		else if (rv == SC_ERROR_DATA_OBJECT_NOT_FOUND && idx <= IASECC_OBJECT_REF_MAX)
  ------------------
  |  |   63|      0|#define IASECC_OBJECT_REF_MAX	0x1F
  ------------------
  |  Branch (289:12): [True: 0, False: 2]
  |  Branch (289:52): [True: 0, False: 0]
  ------------------
  290|      0|			sc_log(ctx, "found empty slot %i", 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__
  |  |  ------------------
  ------------------
  291|      2|		else
  292|      2|			LOG_TEST_RET(ctx, rv, "Cannot select key reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|       |
  294|      3|		idx = ctl_data.index;
  295|      3|	}
  296|       |
  297|       |	/* All card objects but PINs are locals */
  298|      3|	key_info->key_reference = idx | IASECC_OBJECT_REF_LOCAL;
  ------------------
  |  |   59|      3|#define IASECC_OBJECT_REF_LOCAL		0x80
  ------------------
  299|      3|	sc_log(ctx, "selected key reference %i", key_info->key_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  300|       |
  301|      3|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|      3|}
pkcs15-iasecc.c:iasecc_pkcs15_create_key:
 1064|      3|{
 1065|      3|	struct sc_card *card = p15card->card;
 1066|      3|	struct sc_context *ctx = card->ctx;
 1067|      3|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *) object->data;
 1068|      3|	struct iasecc_sdo *sdo_prvkey = NULL, *sdo_pubkey = NULL;
 1069|      3|	size_t keybits = key_info->modulus_length;
 1070|      3|	unsigned char zeros[0x200];
 1071|      3|	int	 rv;
 1072|       |
 1073|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1074|      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__
  |  |  ------------------
  ------------------
 1075|      3|	       "create private key(keybits:%"SC_FORMAT_LEN_SIZE_T"u,usage:%X,access:%X,ref:%X)",
 1076|      3|	       keybits, key_info->usage, key_info->access_flags,
 1077|      3|	       key_info->key_reference);
 1078|      3|	if (keybits < 1024 || keybits > 2048 || (keybits % 256))   {
  ------------------
  |  Branch (1078:6): [True: 0, False: 3]
  |  Branch (1078:24): [True: 0, False: 3]
  |  Branch (1078:42): [True: 0, False: 3]
  ------------------
 1079|      0|		sc_log(ctx, "Unsupported key size %"SC_FORMAT_LEN_SIZE_T"u",
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1080|      0|		       keybits);
 1081|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1082|      0|	}
 1083|       |
 1084|      3|	memset(zeros, 0, sizeof(zeros));
 1085|       |
 1086|      3|	rv = iasecc_sdo_allocate_pubkey(profile, card, (struct sc_pkcs15_pubkey_info *)key_info, &sdo_pubkey);
 1087|      3|	LOG_TEST_RET(ctx, rv, "IasEcc: allocate SDO public key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1088|      0|	sc_log(ctx, "iasecc_pkcs15_create_key() sdo_pubkey->not_on_card %i", sdo_pubkey->not_on_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__
  |  |  ------------------
  ------------------
 1089|       |
 1090|      0|	rv = iasecc_sdo_allocate_prvkey(profile, card, key_info, &sdo_prvkey);
 1091|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "IasEcc: init SDO private key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1092|      0|	sc_log(ctx, "iasecc_pkcs15_create_key() sdo_prvkey->not_on_card %i", sdo_prvkey->not_on_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__
  |  |  ------------------
  ------------------
 1093|       |
 1094|      0|	if (!sdo_prvkey->not_on_card && !sdo_pubkey->not_on_card)   {
  ------------------
  |  Branch (1094:6): [True: 0, False: 0]
  |  Branch (1094:34): [True: 0, False: 0]
  ------------------
 1095|      0|		sc_log(ctx, "Key ref %i already allocated", key_info->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__
  |  |  ------------------
  ------------------
 1096|      0|	}
 1097|      0|	else   {
 1098|      0|		rv = iasecc_pkcs15_create_key_slot(profile, p15card, sdo_prvkey, sdo_pubkey, key_info);
 1099|      0|		LOG_TEST_GOTO_ERR(ctx, rv, "Cannot create key slot");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1100|      0|	}
 1101|       |
 1102|      0|	rv = sc_pkcs15_allocate_object_content(ctx, object, (unsigned char *)sdo_prvkey, sizeof(struct iasecc_sdo));
 1103|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "Failed to allocate PrvKey SDO as object content");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1104|       |
 1105|      0|	rv = iasecc_pkcs15_fix_private_key_attributes(profile, p15card, object, (struct iasecc_sdo *)object->content.value);
 1106|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "Failed to fix private key PKCS#15 attributes");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1107|       |
 1108|      0|	key_info->path.len = 0;
 1109|       |
 1110|      0|err:
 1111|      0|	iasecc_sdo_free(card, sdo_pubkey);
 1112|      0|	iasecc_sdo_free(card, sdo_prvkey);
 1113|       |
 1114|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1115|      0|}
pkcs15-iasecc.c:iasecc_sdo_allocate_pubkey:
  531|      3|{
  532|      3|	struct sc_context *ctx = card->ctx;
  533|      3|	struct iasecc_sdo *sdo = NULL;
  534|      3|	size_t sz = key_info->modulus_length / 8;
  535|      3|	int rv;
  536|       |
  537|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  538|      3|	sdo = calloc(1, sizeof(struct iasecc_sdo));
  539|      3|	if (!sdo)
  ------------------
  |  Branch (539:6): [True: 0, False: 3]
  ------------------
  540|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  541|       |
  542|      3|	sdo->magic = SC_CARDCTL_IASECC_SDO_MAGIC;
  543|      3|	sdo->sdo_ref = key_info->key_reference & 0x3F;
  544|      3|	sdo->sdo_class = IASECC_SDO_CLASS_RSA_PUBLIC;
  ------------------
  |  |  101|      3|#define IASECC_SDO_CLASS_RSA_PUBLIC	0x20
  ------------------
  545|       |
  546|      3|	rv = iasecc_sdo_get_data(card, sdo);
  547|      3|	sc_log(ctx, "get Public Key SDO(class:%X) data returned %i", sdo->sdo_class, rv);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  548|      3|	if (rv == SC_ERROR_DATA_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   66|      3|#define SC_ERROR_DATA_OBJECT_NOT_FOUND		-1216
  ------------------
  |  Branch (548:6): [True: 1, False: 2]
  ------------------
  549|      1|		sdo->not_on_card = 1;
  550|       |
  551|      1|		rv = iasecc_sdo_set_key_acls_from_profile(profile, card, "public-key", sdo);
  552|      1|		if (rv != SC_SUCCESS)
  ------------------
  |  |   28|      1|#define SC_SUCCESS				0
  ------------------
  |  Branch (552:7): [True: 1, False: 0]
  ------------------
  553|      1|			iasecc_sdo_free(card, sdo);
  554|      1|		LOG_TEST_RET(ctx, rv, "iasecc_sdo_allocate_pubkey() cannot set ACLs for SDO from the 'public-key'");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  555|       |
  556|      0|		sdo->docp.size.value = calloc(1, 2);
  557|      0|		if (!sdo->docp.size.value)   {
  ------------------
  |  Branch (557:7): [True: 0, False: 0]
  ------------------
  558|      0|			iasecc_sdo_free(card, sdo);
  559|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  560|      0|		}
  561|      0|		sdo->docp.size.size = 2;
  562|      0|		sdo->docp.size.tag = IASECC_DOCP_TAG_SIZE;
  ------------------
  |  |   38|      0|#define IASECC_DOCP_TAG_SIZE			0x80
  ------------------
  563|      0|		*(sdo->docp.size.value + 0) = (sz >> 8) & 0xFF;
  564|      0|		*(sdo->docp.size.value + 1) = sz & 0xFF;
  565|       |
  566|      0|		if (card->type == SC_CARD_TYPE_IASECC_OBERTHUR)   {
  ------------------
  |  Branch (566:7): [True: 0, False: 0]
  ------------------
  567|       |			/* TODO: Disabled for the tests of the Oberthur card */
  568|      0|		}
  569|      0|		else   {
  570|      0|			sdo->data.pub_key.cha.value = calloc(1, 2);
  571|      0|			if (!sdo->data.pub_key.cha.value)   {
  ------------------
  |  Branch (571:8): [True: 0, False: 0]
  ------------------
  572|      0|				iasecc_sdo_free(card, sdo);
  573|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  574|      0|			}
  575|      0|			sdo->data.pub_key.cha.size = 2;
  576|      0|			sdo->data.pub_key.cha.tag = IASECC_SDO_PUBKEY_TAG_CHA;
  ------------------
  |  |   81|      0|#define IASECC_SDO_PUBKEY_TAG_CHA		0x5F4C
  ------------------
  577|      0|		}
  578|       |
  579|      0|		sdo->data.pub_key.compulsory.value = calloc(1, 1);
  580|      0|		if (!sdo->data.pub_key.compulsory.value)   {
  ------------------
  |  Branch (580:7): [True: 0, False: 0]
  ------------------
  581|      0|			iasecc_sdo_free(card, sdo);
  582|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  583|      0|		}
  584|      0|		sdo->data.pub_key.compulsory.tag = IASECC_SDO_PUBKEY_TAG_COMPULSORY;
  ------------------
  |  |   79|      0|#define IASECC_SDO_PUBKEY_TAG_COMPULSORY	0x80
  ------------------
  585|      0|		sdo->data.pub_key.compulsory.size = 1;
  586|      0|	}
  587|      2|	else if (rv < 0) {
  ------------------
  |  Branch (587:11): [True: 2, False: 0]
  ------------------
  588|      2|		iasecc_sdo_free(card, sdo);
  589|      2|		LOG_TEST_RET(ctx, rv, "iasecc_sdo_allocate_pubkey() error while getting public key SDO data");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  590|      2|	}
  591|       |
  592|      0|	if (out)
  ------------------
  |  Branch (592:6): [True: 0, False: 0]
  ------------------
  593|      0|		*out = sdo;
  594|      0|	else
  595|      0|		iasecc_sdo_free(card, sdo);
  596|       |
  597|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  598|      0|}
pkcs15-iasecc.c:iasecc_sdo_get_data:
  307|      3|{
  308|      3|	struct sc_context *ctx = card->ctx;
  309|      3|	int rv;
  310|       |
  311|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  312|      3|	rv = sc_card_ctl(card, SC_CARDCTL_IASECC_SDO_GET_DATA, sdo);
  313|      3|	LOG_TEST_RET(ctx, rv, "IasEcc: GET DATA 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  314|       |
  315|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  316|      0|}
pkcs15-iasecc.c:iasecc_sdo_set_key_acls_from_profile:
  354|      1|{
  355|      1|	struct sc_context *ctx = card->ctx;
  356|      1|	struct sc_file  *file = NULL;
  357|      1|	unsigned char ops_prvkey[7] = {
  358|      1|		SC_AC_OP_PSO_COMPUTE_SIGNATURE, SC_AC_OP_INTERNAL_AUTHENTICATE, SC_AC_OP_PSO_DECRYPT,
  ------------------
  |  |  177|      1|#define SC_AC_OP_PSO_COMPUTE_SIGNATURE	11
  ------------------
              		SC_AC_OP_PSO_COMPUTE_SIGNATURE, SC_AC_OP_INTERNAL_AUTHENTICATE, SC_AC_OP_PSO_DECRYPT,
  ------------------
  |  |  181|      1|#define SC_AC_OP_INTERNAL_AUTHENTICATE	15
  ------------------
              		SC_AC_OP_PSO_COMPUTE_SIGNATURE, SC_AC_OP_INTERNAL_AUTHENTICATE, SC_AC_OP_PSO_DECRYPT,
  ------------------
  |  |  175|      1|#define SC_AC_OP_PSO_DECRYPT		9
  ------------------
  359|      1|		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  192|      1|#define SC_AC_OP_GENERATE		26
  ------------------
              		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  188|      1|#define SC_AC_OP_READ			22
  ------------------
  360|      1|	};
  361|      1|	unsigned char ops_pubkey[7] = {
  362|      1|		0xFF, SC_AC_OP_EXTERNAL_AUTHENTICATE, 0xFF,
  ------------------
  |  |  182|      1|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
  363|      1|		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  192|      1|#define SC_AC_OP_GENERATE		26
  ------------------
              		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  189|      1|#define SC_AC_OP_UPDATE			23
  ------------------
              		SC_AC_OP_GENERATE, 0xFF, SC_AC_OP_UPDATE, SC_AC_OP_READ
  ------------------
  |  |  188|      1|#define SC_AC_OP_READ			22
  ------------------
  364|      1|	};
  365|      1|	unsigned char amb, scb[16], mask;
  366|      1|	int rv, ii, cntr;
  367|       |
  368|      1|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  369|       |
  370|       |	/* Get ACLs from profile template */
  371|      1|	rv = sc_profile_get_file(profile, template, &file);
  372|      1|	LOG_TEST_RET(ctx, rv, "IasEcc: cannot instantiate private key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  373|       |
  374|       |	/* Convert PKCS15 ACLs to SE ACLs */
  375|      0|	rv = iasecc_file_convert_acls(ctx, profile, file);
  376|      0|	if (rv < 0)
  ------------------
  |  Branch (376:6): [True: 0, False: 0]
  ------------------
  377|      0|		sc_file_free(file);
  378|      0|	LOG_TEST_RET(ctx, rv, "Cannot convert profile 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|       |
  380|      0|	memset(scb, 0, sizeof(scb));
  381|      0|	for (ii = 0, mask = 0x80, amb = 0x80, cntr = 0; ii < 7; ii++) {
  ------------------
  |  Branch (381:50): [True: 0, False: 0]
  ------------------
  382|      0|		const sc_acl_entry_t *acl;
  383|      0|		unsigned char op = sdo->sdo_class == IASECC_SDO_CLASS_RSA_PRIVATE ? ops_prvkey[ii] : ops_pubkey[ii];
  ------------------
  |  |  100|      0|#define IASECC_SDO_CLASS_RSA_PRIVATE	0x10
  ------------------
  |  Branch (383:22): [True: 0, False: 0]
  ------------------
  384|       |
  385|      0|		mask >>= 1;
  386|       |
  387|      0|		if (op == 0xFF)
  ------------------
  |  Branch (387:7): [True: 0, False: 0]
  ------------------
  388|      0|			continue;
  389|       |
  390|      0|		acl = sc_file_get_acl_entry(file, op);
  391|      0|		sc_log(ctx, "ACL: 0x%X:0x%X", acl->method, acl->key_ref);
  ------------------
  |  |   71|      0|#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|       |
  393|      0|		if (acl->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (393:7): [True: 0, False: 0]
  ------------------
  394|      0|		}
  395|      0|		else if (acl->method == SC_AC_NONE)   {
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (395:12): [True: 0, False: 0]
  ------------------
  396|      0|			amb |= mask;
  397|      0|			scb[cntr++] = 0x00;
  398|      0|		}
  399|      0|		else if (acl->method == SC_AC_SEN || acl->method == SC_AC_PRO || acl->method == SC_AC_AUT)   {
  ------------------
  |  |  156|      0|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
              		else if (acl->method == SC_AC_SEN || acl->method == SC_AC_PRO || acl->method == SC_AC_AUT)   {
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
              		else if (acl->method == SC_AC_SEN || acl->method == SC_AC_PRO || acl->method == SC_AC_AUT)   {
  ------------------
  |  |  154|      0|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (399:12): [True: 0, False: 0]
  |  Branch (399:40): [True: 0, False: 0]
  |  Branch (399:68): [True: 0, False: 0]
  ------------------
  400|      0|			if ((acl->key_ref & 0xF) == 0 || (acl->key_ref & 0xF) == 0xF)   {
  ------------------
  |  Branch (400:8): [True: 0, False: 0]
  |  Branch (400:37): [True: 0, False: 0]
  ------------------
  401|      0|				sc_file_free(file);
  402|      0|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid SE reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  403|      0|			}
  404|       |
  405|      0|			amb |= mask;
  406|       |
  407|      0|			if (acl->method == SC_AC_SEN)
  ------------------
  |  |  156|      0|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (407:8): [True: 0, False: 0]
  ------------------
  408|      0|				scb[cntr++] = acl->key_ref | IASECC_SCB_METHOD_USER_AUTH;
  ------------------
  |  |   93|      0|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
  409|      0|			else if (acl->method == SC_AC_PRO)
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (409:13): [True: 0, False: 0]
  ------------------
  410|      0|				scb[cntr++] = acl->key_ref | IASECC_SCB_METHOD_SM;
  ------------------
  |  |   91|      0|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  411|      0|			else
  412|      0|				scb[cntr++] = acl->key_ref | IASECC_SCB_METHOD_EXT_AUTH;
  ------------------
  |  |   92|      0|#define IASECC_SCB_METHOD_EXT_AUTH	0x20
  ------------------
  413|      0|		}
  414|      0|		else   {
  415|      0|			sc_file_free(file);
  416|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Unknown SCB method");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  417|      0|		}
  418|      0|	}
  419|       |
  420|      0|	sc_file_free(file);
  421|       |
  422|       |	/* Copy ACLs into the DOCP*/
  423|      0|	sdo->docp.acls_contact.tag = IASECC_DOCP_TAG_ACLS_CONTACT;
  ------------------
  |  |   40|      0|#define IASECC_DOCP_TAG_ACLS_CONTACT		0x8C
  ------------------
  424|      0|	sdo->docp.acls_contact.size = cntr + 1;
  425|      0|	sdo->docp.acls_contact.value = calloc(1, sdo->docp.acls_contact.size);
  426|      0|	if (!sdo->docp.acls_contact.value)
  ------------------
  |  Branch (426:6): [True: 0, False: 0]
  ------------------
  427|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  428|      0|	*(sdo->docp.acls_contact.value + 0) = amb;
  429|      0|	memcpy(sdo->docp.acls_contact.value + 1, scb, cntr);
  430|       |
  431|      0|	sc_log(ctx, "AMB: %X, CNTR %i, %x %x %x %x %x %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__
  |  |  ------------------
  ------------------
  432|      0|	       amb, cntr, scb[0], scb[1], scb[2], scb[3], scb[4], scb[5], scb[6]);
  433|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  434|      0|}
pkcs15-iasecc.c:iasecc_file_convert_acls:
  321|     28|{
  322|     28|	int ii;
  323|       |
  324|    896|	for (ii=0; ii<SC_MAX_AC_OPS;ii++)   {
  ------------------
  |  |  198|    896|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (324:13): [True: 868, False: 28]
  ------------------
  325|       |		/* FIXME the acl object must not be modified, it is only defined in
  326|       |		 * sc_file_get_acl_entry. Accessing it here means we have a race
  327|       |		 * condition. */
  328|    868|		struct sc_acl_entry *acl = (struct sc_acl_entry *) sc_file_get_acl_entry(file, ii);
  329|       |
  330|    868|		if (acl)   {
  ------------------
  |  Branch (330:7): [True: 868, False: 0]
  ------------------
  331|    868|			switch (acl->method)   {
  ------------------
  |  Branch (331:12): [True: 0, False: 868]
  ------------------
  332|      0|			case SC_AC_IDA:
  ------------------
  |  |  158|      0|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (332:4): [True: 0, False: 868]
  ------------------
  333|      0|				sc_log(ctx, "'IDA' not actually supported");
  ------------------
  |  |   71|      0|#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|				return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  335|      0|			case SC_AC_SCB:
  ------------------
  |  |  157|      0|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (335:4): [True: 0, False: 868]
  ------------------
  336|      0|				if ((acl->key_ref & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   89|      0|#define IASECC_SCB_METHOD_MASK		0x70
  ------------------
              				if ((acl->key_ref & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_USER_AUTH)   {
  ------------------
  |  |   93|      0|#define IASECC_SCB_METHOD_USER_AUTH	0x10
  ------------------
  |  Branch (336:9): [True: 0, False: 0]
  ------------------
  337|      0|					acl->method = SC_AC_SEN;
  ------------------
  |  |  156|      0|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  338|      0|					acl->key_ref &= IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      0|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
  339|      0|				}
  340|      0|				else if ((acl->key_ref & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_SM)   {
  ------------------
  |  |   89|      0|#define IASECC_SCB_METHOD_MASK		0x70
  ------------------
              				else if ((acl->key_ref & IASECC_SCB_METHOD_MASK) == IASECC_SCB_METHOD_SM)   {
  ------------------
  |  |   91|      0|#define IASECC_SCB_METHOD_SM		0x40
  ------------------
  |  Branch (340:14): [True: 0, False: 0]
  ------------------
  341|      0|					acl->method = SC_AC_PRO;
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  342|      0|					acl->key_ref &= IASECC_SCB_METHOD_MASK_REF;
  ------------------
  |  |   90|      0|#define IASECC_SCB_METHOD_MASK_REF	0x0F
  ------------------
  343|      0|				}
  344|    868|			}
  345|    868|		}
  346|    868|	}
  347|       |
  348|     28|	return 0;
  349|     28|}
pkcs15-iasecc.c:iasecc_pkcs15_new_file:
  191|    156|{
  192|    156|	struct sc_context *ctx = card->ctx;
  193|    156|	struct sc_file	*file = NULL;
  194|    156|	const char *_template = NULL;
  195|    156|	int rv;
  196|       |
  197|    156|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    156|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    156|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    156|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    156|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 156]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|    156|	sc_log(ctx, "type %X; num %i\n", type, num);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  199|    156|	switch (type) {
  200|      0|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (200:3): [True: 0, False: 156]
  ------------------
  201|      0|			_template = "private-key";
  202|      0|			break;
  203|      0|		case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (203:3): [True: 0, False: 156]
  ------------------
  204|      0|			_template = "public-key";
  205|      0|			break;
  206|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (206:3): [True: 0, False: 156]
  ------------------
  207|      0|			_template = "certificate";
  208|      0|			break;
  209|    156|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|    156|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (209:3): [True: 156, False: 0]
  ------------------
  210|    156|			_template = "public-data";
  211|    156|			break;
  212|      0|		default:
  ------------------
  |  Branch (212:3): [True: 0, False: 156]
  ------------------
  213|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Profile template 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  214|    156|	}
  215|       |
  216|    156|	sc_log(ctx, "df_info path '%s'\n", sc_print_path(&profile->df_info->file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  217|    156|	rv = sc_profile_get_file(profile, _template, &file);
  218|    156|	if (rv == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|    156|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (218:6): [True: 128, False: 28]
  ------------------
  219|    128|		struct sc_pkcs15_id     id;
  220|       |
  221|    128|		id.len = 1;
  222|    128|		id.value[0] = num & 0xFF;
  223|    128|		rv = sc_profile_instantiate_template(profile, "key-domain", &profile->df_info->file->path,
  224|    128|				_template, &id, &file);
  225|    128|	}
  226|    156|	LOG_TEST_RET(ctx, rv, "Error when getting file from template");
  ------------------
  |  |  174|    156|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    156|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    156|	int _ret = (r); \
  |  |  |  |  168|    156|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 128, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  169|    128|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    128|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    128|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    128|		return _ret; \
  |  |  |  |  172|    128|	} \
  |  |  |  |  173|    156|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  227|       |
  228|     28|	sc_log(ctx, "path(type:%X;path:%s)\n", file->path.type, sc_print_path(&file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  229|       |
  230|     28|	file->id = (file->id & 0xFF00) | (num & 0xFF);
  231|     28|	if (file->path.len == 0)   {
  ------------------
  |  Branch (231:6): [True: 24, False: 4]
  ------------------
  232|     24|		file->path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     24|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  233|     24|		file->path.len = 2;
  234|     24|	}
  235|     28|	file->path.value[file->path.len - 2] = (file->id >> 8) & 0xFF;
  236|     28|	file->path.value[file->path.len - 1] = file->id & 0xFF;
  237|     28|	file->path.count = -1;
  238|       |
  239|     28|	sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  240|     28|	       "file size %"SC_FORMAT_LEN_SIZE_T"u; ef type %i/%i; id %04X\n",
  241|     28|	       file->size, file->type, file->ef_structure, file->id);
  242|     28|	sc_log(ctx, "path type %X; path '%s'", file->path.type, sc_print_path(&file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  243|       |
  244|     28|	if (out)
  ------------------
  |  Branch (244:6): [True: 28, False: 0]
  ------------------
  245|     28|		*out = file;
  246|      0|	else
  247|      0|		sc_file_free(file);
  248|       |
  249|     28|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  250|     28|}
pkcs15-iasecc.c:iasecc_emu_store_data:
 1843|    156|{
 1844|    156|	struct sc_context *ctx = p15card->card->ctx;
 1845|    156|	int rv = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|    156|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
 1846|       |
 1847|    156|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    156|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    156|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    156|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    156|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 156]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1848|       |
 1849|    156|	switch (object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    156|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 1850|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1850:2): [True: 0, False: 156]
  ------------------
 1851|      0|		rv = iasecc_store_prvkey(p15card, profile, object, data, path);
 1852|      0|		break;
 1853|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (1853:2): [True: 0, False: 156]
  ------------------
 1854|      0|		rv = iasecc_store_pubkey(p15card, profile, object, data, path);
 1855|      0|		break;
 1856|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (1856:2): [True: 0, False: 156]
  ------------------
 1857|      0|		rv = iasecc_store_cert(p15card, profile, object, data, path);
 1858|      0|		break;
 1859|    156|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|    156|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (1859:2): [True: 156, False: 0]
  ------------------
 1860|    156|		rv = iasecc_store_data_object(p15card, profile, object, data, path);
 1861|    156|		break;
 1862|      0|	default:
  ------------------
  |  Branch (1862:2): [True: 0, False: 156]
  ------------------
 1863|      0|		rv = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
 1864|      0|		break;
 1865|    156|	}
 1866|       |
 1867|    156|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    156|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    156|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    156|	int _ret = r; \
  |  |  |  |  155|    156|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 156, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    156|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    156|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 156, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    156|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    156|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    156|	return _ret; \
  |  |  |  |  163|    156|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1868|    156|}
pkcs15-iasecc.c:iasecc_store_data_object:
 1731|    156|{
 1732|    156|#define MAX_DATA_OBJS 32
 1733|    156|	struct sc_context *ctx = p15card->card->ctx;
 1734|    156|	struct sc_card *card = p15card->card;
 1735|    156|	struct sc_pkcs15_object *p15objects[MAX_DATA_OBJS];
 1736|    156|	struct sc_file *cfile = NULL, *file = NULL, *parent = NULL;
 1737|    156|	int rv, nn_objs, index, ii;
 1738|       |
 1739|    156|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    156|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    156|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    156|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    156|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 156]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1740|    156|	sc_log(ctx, "iasecc_store_data_object() authID '%s'", sc_pkcs15_print_id(&object->auth_id));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1741|    156|	nn_objs = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT, p15objects, MAX_DATA_OBJS);
  ------------------
  |  |  442|    156|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
              	nn_objs = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT, p15objects, MAX_DATA_OBJS);
  ------------------
  |  | 1732|    156|#define MAX_DATA_OBJS 32
  ------------------
 1742|    156|	LOG_TEST_RET(ctx, nn_objs, "IasEcc get pkcs15 DATA objects error");
  ------------------
  |  |  174|    156|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    156|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    156|	int _ret = (r); \
  |  |  |  |  168|    156|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 156]
  |  |  |  |  ------------------
  |  |  |  |  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|    156|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 156]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1743|       |
 1744|    156|	for(index = 1; index < MAX_DATA_OBJS; index++)   {
  ------------------
  |  | 1732|    156|#define MAX_DATA_OBJS 32
  ------------------
  |  Branch (1744:17): [True: 156, False: 0]
  ------------------
 1745|    156|		rv = iasecc_pkcs15_new_file(profile, card, SC_PKCS15_TYPE_DATA_OBJECT, index, &file);
  ------------------
  |  |  442|    156|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 1746|    156|		LOG_TEST_RET(ctx, rv, "iasecc_store_data_object() pkcs15 new DATA file error");
  ------------------
  |  |  174|    156|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    156|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    156|	int _ret = (r); \
  |  |  |  |  168|    156|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 128, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  169|    128|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    128|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    128|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    128|		return _ret; \
  |  |  |  |  172|    128|	} \
  |  |  |  |  173|    156|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1747|       |
 1748|     28|		for (ii=0; ii<nn_objs; ii++)   {
  ------------------
  |  Branch (1748:14): [True: 0, False: 28]
  ------------------
 1749|      0|			struct sc_pkcs15_data_info *info = (struct sc_pkcs15_data_info *)p15objects[ii]->data;
 1750|      0|			int file_id = info->path.value[info->path.len - 2] * 0x100 + info->path.value[info->path.len - 1];
 1751|       |
 1752|      0|			sc_log(ctx, "iasecc_store_data_object() %i: file_id 0x%X, pfile->id 0x%X\n", ii, file_id, file->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|			if (file->id == file_id)
  ------------------
  |  Branch (1753:8): [True: 0, False: 0]
  ------------------
 1754|      0|			   break;
 1755|      0|		}
 1756|       |
 1757|     28|		if (ii == nn_objs)
  ------------------
  |  Branch (1757:7): [True: 28, False: 0]
  ------------------
 1758|     28|			break;
 1759|      0|		sc_file_free(file);
 1760|      0|		file = NULL;
 1761|      0|	}
 1762|       |
 1763|     28|	if (index == MAX_DATA_OBJS)
  ------------------
  |  | 1732|     28|#define MAX_DATA_OBJS 32
  ------------------
  |  Branch (1763:6): [True: 0, False: 28]
  ------------------
 1764|     28|		LOG_TEST_GOTO_ERR(ctx, SC_ERROR_TOO_MANY_OBJECTS, "iasecc_store_data_object() too many DATA objects.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1765|       |
 1766|     28|	do  {
 1767|     28|		const struct sc_acl_entry *acl;
 1768|       |
 1769|     28|		memset(object->access_rules, 0, sizeof(object->access_rules));
 1770|       |
 1771|     28|		object->access_rules[0].access_mode = SC_PKCS15_ACCESS_RULE_MODE_READ;
  ------------------
  |  |  335|     28|#define SC_PKCS15_ACCESS_RULE_MODE_READ         0x01
  ------------------
 1772|     28|		acl = sc_file_get_acl_entry(file, SC_AC_OP_READ);
  ------------------
  |  |  188|     28|#define SC_AC_OP_READ			22
  ------------------
 1773|     28|		sc_log(ctx, "iasecc_store_data_object() READ method %i", acl->method);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1774|     28|		if (acl->method == SC_AC_IDA)
  ------------------
  |  |  158|     28|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (1774:7): [True: 0, False: 28]
  ------------------
 1775|      0|			iasecc_reference_to_pkcs15_id (acl->key_ref, &object->access_rules[0].auth_id);
 1776|       |
 1777|     28|		object->access_rules[1].access_mode = SC_PKCS15_ACCESS_RULE_MODE_UPDATE;
  ------------------
  |  |  336|     28|#define SC_PKCS15_ACCESS_RULE_MODE_UPDATE       0x02
  ------------------
 1778|     28|		acl = sc_file_get_acl_entry(file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     28|#define SC_AC_OP_UPDATE			23
  ------------------
 1779|     28|		sc_log(ctx, "iasecc_store_data_object() UPDATE method %i", acl->method);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1780|     28|		if (acl->method == SC_AC_IDA)
  ------------------
  |  |  158|     28|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (1780:7): [True: 0, False: 28]
  ------------------
 1781|      0|			iasecc_reference_to_pkcs15_id (acl->key_ref, &object->access_rules[1].auth_id);
 1782|       |
 1783|     28|		object->access_rules[2].access_mode = SC_PKCS15_ACCESS_RULE_MODE_DELETE;
  ------------------
  |  |  338|     28|#define SC_PKCS15_ACCESS_RULE_MODE_DELETE       0x08
  ------------------
 1784|     28|		acl = sc_file_get_acl_entry(file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     28|#define SC_AC_OP_DELETE			2
  ------------------
 1785|     28|		sc_log(ctx, "iasecc_store_data_object() UPDATE method %i", acl->method);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1786|     28|		if (acl->method == SC_AC_IDA)
  ------------------
  |  |  158|     28|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (1786:7): [True: 0, False: 28]
  ------------------
 1787|      0|			iasecc_reference_to_pkcs15_id (acl->key_ref, &object->access_rules[2].auth_id);
 1788|       |
 1789|     28|	} while(0);
  ------------------
  |  Branch (1789:10): [Folded, False: 28]
  ------------------
 1790|       |
 1791|     28|	rv = iasecc_file_convert_acls(ctx, profile, file);
 1792|     28|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() cannot convert profile ACLs");
  ------------------
  |  |  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: 0, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  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|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1793|       |
 1794|     28|	rv = sc_profile_get_parent(profile, "public-data", &parent);
 1795|     28|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() cannot get object parent");
  ------------------
  |  |  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: 0, False: 28]
  |  |  |  |  ------------------
  |  |  |  |  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|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 28]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1796|     28|	sc_log(ctx, "iasecc_store_data_object() parent path '%s'\n", sc_print_path(&parent->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1797|       |
 1798|     28|	rv = sc_select_file(card, &parent->path, NULL);
 1799|     28|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() cannot select parent");
  ------------------
  |  |  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: 1, False: 27]
  |  |  |  |  ------------------
  |  |  |  |  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|     28|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 27]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1800|       |
 1801|     27|	rv = sc_select_file(card, &file->path, &cfile);
 1802|     27|	if (!rv)   {
  ------------------
  |  Branch (1802:6): [True: 22, False: 5]
  ------------------
 1803|     22|		rv = sc_pkcs15init_authenticate(profile, p15card, cfile, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     22|#define SC_AC_OP_DELETE			2
  ------------------
 1804|     22|		LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() DELETE authentication failed");
  ------------------
  |  |  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: 6, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1805|       |
 1806|     16|		rv = iasecc_pkcs15_delete_file(p15card, profile, cfile);
 1807|     16|		LOG_TEST_GOTO_ERR(ctx, rv, "s_pkcs15init_store_data_object() delete pkcs15 file error");
  ------------------
  |  |  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: 13, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     13|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     13|		goto err; \
  |  |  |  |  182|     13|	} \
  |  |  |  |  183|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1808|     16|	}
 1809|      5|	else if (rv != SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|      5|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (1809:11): [True: 5, False: 0]
  ------------------
 1810|      5|		LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() select file error");
  ------------------
  |  |  184|      5|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|      5|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|      5|	int _ret = (r); \
  |  |  |  |  178|      5|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 5, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|      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
  |  |  |  |  ------------------
  |  |  |  |  180|      5|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|      5|		goto err; \
  |  |  |  |  182|      5|	} \
  |  |  |  |  183|      5|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1811|      5|	}
 1812|       |
 1813|      3|	rv = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_CREATE);
  ------------------
  |  |  169|      3|#define SC_AC_OP_CREATE			3
  ------------------
 1814|      3|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() parent CREATE authentication failed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1815|       |
 1816|      0|	file->size = data->len;
 1817|      0|	rv = sc_create_file(card, file);
 1818|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() cannot create DATA 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1819|       |
 1820|      0|	rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
 1821|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() data file UPDATE authentication 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1822|       |
 1823|      0|	rv = sc_update_binary(card, 0, data->value, data->len, 0);
 1824|      0|	LOG_TEST_GOTO_ERR(ctx, rv, "iasecc_store_data_object() update DATA file 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1825|       |
 1826|      0|	if (path)
  ------------------
  |  Branch (1826:6): [True: 0, False: 0]
  ------------------
 1827|      0|		*path = file->path;
 1828|     28|err:
 1829|     28|	sc_file_free(parent);
 1830|     28|	sc_file_free(file);
 1831|     28|	sc_file_free(cfile);
 1832|       |
 1833|     28|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1834|     28|#undef MAX_DATA_OBJS
 1835|     28|}

sc_pkcs15init_get_isoApplet_ops:
  804|     93|{
  805|     93|	return &sc_pkcs15init_isoApplet_operations;
  806|     93|}
pkcs15-isoApplet.c:isoApplet_create_dir:
  183|     20|{
  184|     20|	sc_card_t *card = p15card->card;
  185|     20|	int r = SC_SUCCESS;
  ------------------
  |  |   28|     20|#define SC_SUCCESS				0
  ------------------
  186|       |
  187|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  188|       |
  189|     20|	if(!profile || !df || !p15card->card->ctx)
  ------------------
  |  Branch (189:5): [True: 0, False: 20]
  |  Branch (189:17): [True: 0, False: 20]
  |  Branch (189:24): [True: 0, False: 20]
  ------------------
  190|      0|	{
  191|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  192|      0|	}
  193|     20|	r = sc_pkcs15init_create_file(profile, p15card, df);
  194|     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|      2|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  195|     20|}
pkcs15-isoApplet.c:isoApplet_select_pin_reference:
  209|     98|{
  210|     98|	sc_card_t *card = p15card->card;
  211|     98|	int	preferred;
  212|     98|	int current;
  213|       |
  214|     98|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     98|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     98|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     98|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     98|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 98]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|       |
  216|     98|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     98|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (216:6): [True: 0, False: 98]
  ------------------
  217|      0|	{
  218|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  219|      0|	}
  220|       |
  221|     98|	current = auth_info->attrs.pin.reference;
  222|     98|	if (current < 0)
  ------------------
  |  Branch (222:6): [True: 82, False: 16]
  ------------------
  223|     82|	{
  224|     82|		current = 0;
  225|     82|	}
  226|       |
  227|     98|	if(current > 2)
  ------------------
  |  Branch (227:5): [True: 3, False: 95]
  ------------------
  228|      3|	{
  229|       |		/* Only two PINs supported: User PIN and PUK. */
  230|      3|		LOG_FUNC_RETURN(card->ctx, SC_ERROR_TOO_MANY_OBJECTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  231|      3|	}
  232|     95|	else
  233|     95|	{
  234|     95|		if(auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|     95|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (234:6): [True: 0, False: 95]
  ------------------
  235|      0|		{
  236|       |			/* PUK */
  237|      0|			preferred = 2;
  238|      0|		}
  239|     95|		else
  240|     95|		{
  241|       |			/* PIN */
  242|     95|			preferred = 1;
  243|     95|		}
  244|     95|	}
  245|       |
  246|     95|	auth_info->attrs.pin.reference = preferred;
  247|     95|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|     95|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     95|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     95|	int _ret = r; \
  |  |  |  |  155|     95|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 95, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     95|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 95]
  |  |  |  |  ------------------
  |  |  |  |  157|     95|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     95|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     95|	return _ret; \
  |  |  |  |  163|     95|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  248|     95|}
pkcs15-isoApplet.c:isoApplet_create_pin:
  260|     93|{
  261|     93|	sc_card_t *card = p15card->card;
  262|     93|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  263|     93|	struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
  264|     93|	int r;
  265|       |
  266|     93|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     93|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     93|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     93|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     93|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 93]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  267|       |
  268|     93|	if(!pin || !pin_len || !df)
  ------------------
  |  Branch (268:5): [True: 0, False: 93]
  |  Branch (268:13): [True: 0, False: 93]
  |  Branch (268:25): [True: 0, False: 93]
  ------------------
  269|      0|	{
  270|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  271|      0|	}
  272|       |
  273|     93|	if(pin_attrs->reference != 1 &&	pin_attrs->reference != 2)
  ------------------
  |  Branch (273:5): [True: 0, False: 93]
  |  Branch (273:34): [True: 0, False: 0]
  ------------------
  274|      0|	{
  275|       |		/* Reject PIN reference. */
  276|      0|		LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  277|      0|	}
  278|       |
  279|       |	/* If we have a PUK, set it first. */
  280|     93|	if(puk && puk_len)
  ------------------
  |  Branch (280:5): [True: 92, False: 1]
  |  Branch (280:12): [True: 92, False: 0]
  ------------------
  281|     92|	{
  282|       |		/* The PUK has a incremented reference, i.e. pins are odd, puks are equal (+1). */
  283|     92|		r = sc_change_reference_data(p15card->card, SC_AC_CHV,
  ------------------
  |  |  151|     92|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  284|     92|		                             pin_attrs->reference+1,
  285|     92|		                             NULL, 0,
  286|     92|		                             puk, puk_len, NULL);
  287|     92|		if(r < 0)
  ------------------
  |  Branch (287:6): [True: 52, False: 40]
  ------------------
  288|     52|		{
  289|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  290|     52|		}
  291|     92|	}
  292|       |
  293|       |	/* Store PIN: (use CHANGE REFERENCE DATA). */
  294|     41|	r = sc_change_reference_data(p15card->card, SC_AC_CHV,
  ------------------
  |  |  151|     41|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  295|     41|	                             pin_attrs->reference,
  296|     41|	                             NULL, 0,
  297|     41|	                             pin, pin_len, NULL);
  298|     41|	LOG_TEST_RET(card->ctx, r, "Failed to set PIN");
  ------------------
  |  |  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: 15, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  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|     41|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  299|       |
  300|     26|	sc_pkcs15_pincache_add(p15card, pin_obj, pin, pin_len);
  301|     26|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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: 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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|     26|}
pkcs15-isoApplet.c:isoApplet_select_key_reference:
  668|     77|{
  669|     77|	int rv = SC_SUCCESS;
  ------------------
  |  |   28|     77|#define SC_SUCCESS				0
  ------------------
  670|     77|	sc_card_t *card = p15card->card;
  671|       |
  672|     77|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     77|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     77|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     77|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     77|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 77]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  673|       |
  674|     77|	if(key_info->key_reference < ISOAPPLET_KEY_ID_MIN)
  ------------------
  |  |   37|     77|#define ISOAPPLET_KEY_ID_MIN 0
  ------------------
  |  Branch (674:5): [True: 0, False: 77]
  ------------------
  675|      0|	{
  676|      0|		key_info->key_reference = ISOAPPLET_KEY_ID_MIN;
  ------------------
  |  |   37|      0|#define ISOAPPLET_KEY_ID_MIN 0
  ------------------
  677|      0|		rv = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  678|      0|	}
  679|     77|	if(key_info->key_reference > ISOAPPLET_KEY_ID_MAX)
  ------------------
  |  |   38|     77|#define ISOAPPLET_KEY_ID_MAX 15
  ------------------
  |  Branch (679:5): [True: 0, False: 77]
  ------------------
  680|      0|	{
  681|      0|		rv = SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  682|      0|	}
  683|     77|	LOG_FUNC_RETURN(card->ctx, rv);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 77]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  684|     77|}
pkcs15-isoApplet.c:isoApplet_create_key:
  657|     77|{
  658|     77|	sc_card_t *card = p15card->card;
  659|     77|	LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 77]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  660|     77|}
pkcs15-isoApplet.c:isoApplet_get_curve:
  317|     21|{
  318|     21|	int i;
  319|       |
  320|     21|	if(!oid)
  ------------------
  |  Branch (320:5): [True: 0, False: 21]
  ------------------
  321|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  322|       |
  323|       |	/* Search the curve parameters. */
  324|    147|	for (i = 0; curves[i].oid.value; i++)
  ------------------
  |  Branch (324:14): [True: 147, False: 0]
  ------------------
  325|    147|	{
  326|    147|		if (oid_len == curves[i].oid.len && memcmp(oid, curves[i].oid.value, curves[i].oid.len) == 0)
  ------------------
  |  Branch (326:7): [True: 42, False: 105]
  |  Branch (326:39): [True: 21, False: 21]
  ------------------
  327|     21|		{
  328|     21|			*curve_out = &curves[i];
  329|     21|			return SC_SUCCESS;
  ------------------
  |  |   28|     21|#define SC_SUCCESS				0
  ------------------
  330|     21|		}
  331|    147|	}
  332|       |
  333|      0|	return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  334|     21|}
pkcs15-isoApplet.c:isoApplet_generate_key:
  610|     77|{
  611|     77|	int r;
  612|     77|	sc_pkcs15_prkey_info_t *key_info = (sc_pkcs15_prkey_info_t *) obj->data;
  613|     77|	sc_file_t *privKeyFile=NULL;
  614|     77|	sc_card_t *card = p15card->card;
  615|       |
  616|     77|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|     77|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     77|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     77|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     77|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 77]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|       |
  618|       |	/* Authentication stuff. */
  619|     77|	r = sc_profile_get_file_by_path(profile, &key_info->path, &privKeyFile);
  620|     77|	if(r < 0 || !privKeyFile)
  ------------------
  |  Branch (620:5): [True: 56, False: 21]
  |  Branch (620:14): [True: 0, False: 21]
  ------------------
  621|     56|	{
  622|     56|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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|     56|#define SC_COLOR_FG_RED			0x0001
  |  |  ------------------
  |  |  |  Branch (156:65): [True: 56, False: 0]
  |  |  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  623|     56|	}
  624|     21|	r = sc_pkcs15init_authenticate(profile, p15card, privKeyFile, SC_AC_OP_CREATE_EF);
  ------------------
  |  |  193|     21|#define SC_AC_OP_CREATE_EF		27
  ------------------
  625|     21|	if(r < 0)
  ------------------
  |  Branch (625:5): [True: 0, False: 21]
  ------------------
  626|      0|	{
  627|      0|		sc_file_free(privKeyFile);
  628|      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]
  |  |  ------------------
  ------------------
  629|      0|	}
  630|     21|	sc_file_free(privKeyFile);
  631|       |
  632|       |	/* Generate the key. */
  633|     21|	switch(obj->type)
  634|     21|	{
  635|      0|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (635:2): [True: 0, False: 21]
  ------------------
  636|      0|		r = isoApplet_generate_key_rsa(key_info, card, pubkey);
  637|      0|		break;
  638|       |
  639|     21|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     21|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (639:2): [True: 21, False: 0]
  ------------------
  640|     21|		r = isoApplet_generate_key_ec(key_info, card, pubkey);
  641|     21|		break;
  642|       |
  643|      0|	default:
  ------------------
  |  Branch (643:2): [True: 0, False: 21]
  ------------------
  644|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  645|      0|		sc_log(card->ctx, "%s: Key generation failed: Unknown/unsupported key type.", 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__
  |  |  ------------------
  ------------------
  646|     21|	}
  647|       |
  648|     21|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  649|     21|}
pkcs15-isoApplet.c:isoApplet_generate_key_ec:
  447|     21|{
  448|     21|	int	r;
  449|     21|	const struct ec_curve *curve = NULL;
  450|     21|	struct sc_ec_parameters *alg_id_params = NULL;
  451|     21|	sc_cardctl_isoApplet_genkey_t args;
  452|     21|	const struct sc_ec_parameters *info_ecp =
  453|     21|	    (struct sc_ec_parameters *) key_info->params.data;
  454|       |
  455|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  456|       |
  457|     21|	memset(&args, 0, sizeof(args));
  458|       |
  459|       |	/* Check key size: */
  460|     21|	if(key_info->field_length == 0)
  ------------------
  |  Branch (460:5): [True: 0, False: 21]
  ------------------
  461|      0|	{
  462|      0|		sc_log(card->ctx, "Unknown field 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__
  |  |  ------------------
  ------------------
  463|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  464|      0|		goto out;
  465|      0|	}
  466|       |
  467|     21|	r = isoApplet_get_curve(info_ecp->der.value, info_ecp->der.len, &curve);
  468|     21|	if(r < 0)
  ------------------
  |  Branch (468:5): [True: 0, False: 21]
  ------------------
  469|      0|	{
  470|      0|		sc_log(card->ctx, "EC key generation failed: Unsupported curve: [%s].", info_ecp->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__
  |  |  ------------------
  ------------------
  471|      0|		goto out;
  472|      0|	}
  473|       |
  474|       |	/* Generate the key.
  475|       |	 * Note: The field size is not explicitly passed to the card.
  476|       |	 *       As we only support FP curves, the field length can be calculated from any parameter. */
  477|     21|	args.pubkey.ec.params.prime.value			= curve->prime.value;
  478|     21|	args.pubkey.ec.params.prime.len				= curve->prime.len;
  479|     21|	args.pubkey.ec.params.coefficientA.value	= curve->coefficientA.value;
  480|     21|	args.pubkey.ec.params.coefficientA.len		= curve->coefficientA.len;
  481|     21|	args.pubkey.ec.params.coefficientB.value	= curve->coefficientB.value;
  482|     21|	args.pubkey.ec.params.coefficientB.len		= curve->coefficientB.len;
  483|     21|	args.pubkey.ec.params.basePointG.value 		= curve->basePointG.value;
  484|     21|	args.pubkey.ec.params.basePointG.len		= curve->basePointG.len;
  485|     21|	args.pubkey.ec.params.order.value 			= curve->order.value;
  486|     21|	args.pubkey.ec.params.order.len				= curve->order.len;
  487|     21|	args.pubkey.ec.params.coFactor.value 		= curve->coFactor.value;
  488|     21|	args.pubkey.ec.params.coFactor.len			= curve->coFactor.len;
  489|       |	/* The length of the public key point will be:
  490|       |	 * Uncompressed tag + 2 * field length in bytes. */
  491|     21|	args.pubkey.ec.ecPointQ.len = 1 + BYTES4BITS(key_info->field_length) * 2;
  ------------------
  |  |  146|     21|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  492|     21|	args.pubkey.ec.ecPointQ.value = malloc(args.pubkey.ec.ecPointQ.len);
  493|     21|	if(!args.pubkey.ec.ecPointQ.value)
  ------------------
  |  Branch (493:5): [True: 0, False: 21]
  ------------------
  494|      0|	{
  495|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  496|      0|		goto out;
  497|      0|	}
  498|       |
  499|     21|	args.algorithm_ref = SC_ISOAPPLET_ALG_REF_EC_GEN;
  ------------------
  |  |  980|     21|#define SC_ISOAPPLET_ALG_REF_EC_GEN 0xEC
  ------------------
  500|     21|	args.priv_key_ref = key_info->key_reference;
  501|       |
  502|       |	/* On-card key generation */
  503|     21|	r = sc_card_ctl(card, SC_CARDCTL_ISOAPPLET_GENERATE_KEY, &args);
  504|     21|	if (r < 0)
  ------------------
  |  Branch (504:6): [True: 21, False: 0]
  ------------------
  505|     21|	{
  506|     21|		sc_log(card->ctx, "%s: Error in card_ctl.", sc_strerror(r));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  507|     21|		goto out;
  508|     21|	}
  509|       |
  510|       |	/* Extract and compose the public key. */
  511|      0|	pubkey->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
  512|       |
  513|       |	/* der-encoded parameters */
  514|      0|	alg_id_params = calloc(1, sizeof(*alg_id_params));
  515|      0|	if(!alg_id_params)
  ------------------
  |  Branch (515:5): [True: 0, False: 0]
  ------------------
  516|      0|	{
  517|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  518|      0|		goto out;
  519|      0|	}
  520|      0|	alg_id_params->der.len = curve->oid.len;
  521|      0|	alg_id_params->der.value = malloc(alg_id_params->der.len);
  522|      0|	if(!alg_id_params->der.value)
  ------------------
  |  Branch (522:5): [True: 0, False: 0]
  ------------------
  523|      0|	{
  524|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  525|      0|		goto out;
  526|      0|	}
  527|      0|	memcpy(alg_id_params->der.value, curve->oid.value, curve->oid.len);
  528|      0|	alg_id_params->type = 1; /* named curve */
  529|       |
  530|      0|	pubkey->alg_id = malloc(sizeof(*pubkey->alg_id));
  531|      0|	if(!pubkey->alg_id)
  ------------------
  |  Branch (531:5): [True: 0, False: 0]
  ------------------
  532|      0|	{
  533|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  534|      0|		goto out;
  535|      0|	}
  536|      0|	pubkey->alg_id->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
  537|      0|	sc_init_oid(&pubkey->alg_id->oid);
  538|      0|	pubkey->alg_id->params = alg_id_params;
  539|       |
  540|       |	/* Extract ecpointQ */
  541|      0|	pubkey->u.ec.ecpointQ.len = args.pubkey.ec.ecPointQ.len;
  542|      0|	pubkey->u.ec.ecpointQ.value = malloc(pubkey->u.ec.ecpointQ.len);
  543|      0|	if(!pubkey->u.ec.ecpointQ.value)
  ------------------
  |  Branch (543:5): [True: 0, False: 0]
  ------------------
  544|      0|	{
  545|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  546|      0|		goto out;
  547|      0|	}
  548|      0|	memcpy(pubkey->u.ec.ecpointQ.value, args.pubkey.ec.ecPointQ.value, args.pubkey.ec.ecPointQ.len);
  549|       |
  550|       |	/* The OID is also written to the pubkey->u.ec.params */
  551|      0|	free(pubkey->u.ec.params.der.value);
  552|      0|	pubkey->u.ec.params.der.value = malloc(alg_id_params->der.len);
  553|      0|	if(!pubkey->u.ec.params.der.value)
  ------------------
  |  Branch (553:5): [True: 0, False: 0]
  ------------------
  554|      0|	{
  555|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  556|      0|		goto out;
  557|      0|	}
  558|      0|	memcpy(pubkey->u.ec.params.der.value, alg_id_params->der.value, alg_id_params->der.len);
  559|      0|	pubkey->u.ec.params.der.len = alg_id_params->der.len;
  560|      0|	r = sc_pkcs15_fix_ec_parameters(card->ctx, &pubkey->u.ec.params);
  561|     21|out:
  562|     21|	if(args.pubkey.ec.ecPointQ.value)
  ------------------
  |  Branch (562:5): [True: 21, False: 0]
  ------------------
  563|     21|	{
  564|     21|		free(args.pubkey.ec.ecPointQ.value);
  565|     21|		args.pubkey.ec.ecPointQ.value = NULL;
  566|     21|	}
  567|     21|	if(r < 0 && pubkey)
  ------------------
  |  Branch (567:5): [True: 21, False: 0]
  |  Branch (567:14): [True: 21, False: 0]
  ------------------
  568|     21|	{
  569|     21|		if(pubkey->alg_id)
  ------------------
  |  Branch (569:6): [True: 0, False: 21]
  ------------------
  570|      0|		{
  571|      0|			free(pubkey->alg_id);
  572|      0|			pubkey->alg_id = NULL;
  573|      0|		}
  574|     21|		if(pubkey->u.ec.params.der.value)
  ------------------
  |  Branch (574:6): [True: 21, False: 0]
  ------------------
  575|     21|		{
  576|     21|			free(pubkey->u.ec.params.der.value);
  577|     21|			pubkey->u.ec.params.der.value = NULL;
  578|     21|			pubkey->u.ec.params.der.len = 0;
  579|     21|		}
  580|     21|		if(pubkey->u.ec.params.named_curve)
  ------------------
  |  Branch (580:6): [True: 21, False: 0]
  ------------------
  581|     21|		{
  582|     21|			free(pubkey->u.ec.params.named_curve);
  583|     21|			pubkey->u.ec.params.named_curve = NULL;
  584|     21|		}
  585|     21|		if(pubkey->u.ec.ecpointQ.value)
  ------------------
  |  Branch (585:6): [True: 0, False: 21]
  ------------------
  586|      0|		{
  587|      0|			free(pubkey->u.ec.ecpointQ.value);
  588|      0|			pubkey->u.ec.ecpointQ.value = NULL;
  589|      0|			pubkey->u.ec.ecpointQ.len = 0;
  590|      0|		}
  591|     21|		memset(pubkey, 0, sizeof(sc_pkcs15_pubkey_t));
  592|     21|	}
  593|     21|	if(r < 0 && alg_id_params)
  ------------------
  |  Branch (593:5): [True: 21, False: 0]
  |  Branch (593:14): [True: 0, False: 21]
  ------------------
  594|      0|	{
  595|      0|		if(alg_id_params->der.value)
  ------------------
  |  Branch (595:6): [True: 0, False: 0]
  ------------------
  596|      0|		{
  597|      0|			free(alg_id_params->der.value);
  598|      0|			alg_id_params->der.value = NULL;
  599|      0|		}
  600|      0|		free(alg_id_params);
  601|      0|		pubkey->alg_id->params = NULL;
  602|      0|	}
  603|     21|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  604|     21|}

sc_pkcs15init_unbind:
  428|  2.75k|{
  429|  2.75k|	int r;
  430|  2.75k|	struct sc_context *ctx = profile->card->ctx;
  431|       |
  432|  2.75k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.75k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.75k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.75k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.75k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.75k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  433|  2.75k|	sc_log(ctx, "Pksc15init Unbind: %i:%p:%i", profile->dirty, profile->p15_data, profile->pkcs15.do_last_update);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  434|  2.75k|	if (profile->dirty != 0 && profile->p15_data != NULL && profile->pkcs15.do_last_update) {
  ------------------
  |  Branch (434:6): [True: 835, False: 1.91k]
  |  Branch (434:29): [True: 738, False: 97]
  |  Branch (434:58): [True: 737, False: 1]
  ------------------
  435|    737|		r = sc_pkcs15init_update_lastupdate(profile->p15_data, profile);
  436|    737|		if (r < 0)
  ------------------
  |  Branch (436:7): [True: 485, False: 252]
  ------------------
  437|    485|			sc_log(ctx, "Failed to update TokenInfo: %s", sc_strerror(r));
  ------------------
  |  |   71|    485|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  438|    737|	}
  439|  2.75k|	sc_profile_free(profile);
  440|  2.75k|}
sc_pkcs15init_set_p15card:
  445|  2.21k|{
  446|  2.21k|	struct sc_context *ctx = p15card->card->ctx;
  447|  2.21k|	struct sc_pkcs15_object *p15objects[10];
  448|  2.21k|	int i, r, nn_objs;
  449|       |
  450|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  451|       |
  452|       |	/* Prepare pin-domain instantiation:
  453|       |	 * for every present local User PIN, add to the profile EF list the named PIN path. */
  454|  2.21k|	nn_objs = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, p15objects, 10);
  ------------------
  |  |  445|  2.21k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  455|  2.77k|	for (i = 0; i < nn_objs; i++) {
  ------------------
  |  Branch (455:14): [True: 552, False: 2.21k]
  ------------------
  456|    552|		struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *) p15objects[i]->data;
  457|    552|		struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
  458|    552|		struct sc_file *file = NULL;
  459|       |
  460|    552|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|    552|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (460:7): [True: 62, False: 490]
  ------------------
  461|     62|			continue;
  462|    490|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|    490|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (462:7): [True: 240, False: 250]
  ------------------
  463|    240|			continue;
  464|    250|		if (!auth_info->path.len)
  ------------------
  |  Branch (464:7): [True: 227, False: 23]
  ------------------
  465|    227|			continue;
  466|       |
  467|     23|		r = sc_profile_get_file_by_path(profile, &auth_info->path, &file);
  468|     23|                if (r == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|     23|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (468:21): [True: 23, False: 0]
  ------------------
  469|     23|			if (!sc_select_file(p15card->card, &auth_info->path, &file))   {
  ------------------
  |  Branch (469:8): [True: 5, False: 18]
  ------------------
  470|      5|				char pin_name[16];
  471|       |
  472|      5|				sprintf(pin_name, "pin-dir-%02X%02X", file->path.value[file->path.len - 2],
  473|      5|						file->path.value[file->path.len - 1]);
  474|      5|				sc_log(ctx, "add '%s' to profile file list", pin_name);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  475|      5|				sc_profile_add_file(profile, pin_name, file);
  476|      5|			}
  477|     23|		}
  478|       |
  479|     23|		sc_file_free(file);
  480|     23|	}
  481|       |
  482|  2.21k|	profile->p15_data = p15card;
  483|  2.21k|	sc_log(ctx, "sc_pkcs15init_set_p15card() returns");
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
  484|  2.21k|}
sc_pkcs15init_set_lifecycle:
  492|  5.42k|{
  493|  5.42k|	return sc_card_ctl(card, SC_CARDCTL_LIFECYCLE_SET, &lcycle);
  494|  5.42k|}
sc_pkcs15init_erase_card:
  503|  2.21k|{
  504|  2.21k|	struct sc_context *ctx = NULL;
  505|  2.21k|	int rv;
  506|       |
  507|  2.21k|	if (!p15card)
  ------------------
  |  Branch (507:6): [True: 0, False: 2.21k]
  ------------------
  508|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  509|       |
  510|  2.21k|	ctx = p15card->card->ctx;
  511|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  512|       |	/* Needs the 'SOPIN' AUTH pkcs15 object.
  513|       |	 * So that, SOPIN can be found by it's reference. */
  514|  2.21k|	if (sc_pkcs15_bind(p15card->card, aid, &p15card) >= 0)
  ------------------
  |  Branch (514:6): [True: 231, False: 1.98k]
  ------------------
  515|    231|		profile->p15_data = p15card;
  516|       |
  517|  2.21k|	if (profile->ops->erase_card == NULL)
  ------------------
  |  Branch (517:6): [True: 231, False: 1.98k]
  ------------------
  518|  2.21k|		LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    231|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    231|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    231|	int _ret = r; \
  |  |  |  |  155|    231|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 231, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    231|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    231|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 231, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    231|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    231|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    231|	return _ret; \
  |  |  |  |  163|    231|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  519|       |
  520|  1.98k|	rv = profile->ops->erase_card(profile, p15card);
  521|       |
  522|  1.98k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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.55k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.55k, False: 436]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  523|  1.98k|}
sc_pkcs15init_erase_card_recursively:
  529|    143|{
  530|    143|	struct sc_file	*df = profile->df_info->file, *dir;
  531|    143|	int		r;
  532|       |
  533|       |	/* Delete EF(DIR). This may not be very nice
  534|       |	 * against other applications that use this file, but
  535|       |	 * extremely useful for testing :)
  536|       |	 * Note we need to delete it before the DF because we create
  537|       |	 * it *after* the DF. Some cards (e.g. the cryptoflex) want
  538|       |	 * us to delete files in reverse order of creation.
  539|       |	 * */
  540|    143|	if (sc_profile_get_file(profile, "DIR", &dir) >= 0) {
  ------------------
  |  Branch (540:6): [True: 10, False: 133]
  ------------------
  541|     10|		r = sc_pkcs15init_rmdir(p15card, profile, dir);
  542|     10|		sc_file_free(dir);
  543|     10|		if (r < 0 && r != SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|      8|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (543:7): [True: 8, False: 2]
  |  Branch (543:16): [True: 5, False: 3]
  ------------------
  544|      5|			sc_free_apps(p15card->card);
  545|      5|			return r;
  546|      5|		}
  547|     10|	}
  548|       |
  549|    138|	r = sc_select_file(p15card->card, &df->path, &df);
  550|    138|	if (r >= 0) {
  ------------------
  |  Branch (550:6): [True: 16, False: 122]
  ------------------
  551|     16|		r = sc_pkcs15init_rmdir(p15card, profile, df);
  552|     16|		sc_file_free(df);
  553|     16|	}
  554|    138|	if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    138|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (554:6): [True: 2, False: 136]
  ------------------
  555|      2|		r = 0;
  556|       |
  557|    138|	sc_free_apps(p15card->card);
  558|    138|	return r;
  559|    143|}
sc_pkcs15init_delete_by_path:
  565|    598|{
  566|    598|	struct sc_context *ctx = p15card->card->ctx;
  567|    598|	struct sc_file *parent = NULL, *file = NULL;
  568|    598|	struct sc_path path;
  569|    598|	int rv;
  570|       |	/*int file_type = SC_FILE_TYPE_DF;*/
  571|       |
  572|    598|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    598|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    598|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    598|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    598|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 598]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|    598|	sc_log(ctx, "trying to delete '%s'", sc_print_path(file_path));
  ------------------
  |  |   71|    598|#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|       |
  575|       |	/* For some cards, to delete file should be satisfied the 'DELETE' ACL of the file itself,
  576|       |	 * for the others the 'DELETE' ACL of parent.
  577|       |	 * Let's start from the file's 'DELETE' ACL.
  578|       |	 *
  579|       |	 * TODO: 'DELETE_SELF' exists. Proper solution would be to use this acl by every
  580|       |	 * card (driver and profile) that uses self delete ACL.
  581|       |	 */
  582|       |	/* Select the file itself */
  583|    598|	path = *file_path;
  584|    598|	rv = sc_select_file(p15card->card, &path, &file);
  585|    598|	LOG_TEST_RET(ctx, rv, "cannot select file to delete");
  ------------------
  |  |  174|    598|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    598|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    598|	int _ret = (r); \
  |  |  |  |  168|    598|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 363, False: 235]
  |  |  |  |  ------------------
  |  |  |  |  169|    363|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    363|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    363|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    363|		return _ret; \
  |  |  |  |  172|    363|	} \
  |  |  |  |  173|    598|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 235]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  586|       |
  587|    235|	if (sc_file_get_acl_entry(file, SC_AC_OP_DELETE_SELF))   {
  ------------------
  |  |  174|    235|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  |  Branch (587:6): [True: 0, False: 235]
  ------------------
  588|      0|		sc_log(ctx, "Found 'DELETE-SELF' acl");
  ------------------
  |  |   71|      0|#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|      0|		rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_DELETE_SELF);
  ------------------
  |  |  174|      0|#define SC_AC_OP_DELETE_SELF		8
  ------------------
  590|      0|		sc_file_free(file);
  591|      0|	}
  592|    235|	else if (sc_file_get_acl_entry(file, SC_AC_OP_DELETE))   {
  ------------------
  |  |  168|    235|#define SC_AC_OP_DELETE			2
  ------------------
  |  Branch (592:11): [True: 60, False: 175]
  ------------------
  593|     60|		sc_log(ctx, "Found 'DELETE' acl");
  ------------------
  |  |   71|     60|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  594|     60|	        rv = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     60|#define SC_AC_OP_DELETE			2
  ------------------
  595|     60|		sc_file_free(file);
  596|     60|	}
  597|    175|	else    {
  598|    175|		sc_log(ctx, "Try to get the parent's 'DELETE' access");
  ------------------
  |  |   71|    175|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  599|       |		/*file_type = file->type;*/
  600|    175|		if (file_path->len >= 2) {
  ------------------
  |  Branch (600:7): [True: 150, False: 25]
  ------------------
  601|       |			/* Select the parent DF */
  602|    150|			path.len -= 2;
  603|    150|			rv = sc_select_file(p15card->card, &path, &parent);
  604|    150|			if (rv < 0)
  ------------------
  |  Branch (604:8): [True: 24, False: 126]
  ------------------
  605|     24|				sc_file_free(file);
  606|    150|			LOG_TEST_RET(ctx, rv, "Cannot select parent");
  ------------------
  |  |  174|    150|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    150|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    150|	int _ret = (r); \
  |  |  |  |  168|    150|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 24, False: 126]
  |  |  |  |  ------------------
  |  |  |  |  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|    150|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 126]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|       |
  608|    126|			rv = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    126|#define SC_AC_OP_DELETE			2
  ------------------
  609|    126|			sc_file_free(parent);
  610|    126|			sc_file_free(file);
  611|    126|			LOG_TEST_RET(ctx, rv, "parent 'DELETE' authentication failed");
  ------------------
  |  |  174|    126|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    126|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    126|	int _ret = (r); \
  |  |  |  |  168|    126|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 19, False: 107]
  |  |  |  |  ------------------
  |  |  |  |  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|    126|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 107]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  612|    126|		}
  613|     25|		else {
  614|       |			/* No 'DELETE' ACL of the file and not deleted for parent */
  615|     25|			rv = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     25|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  616|     25|			sc_file_free(file);
  617|     25|		}
  618|    175|	}
  619|    192|	LOG_TEST_RET(ctx, rv, "'DELETE' authentication failed");
  ------------------
  |  |  174|    192|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    192|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    192|	int _ret = (r); \
  |  |  |  |  168|    192|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 44, False: 148]
  |  |  |  |  ------------------
  |  |  |  |  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|    192|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 148]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  620|       |
  621|       |	/* Reselect file to delete: current path could be changed by 'verify PIN' procedure */
  622|    148|	path = *file_path;
  623|    148|	rv = sc_select_file(p15card->card, &path, &file);
  624|    148|	LOG_TEST_RET(ctx, rv, "cannot select file to delete");
  ------------------
  |  |  174|    148|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    148|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    148|	int _ret = (r); \
  |  |  |  |  168|    148|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 48, False: 100]
  |  |  |  |  ------------------
  |  |  |  |  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|    148|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 100]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|       |
  626|    100|	memset(&path, 0, sizeof(path));
  627|    100|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|    100|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  628|    100|	if (file_path->len < 2) {
  ------------------
  |  Branch (628:6): [True: 4, False: 96]
  ------------------
  629|      4|		sc_file_free(file);
  630|      4|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  631|      4|	}
  632|     96|	path.value[0] = file_path->value[file_path->len - 2];
  633|     96|	path.value[1] = file_path->value[file_path->len - 1];
  634|     96|	path.len = 2;
  635|       |
  636|       |	/* Reselect file to delete if the parent DF was selected and it's not DF. */
  637|       |/*
  638|       |	if (file_type != SC_FILE_TYPE_DF)   {
  639|       |		rv = sc_select_file(p15card->card, &path, &file);
  640|       |		LOG_TEST_RET(ctx, rv, "cannot select file to delete");
  641|       |	}
  642|       |*/
  643|       |
  644|     96|	sc_log(ctx, "Now really delete file");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  645|     96|	rv = sc_delete_file(p15card->card, &path);
  646|     96|	sc_file_free(file);
  647|     96|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|     96|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     96|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     96|	int _ret = r; \
  |  |  |  |  155|     96|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 96, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     96|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 56]
  |  |  |  |  ------------------
  |  |  |  |  157|     96|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     96|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     96|	return _ret; \
  |  |  |  |  163|     96|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  648|     96|}
sc_pkcs15init_rmdir:
  659|     28|{
  660|     28|	struct sc_context *ctx = p15card->card->ctx;
  661|     28|	unsigned char buffer[1024];
  662|     28|	struct sc_path	path;
  663|     28|	struct sc_file	*file, *parent;
  664|     28|	int		r = 0, nfids;
  665|       |
  666|     28|	if (df == NULL)
  ------------------
  |  Branch (666:6): [True: 0, False: 28]
  ------------------
  667|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  668|     28|	sc_log(ctx, "sc_pkcs15init_rmdir(%s)", sc_print_path(&df->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  669|       |
  670|     28|	if (df->type == SC_FILE_TYPE_DF) {
  ------------------
  |  |  214|     28|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (670:6): [True: 17, False: 11]
  ------------------
  671|     17|		r = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_LIST_FILES);
  ------------------
  |  |  172|     17|#define SC_AC_OP_LIST_FILES		6
  ------------------
  672|     17|		if (r < 0)
  ------------------
  |  Branch (672:7): [True: 0, False: 17]
  ------------------
  673|      0|			return r;
  674|     17|		r = sc_list_files(p15card->card, buffer, sizeof(buffer));
  675|     17|		if (r < 0)
  ------------------
  |  Branch (675:7): [True: 11, False: 6]
  ------------------
  676|     11|			return r;
  677|       |
  678|      6|		path = df->path;
  679|      6|		path.len += 2;
  680|      6|		if (path.len > SC_MAX_PATH_SIZE)
  ------------------
  |  |   47|      6|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (680:7): [True: 0, False: 6]
  ------------------
  681|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  682|       |
  683|      6|		nfids = r / 2;
  684|      9|		while (r >= 0 && nfids--) {
  ------------------
  |  Branch (684:10): [True: 6, False: 3]
  |  Branch (684:20): [True: 5, False: 1]
  ------------------
  685|      5|			path.value[path.len-2] = buffer[2*nfids];
  686|      5|			path.value[path.len-1] = buffer[2*nfids+1];
  687|      5|			r = sc_select_file(p15card->card, &path, &file);
  688|      5|			if (r < 0) {
  ------------------
  |  Branch (688:8): [True: 3, False: 2]
  ------------------
  689|      3|				if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      3|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (689:9): [True: 1, False: 2]
  ------------------
  690|      1|					continue;
  691|      2|				break;
  692|      3|			}
  693|      2|			r = sc_pkcs15init_rmdir(p15card, profile, file);
  694|      2|			sc_file_free(file);
  695|      2|		}
  696|       |
  697|      6|		if (r < 0)
  ------------------
  |  Branch (697:7): [True: 5, False: 1]
  ------------------
  698|      5|			return r;
  699|      6|	}
  700|       |
  701|       |	/* Select the parent DF */
  702|     12|	path = df->path;
  703|     12|	if (path.len <= 2)
  ------------------
  |  Branch (703:6): [True: 2, False: 10]
  ------------------
  704|      2|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      2|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  705|     10|	path.len -= 2;
  706|     10|	r = sc_select_file(p15card->card, &path, &parent);
  707|     10|	if (r < 0)
  ------------------
  |  Branch (707:6): [True: 3, False: 7]
  ------------------
  708|      3|		return r;
  709|       |
  710|      7|	r = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      7|#define SC_AC_OP_DELETE			2
  ------------------
  711|      7|	if (r < 0) {
  ------------------
  |  Branch (711:6): [True: 2, False: 5]
  ------------------
  712|      2|		sc_file_free(parent);
  713|      2|		return r;
  714|      2|	}
  715|      5|	r = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      5|#define SC_AC_OP_DELETE			2
  ------------------
  716|      5|	sc_file_free(parent);
  717|      5|	if (r < 0)
  ------------------
  |  Branch (717:6): [True: 1, False: 4]
  ------------------
  718|      1|		return r;
  719|       |
  720|      4|	memset(&path, 0, sizeof(path));
  721|      4|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|      4|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  722|      4|	path.value[0] = df->id >> 8;
  723|      4|	path.value[1] = df->id & 0xFF;
  724|      4|	path.len = 2;
  725|       |
  726|       |	/* ensure that the card is in the correct lifecycle */
  727|      4|	r = sc_pkcs15init_set_lifecycle(p15card->card, SC_CARDCTRL_LIFECYCLE_ADMIN);
  728|      4|	if (r < 0 && r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|      2|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (728:6): [True: 2, False: 2]
  |  Branch (728:15): [True: 1, False: 1]
  ------------------
  729|      1|		return r;
  730|       |
  731|      3|	r = sc_delete_file(p15card->card, &path);
  732|      3|	return r;
  733|      4|}
sc_pkcs15init_finalize_card:
  738|  2.21k|{
  739|  2.21k|	if (profile->ops->finalize_card == NULL)
  ------------------
  |  Branch (739:6): [True: 1.46k, False: 757]
  ------------------
  740|  1.46k|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  1.46k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  741|    757|	return profile->ops->finalize_card(card);
  742|  2.21k|}
sc_pkcs15init_add_app:
  781|  2.75k|{
  782|  2.75k|	struct sc_context *ctx = card->ctx;
  783|  2.75k|	struct sc_pkcs15_card	*p15card = profile->p15_spec;
  784|  2.75k|	struct sc_pkcs15_auth_info pin_ainfo, puk_ainfo;
  785|  2.75k|	struct sc_pkcs15_pin_attributes *pin_attrs = &pin_ainfo.attrs.pin;
  786|  2.75k|	struct sc_pkcs15_object	*pin_obj = NULL;
  787|  2.75k|	struct sc_app_info	*app;
  788|  2.75k|	struct sc_file		*df = profile->df_info->file;
  789|  2.75k|	int			r = SC_SUCCESS;
  ------------------
  |  |   28|  2.75k|#define SC_SUCCESS				0
  ------------------
  790|  2.75k|	int			has_so_pin = args->so_pin_len != 0;
  791|       |
  792|  2.75k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.75k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.75k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.75k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.75k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.75k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  793|  2.75k|	p15card->card = card;
  794|       |
  795|       |	/* FIXME:
  796|       |	 * Some cards need pincache
  797|       |	 *  for ex. to create temporary CHV key with the value of default AUTH key.
  798|       |	 */
  799|  2.75k|	p15card->opts.use_pin_cache = 1;
  800|       |
  801|  2.75k|	if (card->app_count >= SC_MAX_CARD_APPS)
  ------------------
  |  |   33|  2.75k|#define SC_MAX_CARD_APPS		8
  ------------------
  |  Branch (801:6): [True: 0, False: 2.75k]
  ------------------
  802|  2.75k|		LOG_TEST_RET(ctx, SC_ERROR_TOO_MANY_OBJECTS, "Too many applications on this 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  803|       |
  804|       |	/* In case of pinpad readers check if SO PIN is defined in a profile */
  805|  2.75k|	if (!has_so_pin && (card->reader->capabilities & SC_READER_CAP_PIN_PAD)) {
  ------------------
  |  |  383|      0|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (805:6): [True: 0, False: 2.75k]
  |  Branch (805:21): [True: 0, False: 0]
  ------------------
  806|      0|		sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &pin_ainfo);
  ------------------
  |  |  169|      0|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  807|       |		/* If found, assume we want SO PIN */
  808|      0|		has_so_pin = pin_ainfo.attrs.pin.reference != -1;
  809|      0|	}
  810|       |
  811|       |	/* If the profile requires an SO PIN, check min/max length */
  812|  2.75k|	if (has_so_pin) {
  ------------------
  |  Branch (812:6): [True: 2.75k, False: 0]
  ------------------
  813|  2.75k|		const char	*pin_label;
  814|       |
  815|  2.75k|		if (args->so_pin_len) {
  ------------------
  |  Branch (815:7): [True: 2.75k, False: 0]
  ------------------
  816|  2.75k|			sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &pin_ainfo);
  ------------------
  |  |  169|  2.75k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  817|  2.75k|			r = sc_pkcs15init_qualify_pin(card, "SO PIN", args->so_pin_len, &pin_ainfo);
  818|  2.75k|			LOG_TEST_RET(ctx, r, "Failed to qualify SO PIN");
  ------------------
  |  |  174|  2.75k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.75k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.75k|	int _ret = (r); \
  |  |  |  |  168|  2.75k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.90k, False: 844]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.90k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.90k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.90k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.90k|		return _ret; \
  |  |  |  |  172|  1.90k|	} \
  |  |  |  |  173|  2.75k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 844]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  819|  2.75k|		}
  820|       |
  821|       |		/* Path encoded only for local SO PIN */
  822|    844|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|    844|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (822:7): [True: 624, False: 220]
  ------------------
  823|    624|			pin_ainfo.path = df->path;
  824|       |
  825|       |		/* Select the PIN reference */
  826|    844|		if (profile->ops->select_pin_reference) {
  ------------------
  |  Branch (826:7): [True: 756, False: 88]
  ------------------
  827|    756|			r = profile->ops->select_pin_reference(profile, p15card, &pin_ainfo);
  828|    756|			LOG_TEST_RET(ctx, r, "Failed to select card specific PIN reference");
  ------------------
  |  |  174|    756|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    756|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    756|	int _ret = (r); \
  |  |  |  |  168|    756|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 119, False: 637]
  |  |  |  |  ------------------
  |  |  |  |  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|    756|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 637]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  829|    756|		}
  830|       |
  831|    725|		sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PUK, &puk_ainfo);
  ------------------
  |  |  170|    725|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  832|    725|		r = sc_pkcs15init_qualify_pin(card, "SO PUK", args->so_puk_len, &puk_ainfo);
  833|    725|		LOG_TEST_RET(ctx, r, "Failed to qualify SO PUK");
  ------------------
  |  |  174|    725|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    725|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    725|	int _ret = (r); \
  |  |  |  |  168|    725|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 171, False: 554]
  |  |  |  |  ------------------
  |  |  |  |  169|    171|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    171|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    171|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    171|		return _ret; \
  |  |  |  |  172|    171|	} \
  |  |  |  |  173|    725|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 554]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  834|       |
  835|    554|		if (!(pin_label = args->so_pin_label)) {
  ------------------
  |  Branch (835:7): [True: 554, False: 0]
  ------------------
  836|    554|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|    554|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (836:8): [True: 208, False: 346]
  ------------------
  837|    208|				pin_label = "Security Officer PIN";
  838|    346|			else
  839|    346|				pin_label = "User PIN";
  840|    554|		}
  841|       |
  842|    554|		if (args->so_puk_len == 0)
  ------------------
  |  Branch (842:7): [True: 128, False: 426]
  ------------------
  843|    128|			pin_attrs->flags |= SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED;
  ------------------
  |  |   57|    128|#define SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED		0x0008
  ------------------
  844|       |
  845|    554|		pin_obj = sc_pkcs15init_new_object(SC_PKCS15_TYPE_AUTH_PIN, pin_label, NULL, &pin_ainfo);
  ------------------
  |  |  445|    554|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  846|    554|		if (pin_obj)   {
  ------------------
  |  Branch (846:7): [True: 554, False: 0]
  ------------------
  847|       |			/* When composing ACLs to create 'DIR' DF,
  848|       |			 *	the references of the not-yet-existing PINs can be requested.
  849|       |			 * For this, create a 'virtual' AUTH object 'SO PIN', accessible by the card specific part,
  850|       |			 * but not yet written into the on-card PKCS#15.
  851|       |			 */
  852|    554|			sc_log(ctx, "Add virtual SO_PIN('%.*s',flags:%X,reference:%i,path:'%s')", (int) sizeof pin_obj->label, pin_obj->label,
  ------------------
  |  |   71|    554|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  853|    554|					pin_attrs->flags, pin_attrs->reference, sc_print_path(&pin_ainfo.path));
  854|       |
  855|    554|			r = sc_pkcs15_add_object(p15card, pin_obj);
  856|    554|			LOG_TEST_GOTO_ERR(ctx, r, "Failed to add 'SOPIN' AUTH object");
  ------------------
  |  |  184|    554|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    554|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    554|	int _ret = (r); \
  |  |  |  |  178|    554|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 554]
  |  |  |  |  ------------------
  |  |  |  |  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|    554|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 554]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  857|    554|		}
  858|    554|	}
  859|       |
  860|       |	/* Perform card-specific initialization */
  861|    554|	if (profile->ops->init_card)   {
  ------------------
  |  Branch (861:6): [True: 424, False: 130]
  ------------------
  862|    424|		r = profile->ops->init_card(profile, p15card);
  863|    424|		if (r < 0 && pin_obj)   {
  ------------------
  |  Branch (863:7): [True: 160, False: 264]
  |  Branch (863:16): [True: 160, False: 0]
  ------------------
  864|    160|			sc_pkcs15_remove_object(p15card, pin_obj);
  865|    160|		}
  866|    424|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific init failed");
  ------------------
  |  |  184|    424|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    424|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    424|	int _ret = (r); \
  |  |  |  |  178|    424|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 160, False: 264]
  |  |  |  |  ------------------
  |  |  |  |  179|    160|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    160|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    160|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    160|		goto err; \
  |  |  |  |  182|    160|	} \
  |  |  |  |  183|    424|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 264]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|    424|	}
  868|       |
  869|       |	/* Create the application directory */
  870|    394|	if (profile->ops->create_dir) {
  ------------------
  |  Branch (870:6): [True: 348, False: 46]
  ------------------
  871|    348|		r = profile->ops->create_dir(profile, p15card, df);
  872|    348|		if (r < 0 && pin_obj)   {
  ------------------
  |  Branch (872:7): [True: 195, False: 153]
  |  Branch (872:16): [True: 195, False: 0]
  ------------------
  873|    195|			sc_pkcs15_remove_object(p15card, pin_obj);
  874|    195|		}
  875|    348|		LOG_TEST_GOTO_ERR(ctx, r, "Create 'DIR' error");
  ------------------
  |  |  184|    348|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    348|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    348|	int _ret = (r); \
  |  |  |  |  178|    348|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 195, False: 153]
  |  |  |  |  ------------------
  |  |  |  |  179|    195|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    195|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    195|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    195|		goto err; \
  |  |  |  |  182|    195|	} \
  |  |  |  |  183|    348|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 153]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  876|    348|	}
  877|       |
  878|       |	/* Store SO PIN */
  879|    199|	if (pin_obj && profile->ops->create_pin)
  ------------------
  |  Branch (879:6): [True: 199, False: 0]
  |  Branch (879:17): [True: 153, False: 46]
  ------------------
  880|    153|		r = profile->ops->create_pin(profile, p15card, df, pin_obj,
  881|    153|				args->so_pin, args->so_pin_len,
  882|    153|				args->so_puk, args->so_puk_len);
  883|       |
  884|    199|	if (pin_obj)
  ------------------
  |  Branch (884:6): [True: 199, False: 0]
  ------------------
  885|       |		/* Remove 'virtual' AUTH object . */
  886|    199|		sc_pkcs15_remove_object(p15card, pin_obj);
  887|       |
  888|    199|	LOG_TEST_GOTO_ERR(ctx, r, "Card specific create application DF failed");
  ------------------
  |  |  184|    199|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    199|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    199|	int _ret = (r); \
  |  |  |  |  178|    199|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 26, False: 173]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     26|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     26|		goto err; \
  |  |  |  |  182|     26|	} \
  |  |  |  |  183|    199|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 173]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  889|       |
  890|       |	/* Store the PKCS15 information on the card */
  891|    173|	app = (struct sc_app_info *)calloc(1, sizeof(*app));
  892|    173|	if (app == NULL) {
  ------------------
  |  Branch (892:6): [True: 0, False: 173]
  ------------------
  893|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  894|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to allocate application info");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  895|      0|	}
  896|       |
  897|    173|	app->path = p15card->file_app->path;
  898|    173|	if (p15card->file_app->namelen <= SC_MAX_AID_SIZE) {
  ------------------
  |  |   43|    173|#define SC_MAX_AID_SIZE			16
  ------------------
  |  Branch (898:6): [True: 173, False: 0]
  ------------------
  899|    173|		app->aid.len = p15card->file_app->namelen;
  900|    173|		memcpy(app->aid.value, p15card->file_app->name, app->aid.len);
  901|    173|	}
  902|       |
  903|       |	/* set serial number if explicitly specified */
  904|    173|	if (args->serial)   {
  ------------------
  |  Branch (904:6): [True: 0, False: 173]
  ------------------
  905|      0|		sc_pkcs15init_set_serial(profile, args->serial);
  906|      0|	}
  907|    173|	else {
  908|       |		/* otherwise try to get the serial number from the card */
  909|    173|		struct sc_serial_number serialnr;
  910|       |
  911|    173|		r = sc_card_ctl(card, SC_CARDCTL_GET_SERIALNR, &serialnr);
  912|    173|		if (r == SC_SUCCESS) {
  ------------------
  |  |   28|    173|#define SC_SUCCESS				0
  ------------------
  |  Branch (912:7): [True: 105, False: 68]
  ------------------
  913|    105|			char hex_serial[SC_MAX_SERIALNR * 2 + 1];
  914|       |
  915|    105|			sc_bin_to_hex(serialnr.value, serialnr.len, hex_serial, sizeof(hex_serial), 0);
  916|    105|			sc_pkcs15init_set_serial(profile, hex_serial);
  917|    105|		}
  918|    173|	}
  919|       |
  920|    173|	if (args->label) {
  ------------------
  |  Branch (920:6): [True: 0, False: 173]
  ------------------
  921|      0|		free(p15card->tokeninfo->label);
  922|      0|		p15card->tokeninfo->label = strdup(args->label);
  923|      0|	}
  924|    173|	if (p15card->tokeninfo->label)
  ------------------
  |  Branch (924:6): [True: 173, False: 0]
  ------------------
  925|    173|		app->label = strdup(p15card->tokeninfo->label);
  926|      0|	else
  927|      0|		app->label = strdup("Token");
  928|       |
  929|       |	/* See if we've set an SO PIN */
  930|    173|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_AODF, pin_obj);
  ------------------
  |  |  496|    173|#define SC_PKCS15_AODF			8
  ------------------
  931|    173|	if (r >= 0) {
  ------------------
  |  Branch (931:6): [True: 98, False: 75]
  ------------------
  932|     98|		r = sc_pkcs15init_update_dir(p15card, profile, app);
  933|     98|		if (r >= 0) {
  ------------------
  |  Branch (933:7): [True: 30, False: 68]
  ------------------
  934|     30|			r = sc_pkcs15init_update_tokeninfo(p15card, profile);
  935|     68|		} else {
  936|       |			/* FIXED: what to do if sc_pkcs15init_update_dir failed? */
  937|       |			/* sc_pkcs15init_update_dir may add app to card->app[] */
  938|     68|			int found = 0;
  939|     68|			int i;
  940|     68|			for (i = 0; i < card->app_count; i++) {
  ------------------
  |  Branch (940:16): [True: 39, False: 29]
  ------------------
  941|     39|				if (card->app[i] == app) {
  ------------------
  |  Branch (941:9): [True: 39, False: 0]
  ------------------
  942|     39|					found = 1;
  943|     39|					break;
  944|     39|				}
  945|     39|			}
  946|     68|			if (found == 0) { /* not in card->app[] free it */
  ------------------
  |  Branch (946:8): [True: 29, False: 39]
  ------------------
  947|     29|				free(app->label);
  948|     29|				free(app); /* unused */
  949|     29|			}
  950|     68|		}
  951|     98|	}
  952|     75|	else {
  953|     75|		free(app->label);
  954|     75|		free(app); /* unused */
  955|     75|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to add pin object.");
  ------------------
  |  |  184|     75|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     75|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     75|	int _ret = (r); \
  |  |  |  |  178|     75|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 75, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     75|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     75|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     75|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     75|		goto err; \
  |  |  |  |  182|     75|	} \
  |  |  |  |  183|     75|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  956|     75|	}
  957|       |
  958|     98|	sc_pkcs15init_write_info(p15card, profile, pin_obj);
  959|     98|	pin_obj = NULL;
  960|       |
  961|    554|err:
  962|    554|	sc_pkcs15_free_object(pin_obj);
  963|    554|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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: 541, False: 13]
  |  |  |  |  ------------------
  |  |  |  |  156|    541|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    541|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 541, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    541|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    541|	} else { \
  |  |  |  |  159|     13|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     13|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     13|	} \
  |  |  |  |  162|    554|	return _ret; \
  |  |  |  |  163|    554|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  964|    554|}
sc_pkcs15init_store_pin:
 1042|  2.21k|{
 1043|  2.21k|	struct sc_context *ctx = p15card->card->ctx;
 1044|  2.21k|	struct sc_pkcs15_object	*pin_obj;
 1045|  2.21k|	struct sc_pkcs15_auth_info *auth_info;
 1046|  2.21k|	int			r;
 1047|       |
 1048|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1049|       |	/* No auth_id given: select one */
 1050|  2.21k|	if (args->auth_id.len == 0) {
  ------------------
  |  Branch (1050:6): [True: 0, False: 2.21k]
  ------------------
 1051|      0|		unsigned int	n;
 1052|       |
 1053|      0|		args->auth_id.len = 1;
 1054|      0|		for (n = 1, r = 0; n < 256; n++) {
  ------------------
  |  Branch (1054:22): [True: 0, False: 0]
  ------------------
 1055|      0|			args->auth_id.value[0] = n;
 1056|      0|			r = sc_pkcs15_find_pin_by_auth_id(p15card, &args->auth_id, NULL);
 1057|      0|			if (r == SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1057:8): [True: 0, False: 0]
  ------------------
 1058|      0|				break;
 1059|      0|		}
 1060|       |
 1061|      0|		if (r != SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1061:7): [True: 0, False: 0]
  ------------------
 1062|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "No auth_id specified for new PIN");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1063|      0|	}
 1064|  2.21k|	else   {
 1065|       |		/* Make sure we don't get duplicate PIN IDs */
 1066|  2.21k|		r = sc_pkcs15_find_pin_by_auth_id(p15card, &args->auth_id, NULL);
 1067|  2.21k|		if (r != SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|  2.21k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1067:7): [True: 220, False: 1.99k]
  ------------------
 1068|  2.21k|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "There already is a PIN with this ID.");
  ------------------
  |  |  174|    220|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    220|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    220|	int _ret = (r); \
  |  |  |  |  168|    220|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 220, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    220|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    220|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    220|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    220|		return _ret; \
  |  |  |  |  172|    220|	} \
  |  |  |  |  173|    220|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1069|  2.21k|	}
 1070|       |
 1071|  1.99k|	pin_obj = sc_pkcs15init_new_object(SC_PKCS15_TYPE_AUTH_PIN, args->label, NULL, NULL);
  ------------------
  |  |  445|  1.99k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 1072|  1.99k|	if (pin_obj == NULL)
  ------------------
  |  Branch (1072:6): [True: 0, False: 1.99k]
  ------------------
 1073|  1.99k|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate PIN 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1074|       |
 1075|  1.99k|	auth_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
 1076|       |
 1077|  1.99k|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_USER_PIN, auth_info);
  ------------------
  |  |  171|  1.99k|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
 1078|  1.99k|	if (auth_info == NULL)
  ------------------
  |  Branch (1078:6): [True: 0, False: 1.99k]
  ------------------
 1079|  1.99k|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "Failed to retrieve auth_info");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1080|       |
 1081|  1.99k|	auth_info->auth_id = args->auth_id;
 1082|       |
 1083|       |	/* Now store the PINs */
 1084|  1.99k|	sc_log(ctx, "Store PIN(%.*s,authID:%s)", (int) sizeof pin_obj->label, pin_obj->label, sc_pkcs15_print_id(&auth_info->auth_id));
  ------------------
  |  |   71|  1.99k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1085|  1.99k|	if (profile->ops->create_pin) {
  ------------------
  |  Branch (1085:6): [True: 1.69k, False: 309]
  ------------------
 1086|  1.69k|		r = sc_pkcs15init_create_pin(p15card, profile, pin_obj, args);
 1087|  1.69k|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific create PIN failed.");
  ------------------
  |  |  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: 1.49k, False: 192]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.49k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.49k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.49k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.49k|		goto err; \
  |  |  |  |  182|  1.49k|	} \
  |  |  |  |  183|  1.69k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 192]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1088|  1.69k|	} else {
 1089|    309|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    309|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1090|    309|		LOG_TEST_GOTO_ERR(ctx, r, "Store PIN operation is not supported");
  ------------------
  |  |  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: 309, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|    309|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    309|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    309|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    309|		goto err; \
  |  |  |  |  182|    309|	} \
  |  |  |  |  183|    309|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1091|    309|	}
 1092|       |
 1093|    192|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_AODF, pin_obj);
  ------------------
  |  |  496|    192|#define SC_PKCS15_AODF			8
  ------------------
 1094|    192|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to add PIN object");
  ------------------
  |  |  184|    192|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    192|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    192|	int _ret = (r); \
  |  |  |  |  178|    192|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 167, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  179|    167|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    167|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    167|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    167|		goto err; \
  |  |  |  |  182|    167|	} \
  |  |  |  |  183|    192|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 25]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1095|       |
 1096|     25|	if (args->puk_id.len)
  ------------------
  |  Branch (1096:6): [True: 0, False: 25]
  ------------------
 1097|      0|		r = sc_pkcs15init_store_puk(p15card, profile, args);
 1098|       |
 1099|     25|	profile->dirty = 1;
 1100|       |
 1101|     25|	pin_obj = NULL;
 1102|       |
 1103|  1.99k|err:
 1104|  1.99k|	sc_pkcs15_free_object(pin_obj);
 1105|  1.99k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  1.99k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.99k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.99k|	int _ret = r; \
  |  |  |  |  155|  1.99k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.99k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|  1.97k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.97k, False: 25]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.99k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.99k|	return _ret; \
  |  |  |  |  163|  1.99k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1106|  1.99k|}
sc_pkcs15init_generate_key:
 1524|  4.43k|{
 1525|  4.43k|	struct sc_context *ctx = p15card->card->ctx;
 1526|  4.43k|	struct sc_pkcs15init_pubkeyargs pubkey_args;
 1527|  4.43k|	struct sc_pkcs15_object *object = NULL;
 1528|  4.43k|	struct sc_pkcs15_prkey_info *key_info = NULL;
 1529|  4.43k|	struct sc_pkcs15_pubkey *pubkey = NULL;
 1530|  4.43k|	int r, caller_supplied_id = 0;
 1531|  4.43k|	unsigned long algorithm = keygen_args->prkey_args.key.algorithm;
 1532|       |
 1533|  4.43k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  4.43k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  4.43k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  4.43k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  4.43k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 4.43k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1534|       |
 1535|  4.43k|	memset(&pubkey_args, 0, sizeof(pubkey_args));
 1536|       |
 1537|       |	/* check supported key size */
 1538|  4.43k|	r = check_keygen_params_consistency(p15card->card,
 1539|  4.43k|		algorithm, &keygen_args->prkey_args,
 1540|  4.43k|		&keybits);
 1541|  4.43k|	LOG_TEST_GOTO_ERR(ctx, r, "Invalid key size");
  ------------------
  |  |  184|  4.43k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.43k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.43k|	int _ret = (r); \
  |  |  |  |  178|  4.43k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.93k, False: 2.50k]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.93k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.93k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.93k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.93k|		goto err; \
  |  |  |  |  182|  1.93k|	} \
  |  |  |  |  183|  4.43k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.50k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1542|       |
 1543|  2.50k|	if (check_key_compatibility(p15card, algorithm,
  ------------------
  |  Branch (1543:6): [True: 27, False: 2.47k]
  ------------------
 1544|  2.50k|			&keygen_args->prkey_args.key, keygen_args->prkey_args.x509_usage,
 1545|  2.50k|			keybits, SC_ALGORITHM_ONBOARD_KEY_GEN) != SC_SUCCESS) {
  ------------------
  |  |  102|  2.50k|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              			keybits, SC_ALGORITHM_ONBOARD_KEY_GEN) != SC_SUCCESS) {
  ------------------
  |  |   28|  2.50k|#define SC_SUCCESS				0
  ------------------
 1546|     27|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     27|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1547|     27|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot generate key with the given parameters");
  ------------------
  |  |  184|     27|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     27|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     27|	int _ret = (r); \
  |  |  |  |  178|     27|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 27, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     27|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     27|		goto err; \
  |  |  |  |  182|     27|	} \
  |  |  |  |  183|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1548|     27|	}
 1549|       |
 1550|  2.47k|	if (profile->ops->generate_key == NULL) {
  ------------------
  |  Branch (1550:6): [True: 0, False: 2.47k]
  ------------------
 1551|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1552|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Key generation not supported");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1553|      0|	}
 1554|       |
 1555|  2.47k|	if (keygen_args->prkey_args.id.len)   {
  ------------------
  |  Branch (1555:6): [True: 610, False: 1.86k]
  ------------------
 1556|    610|		caller_supplied_id = 1;
 1557|       |
 1558|       |		/* Make sure that private key's ID is the unique inside the PKCS#15 application */
 1559|    610|		r = sc_pkcs15_find_prkey_by_id(p15card, &keygen_args->prkey_args.id, NULL);
 1560|    610|		if (!r) {
  ------------------
  |  Branch (1560:7): [True: 1, False: 609]
  ------------------
 1561|      1|			r = SC_ERROR_NON_UNIQUE_ID;
  ------------------
  |  |  107|      1|#define SC_ERROR_NON_UNIQUE_ID			-1505
  ------------------
 1562|      1|			LOG_TEST_GOTO_ERR(ctx, r, "Non unique ID of the private key object");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1563|      1|		}
 1564|    609|		else if (r != SC_ERROR_OBJECT_NOT_FOUND) {
  ------------------
  |  |   88|    609|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1564:12): [True: 0, False: 609]
  ------------------
 1565|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Find private 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1566|      0|		}
 1567|    610|	}
 1568|       |
 1569|       |	/* Set up the PrKDF object */
 1570|  2.47k|	r = sc_pkcs15init_init_prkdf(p15card, profile, &keygen_args->prkey_args,
 1571|  2.47k|		&keygen_args->prkey_args.key, keybits, &object);
 1572|  2.47k|	LOG_TEST_GOTO_ERR(ctx, r, "Set up private key object error");
  ------------------
  |  |  184|  2.47k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.47k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.47k|	int _ret = (r); \
  |  |  |  |  178|  2.47k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 240, False: 2.23k]
  |  |  |  |  ------------------
  |  |  |  |  179|    240|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    240|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    240|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    240|		goto err; \
  |  |  |  |  182|    240|	} \
  |  |  |  |  183|  2.47k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1573|       |
 1574|  2.23k|	key_info = (struct sc_pkcs15_prkey_info *) object->data;
 1575|       |
 1576|  2.23k|	r = _pkcd15init_set_aux_md_data(p15card, &key_info->aux_data,
 1577|  2.23k|			keygen_args->prkey_args.guid, keygen_args->prkey_args.guid_len);
 1578|  2.23k|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to set aux MD data");
  ------------------
  |  |  184|  2.23k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.23k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.23k|	int _ret = (r); \
  |  |  |  |  178|  2.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2.23k]
  |  |  |  |  ------------------
  |  |  |  |  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.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1579|       |
 1580|       |	/* Set up the PuKDF info. The public key will be filled in
 1581|       |	 * by the card driver's generate_key function called below.
 1582|       |	 * Auth.ID of the public key object is left empty. */
 1583|  2.23k|	pubkey_args.id = keygen_args->prkey_args.id;
 1584|  2.23k|	pubkey_args.label = keygen_args->pubkey_label ? keygen_args->pubkey_label : object->label;
  ------------------
  |  Branch (1584:22): [True: 0, False: 2.23k]
  ------------------
 1585|  2.23k|	pubkey_args.usage = keygen_args->prkey_args.usage;
 1586|  2.23k|	pubkey_args.x509_usage = keygen_args->prkey_args.x509_usage;
 1587|  2.23k|	pubkey_args.key.algorithm = algorithm;
 1588|       |
 1589|  2.23k|	if (algorithm == SC_ALGORITHM_GOSTR3410)   {
  ------------------
  |  |   80|  2.23k|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1589:6): [True: 0, False: 2.23k]
  ------------------
 1590|      0|		pubkey_args.params.gost = keygen_args->prkey_args.params.gost;
 1591|      0|		r = sc_copy_gost_params(&(pubkey_args.key.u.gostr3410.params), &(keygen_args->prkey_args.key.u.gostr3410.params));
 1592|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate GOST 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1593|  2.23k|	} else if (algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   79|  4.46k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1593:13): [True: 676, False: 1.55k]
  ------------------
 1594|  1.55k|			algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   81|  3.79k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1594:4): [True: 0, False: 1.55k]
  ------------------
 1595|  1.55k|			algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   82|  1.55k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1595:4): [True: 0, False: 1.55k]
  ------------------
 1596|    676|		r = sc_copy_ec_params(&pubkey_args.key.u.ec.params, &keygen_args->prkey_args.key.u.ec.params);
 1597|    676|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate EC parameters");
  ------------------
  |  |  184|    676|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    676|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    676|	int _ret = (r); \
  |  |  |  |  178|    676|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 676]
  |  |  |  |  ------------------
  |  |  |  |  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|    676|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 676]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1598|    676|	}
 1599|       |
 1600|       |	/* Generate the private key on card */
 1601|  2.23k|	r = profile->ops->create_key(profile, p15card, object);
 1602|  2.23k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot generate key: create key failed");
  ------------------
  |  |  184|  2.23k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.23k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.23k|	int _ret = (r); \
  |  |  |  |  178|  2.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1.27k, False: 955]
  |  |  |  |  ------------------
  |  |  |  |  179|  1.27k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.27k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  1.27k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  1.27k|		goto err; \
  |  |  |  |  182|  1.27k|	} \
  |  |  |  |  183|  2.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 955]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1603|       |
 1604|    955|	r = profile->ops->generate_key(profile, p15card, object, &pubkey_args.key);
 1605|    955|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to generate key");
  ------------------
  |  |  184|    955|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    955|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    955|	int _ret = (r); \
  |  |  |  |  178|    955|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 906, False: 49]
  |  |  |  |  ------------------
  |  |  |  |  179|    906|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    906|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    906|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    906|		goto err; \
  |  |  |  |  182|    906|	} \
  |  |  |  |  183|    955|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 49]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1606|       |
 1607|       |	/* update PrKDF entry */
 1608|     49|	if (!caller_supplied_id)   {
  ------------------
  |  Branch (1608:6): [True: 30, False: 19]
  ------------------
 1609|     30|		struct sc_pkcs15_id iid;
 1610|       |
 1611|       |		/* Caller not supplied ID, so,
 1612|       |		 * if intrinsic ID can be calculated -- overwrite the native one */
 1613|     30|		memset(&iid, 0, sizeof(iid));
 1614|     30|		r = sc_pkcs15init_select_intrinsic_id(p15card, profile, SC_PKCS15_TYPE_PUBKEY, &iid, &pubkey_args.key);
  ------------------
  |  |  425|     30|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
 1615|     30|		LOG_TEST_GOTO_ERR(ctx, r, "Select intrinsic ID error");
  ------------------
  |  |  184|     30|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     30|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     30|	int _ret = (r); \
  |  |  |  |  178|     30|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 29]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 29]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1616|       |
 1617|     29|		if (iid.len)
  ------------------
  |  Branch (1617:7): [True: 6, False: 23]
  ------------------
 1618|      6|			key_info->id = iid;
 1619|     29|	}
 1620|     48|	pubkey = &pubkey_args.key;
 1621|     48|	if (!pubkey->alg_id)   {
  ------------------
  |  Branch (1621:6): [True: 48, False: 0]
  ------------------
 1622|     48|		pubkey->alg_id = calloc(1, sizeof(struct sc_algorithm_id));
 1623|     48|		if (!pubkey->alg_id) {
  ------------------
  |  Branch (1623:7): [True: 0, False: 48]
  ------------------
 1624|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1625|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Can not allocate memory for algorithm id");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1626|      0|		}
 1627|       |
 1628|     48|		sc_init_oid(&pubkey->alg_id->oid);
 1629|     48|		pubkey->alg_id->algorithm = pubkey->algorithm;
 1630|     48|	}
 1631|       |
 1632|     48|	pubkey_args.id = key_info->id;
 1633|     48|	r = sc_pkcs15_encode_pubkey(ctx, pubkey, &object->content.value, &object->content.len);
 1634|     48|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to encode public key");
  ------------------
  |  |  184|     48|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     48|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     48|	int _ret = (r); \
  |  |  |  |  178|     48|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 1, False: 47]
  |  |  |  |  ------------------
  |  |  |  |  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|     48|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 47]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1635|       |
 1636|     47|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_PRKDF, object);
  ------------------
  |  |  488|     47|#define SC_PKCS15_PRKDF			0
  ------------------
 1637|     47|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to add generated private key object");
  ------------------
  |  |  184|     47|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     47|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     47|	int _ret = (r); \
  |  |  |  |  178|     47|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 25, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     25|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     25|		goto err; \
  |  |  |  |  182|     25|	} \
  |  |  |  |  183|     47|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1638|       |
 1639|     22|	if (!r && profile->ops->emu_store_data)   {
  ------------------
  |  Branch (1639:6): [True: 22, False: 0]
  |  Branch (1639:12): [True: 3, False: 19]
  ------------------
 1640|      3|		r = profile->ops->emu_store_data(p15card, profile, object, NULL, NULL);
 1641|      3|		if (r == SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   97|      3|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  |  Branch (1641:7): [True: 0, False: 3]
  ------------------
 1642|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1643|      3|		if (r < 0)
  ------------------
  |  Branch (1643:7): [True: 0, False: 3]
  ------------------
 1644|      0|			sc_pkcs15_remove_object(p15card, object);
 1645|      3|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'store data' failed");
  ------------------
  |  |  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: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1646|      3|	}
 1647|       |
 1648|     22|	r = sc_pkcs15init_store_public_key(p15card, profile, &pubkey_args, NULL);
 1649|     22|	if (r < 0)
  ------------------
  |  Branch (1649:6): [True: 17, False: 5]
  ------------------
 1650|     17|		sc_pkcs15_remove_object(p15card, object);
 1651|     22|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to store public key");
  ------------------
  |  |  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: 17, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1652|       |
 1653|      5|	if (res_obj)
  ------------------
  |  Branch (1653:6): [True: 0, False: 5]
  ------------------
 1654|      0|		*res_obj = object;
 1655|      5|	object = NULL;
 1656|       |
 1657|      5|	profile->dirty = 1;
 1658|       |
 1659|  4.43k|err:
 1660|  4.43k|	sc_pkcs15_free_object(object);
 1661|  4.43k|	sc_pkcs15_erase_pubkey(&pubkey_args.key);
 1662|  4.43k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  4.43k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.43k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.43k|	int _ret = r; \
  |  |  |  |  155|  4.43k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.43k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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|  4.43k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.43k, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.43k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.43k|	} else { \
  |  |  |  |  159|      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.43k|	return _ret; \
  |  |  |  |  163|  4.43k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1663|  4.43k|}
sc_pkcs15init_generate_secret_key:
 1671|  6.65k|{
 1672|  6.65k|	struct sc_context *ctx = p15card->card->ctx;
 1673|  6.65k|	struct sc_pkcs15_object *object = NULL;
 1674|  6.65k|	unsigned int keybits = (unsigned int)skey_args->value_len;
 1675|  6.65k|	int r;
 1676|       |
 1677|  6.65k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  6.65k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.65k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.65k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.65k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.65k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1678|       |	/* check supported key size */
 1679|  6.65k|	r = check_keygen_params_consistency(p15card->card, skey_args->algorithm, NULL, &keybits);
 1680|  6.65k|	LOG_TEST_RET(ctx, r, "Invalid key size");
  ------------------
  |  |  174|  6.65k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  6.65k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  6.65k|	int _ret = (r); \
  |  |  |  |  168|  6.65k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6.09k, False: 563]
  |  |  |  |  ------------------
  |  |  |  |  169|  6.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|  6.09k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  6.09k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  6.09k|		return _ret; \
  |  |  |  |  172|  6.09k|	} \
  |  |  |  |  173|  6.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 563]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1681|       |
 1682|    563|	if (check_key_compatibility(p15card, skey_args->algorithm, NULL, 0,
  ------------------
  |  Branch (1682:6): [True: 563, False: 0]
  ------------------
 1683|    563|			keybits, SC_ALGORITHM_ONBOARD_KEY_GEN) != SC_SUCCESS)
  ------------------
  |  |  102|    563|#define SC_ALGORITHM_ONBOARD_KEY_GEN	0x80000000
  ------------------
              			keybits, SC_ALGORITHM_ONBOARD_KEY_GEN) != SC_SUCCESS)
  ------------------
  |  |   28|    563|#define SC_SUCCESS				0
  ------------------
 1684|    563|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Cannot generate key with the given parameters");
  ------------------
  |  |  174|    563|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    563|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    563|	int _ret = (r); \
  |  |  |  |  168|    563|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 563, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    563|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    563|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    563|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    563|		return _ret; \
  |  |  |  |  172|    563|	} \
  |  |  |  |  173|    563|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1685|       |
 1686|      0|	if (profile->ops->generate_key == NULL)
  ------------------
  |  Branch (1686:6): [True: 0, False: 0]
  ------------------
 1687|      0|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Key generation 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1688|       |
 1689|      0|	if (skey_args->id.len)   {
  ------------------
  |  Branch (1689:6): [True: 0, False: 0]
  ------------------
 1690|       |		/* Make sure that secret key's ID is the unique inside the PKCS#15 application */
 1691|      0|		r = sc_pkcs15_find_skey_by_id(p15card, &skey_args->id, NULL);
 1692|      0|		if (!r)
  ------------------
  |  Branch (1692:7): [True: 0, False: 0]
  ------------------
 1693|      0|			LOG_TEST_RET(ctx, SC_ERROR_NON_UNIQUE_ID, "Non unique ID of the private key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1694|      0|		else if (r != SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|      0|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1694:12): [True: 0, False: 0]
  ------------------
 1695|      0|			LOG_TEST_RET(ctx, r, "Find private key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1696|      0|	}
 1697|       |
 1698|       |	/* Set up the SKDF object */
 1699|      0|	r = sc_pkcs15init_init_skdf(p15card, profile, skey_args, &object);
 1700|      0|	LOG_TEST_GOTO_ERR(ctx, r, "Set up secret key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1701|       |
 1702|       |	/* Generate the secret key on card */
 1703|      0|	r = profile->ops->create_key(profile, p15card, object);
 1704|      0|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot generate key: create key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1705|       |
 1706|      0|	r = profile->ops->generate_key(profile, p15card, object, NULL);
 1707|      0|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to generate 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1708|       |
 1709|      0|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_SKDF, object);
  ------------------
  |  |  491|      0|#define SC_PKCS15_SKDF			3
  ------------------
 1710|      0|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to add generated secret key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1711|       |
 1712|      0|	if (!r && profile->ops->emu_store_data)   {
  ------------------
  |  Branch (1712:6): [True: 0, False: 0]
  |  Branch (1712:12): [True: 0, False: 0]
  ------------------
 1713|      0|		r = profile->ops->emu_store_data(p15card, profile, object, NULL, NULL);
 1714|      0|		if (r == SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  |  Branch (1714:7): [True: 0, False: 0]
  ------------------
 1715|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 1716|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'store data' 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1717|      0|	}
 1718|       |
 1719|      0|	if (res_obj)
  ------------------
  |  Branch (1719:6): [True: 0, False: 0]
  ------------------
 1720|      0|		*res_obj = object;
 1721|      0|	object = NULL;
 1722|       |
 1723|      0|	profile->dirty = 1;
 1724|       |
 1725|      0|err:
 1726|      0|	sc_pkcs15_free_object(object);
 1727|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1728|      0|}
sc_pkcs15init_store_public_key:
 1836|     22|{
 1837|     22|	struct sc_context *ctx = p15card->card->ctx;
 1838|     22|	struct sc_pkcs15_object *object = NULL;
 1839|     22|	struct sc_pkcs15_pubkey_info *key_info;
 1840|     22|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
 1841|     22|	struct sc_pkcs15_pubkey key;
 1842|     22|	struct sc_path	*path;
 1843|     22|	const char	*label;
 1844|     22|	unsigned int	type = 0;
 1845|     22|	unsigned int usage;
 1846|     22|	size_t keybits;
 1847|     22|	int		r;
 1848|       |
 1849|     22|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     22|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     22|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     22|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     22|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1850|     22|	if (!keyargs)
  ------------------
  |  Branch (1850:6): [True: 0, False: 22]
  ------------------
 1851|     22|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Store public key aborted");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1852|       |
 1853|       |	/* Create shallow a copy of the key first */
 1854|     22|	key = keyargs->key;
 1855|       |
 1856|       |	/* Copy algorithm id structure */
 1857|     22|	if (keyargs->key.alg_id) {
  ------------------
  |  Branch (1857:6): [True: 22, False: 0]
  ------------------
 1858|     22|		key.alg_id = calloc(1, sizeof(struct sc_algorithm_id));
 1859|     22|		if (!key.alg_id)
  ------------------
  |  Branch (1859:7): [True: 0, False: 22]
  ------------------
 1860|     22|			LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Can not allocate memory for algorithm 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1861|       |
 1862|     22|		key.alg_id->algorithm = keyargs->key.alg_id->algorithm;
 1863|     22|		memcpy(&key.alg_id->oid, &keyargs->key.alg_id->oid, sizeof(struct sc_object_id));
 1864|     22|	}
 1865|       |
 1866|       |	/* Copy algorithm related parameters */
 1867|     22|	switch (key.algorithm) {
 1868|     12|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   78|     12|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1868:2): [True: 12, False: 10]
  ------------------
 1869|     12|		key.u.rsa.modulus.data = NULL;
 1870|     12|		key.u.rsa.exponent.data = NULL;
 1871|       |		// copy RSA params
 1872|     12|		if (!(key.u.rsa.modulus.data = malloc(keyargs->key.u.rsa.modulus.len))) {
  ------------------
  |  Branch (1872:7): [True: 0, False: 12]
  ------------------
 1873|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1874|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Failed to copy RSA public key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1875|      0|		}
 1876|     12|		memcpy(key.u.rsa.modulus.data, keyargs->key.u.rsa.modulus.data, keyargs->key.u.rsa.modulus.len);
 1877|     12|		if (!(key.u.rsa.exponent.data = malloc(keyargs->key.u.rsa.exponent.len))) {
  ------------------
  |  Branch (1877:7): [True: 0, False: 12]
  ------------------
 1878|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1879|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Failed to copy RSA public key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1880|      0|		}
 1881|     12|		memcpy(key.u.rsa.exponent.data, keyargs->key.u.rsa.exponent.data, keyargs->key.u.rsa.exponent.len);
 1882|     12|		keybits = sc_pkcs15init_keybits(&key.u.rsa.modulus);
 1883|     12|		type = SC_PKCS15_TYPE_PUBKEY_RSA;
  ------------------
  |  |  426|     12|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
 1884|     12|		break;
 1885|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   80|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1885:2): [True: 0, False: 22]
  ------------------
 1886|      0|		key.u.gostr3410.xy.data = NULL;
 1887|       |		// copy GOSTR params
 1888|      0|		if (!(key.u.gostr3410.xy.data = malloc(keyargs->key.u.gostr3410.xy.len))) {
  ------------------
  |  Branch (1888:7): [True: 0, False: 0]
  ------------------
 1889|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1890|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Failed to copy GOSTR public key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1891|      0|		}
 1892|      0|		memcpy(key.u.gostr3410.xy.data, keyargs->key.u.gostr3410.xy.data, keyargs->key.u.gostr3410.xy.len);
 1893|      0|		keybits = SC_PKCS15_GOSTR3410_KEYSIZE;
  ------------------
  |  |  326|      0|#define SC_PKCS15_GOSTR3410_KEYSIZE             256
  ------------------
 1894|      0|		type = SC_PKCS15_TYPE_PUBKEY_GOSTR3410;
  ------------------
  |  |  427|      0|#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410		0x203
  ------------------
 1895|      0|		break;
 1896|     10|	case SC_ALGORITHM_EC:
  ------------------
  |  |   79|     10|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1896:2): [True: 10, False: 12]
  ------------------
 1897|     10|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   81|     10|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1897:2): [True: 0, False: 22]
  ------------------
 1898|     10|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   82|     10|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1898:2): [True: 0, False: 22]
  ------------------
 1899|       |
 1900|     10|		r = sc_copy_ec_params(&key.u.ec.params, &keyargs->key.u.ec.params);
 1901|     10|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to copy EC public key parameters");
  ------------------
  |  |  184|     10|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     10|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     10|	int _ret = (r); \
  |  |  |  |  178|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1902|     10|		r = sc_pkcs15_fix_ec_parameters(ctx, &key.u.ec.params);
 1903|     10|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to fix EC public key parameters");
  ------------------
  |  |  184|     10|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     10|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     10|	int _ret = (r); \
  |  |  |  |  178|     10|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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|     10|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 10]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1904|       |
 1905|     10|		if (key.algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   79|     10|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1905:7): [True: 10, False: 0]
  ------------------
 1906|     10|			type = SC_PKCS15_TYPE_PUBKEY_EC;
  ------------------
  |  |  428|     10|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
 1907|      0|		else if (key.algorithm == SC_ALGORITHM_EDDSA)
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1907:12): [True: 0, False: 0]
  ------------------
 1908|      0|			type = SC_PKCS15_TYPE_PUBKEY_EDDSA;
  ------------------
  |  |  429|      0|#define SC_PKCS15_TYPE_PUBKEY_EDDSA		0x205
  ------------------
 1909|      0|		else if (key.algorithm == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1909:12): [True: 0, False: 0]
  ------------------
 1910|      0|			type = SC_PKCS15_TYPE_PUBKEY_XEDDSA;
  ------------------
  |  |  430|      0|#define SC_PKCS15_TYPE_PUBKEY_XEDDSA		0x206
  ------------------
 1911|       |
 1912|     10|		keybits = key.u.ec.params.field_length;
 1913|     10|		break;
 1914|      0|	default:
  ------------------
  |  Branch (1914:2): [True: 0, False: 22]
  ------------------
 1915|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1916|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Unsupported key algorithm.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1917|     22|	}
 1918|       |
 1919|     22|	if ((usage = keyargs->usage) == 0) {
  ------------------
  |  Branch (1919:6): [True: 22, False: 0]
  ------------------
 1920|     22|		if (type == SC_PKCS15_TYPE_PUBKEY_XEDDSA) {
  ------------------
  |  |  430|     22|#define SC_PKCS15_TYPE_PUBKEY_XEDDSA		0x206
  ------------------
  |  Branch (1920:7): [True: 0, False: 22]
  ------------------
 1921|      0|			sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Setting default usage to derive");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1922|      0|			usage = SC_PKCS15_PRKEY_USAGE_DERIVE;
  ------------------
  |  |  313|      0|#define SC_PKCS15_PRKEY_USAGE_DERIVE		0x100
  ------------------
 1923|     22|		} else {
 1924|     22|			sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Setting default usage to verify");
  ------------------
  |  |   70|     22|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1925|     22|			usage = SC_PKCS15_PRKEY_USAGE_VERIFY;
  ------------------
  |  |  311|     22|#define SC_PKCS15_PRKEY_USAGE_VERIFY		0x40
  ------------------
 1926|     22|		}
 1927|     22|		if (keyargs->x509_usage) {
  ------------------
  |  Branch (1927:7): [True: 0, False: 22]
  ------------------
 1928|      0|			sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Setting usage from keyargs->x509_usage");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1929|      0|			usage = sc_pkcs15init_map_usage(keyargs->x509_usage, 0);
 1930|      0|		}
 1931|     22|	}
 1932|     22|	sc_debug(ctx, SC_LOG_DEBUG_NORMAL, "Usage: 0x%X", usage);
  ------------------
  |  |   70|     22|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1933|       |
 1934|     22|	label = keyargs->label;
 1935|     22|	if (!label)
  ------------------
  |  Branch (1935:6): [True: 0, False: 22]
  ------------------
 1936|      0|		label = "Public Key";
 1937|       |
 1938|       |	/* Set up the pkcs15 object. */
 1939|     22|	object = sc_pkcs15init_new_object(type, label, &keyargs->auth_id, NULL);
 1940|     22|	if (object == NULL) {
  ------------------
  |  Branch (1940:6): [True: 0, False: 22]
  ------------------
 1941|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1942|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate new public key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1943|      0|	}
 1944|       |
 1945|     22|	key_info = (struct sc_pkcs15_pubkey_info *) object->data;
 1946|     22|	key_info->usage = usage;
 1947|     22|	key_info->id = keyargs->id;
 1948|       |
 1949|     22|	if (key.algorithm == SC_ALGORITHM_RSA) {
  ------------------
  |  |   78|     22|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (1949:6): [True: 12, False: 10]
  ------------------
 1950|     12|		key_info->modulus_length = keybits;
 1951|     12|	} else if (key.algorithm == SC_ALGORITHM_GOSTR3410) {
  ------------------
  |  |   80|     10|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1951:13): [True: 0, False: 10]
  ------------------
 1952|      0|		key_info->params.len = sizeof(*keyinfo_gostparams);
 1953|       |		/* FIXME: malloc() call in pkcs15init, but free() call
 1954|       |		 * in libopensc (sc_pkcs15_free_prkey_info) */
 1955|      0|		key_info->params.data = malloc(key_info->params.len);
 1956|      0|		if (!key_info->params.data) {
  ------------------
  |  Branch (1956:7): [True: 0, False: 0]
  ------------------
 1957|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1958|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate GOST params");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1959|      0|		}
 1960|      0|		keyinfo_gostparams = key_info->params.data;
 1961|      0|		keyinfo_gostparams->gostr3410 = keyargs->params.gost.gostr3410;
 1962|      0|		keyinfo_gostparams->gostr3411 = keyargs->params.gost.gostr3411;
 1963|      0|		keyinfo_gostparams->gost28147 = keyargs->params.gost.gost28147;
 1964|     10|	} else if (key.algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   79|     20|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1964:13): [True: 10, False: 0]
  ------------------
 1965|      0|			key.algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   81|     10|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1965:4): [True: 0, False: 0]
  ------------------
 1966|     10|			key.algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1966:4): [True: 0, False: 0]
  ------------------
 1967|     10|		key_info->field_length = keybits;
 1968|       |		/* only SC_ALGORITHM_EC has ec_params with the EC curveName OID
 1969|       |		 * that becomes part of the SPKI algo params.
 1970|       |		 * EDDSA and XEDDSA ec_params have the OID of the EDDSA or XEDDSA
 1971|       |		 * which is used as the alg OID. But we still copy here
 1972|       |		 * as the asn1 routines will do the right thing based on key.algorithm.
 1973|       |		 */
 1974|     10|		if (key.u.ec.params.der.value) {
  ------------------
  |  Branch (1974:7): [True: 10, False: 0]
  ------------------
 1975|     10|			key_info->params.data = malloc(key.u.ec.params.der.len);
 1976|     10|			if (!key_info->params.data) {
  ------------------
  |  Branch (1976:8): [True: 0, False: 10]
  ------------------
 1977|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1978|      0|				LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate EC params");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1979|      0|			}
 1980|     10|			key_info->params.len = key.u.ec.params.der.len;
 1981|     10|			memcpy(key_info->params.data, key.u.ec.params.der.value, key.u.ec.params.der.len);
 1982|     10|		}
 1983|     10|		if (keyargs->key.u.ec.ecpointQ.value) {
  ------------------
  |  Branch (1983:7): [True: 10, False: 0]
  ------------------
 1984|     10|			key.u.ec.ecpointQ.value = malloc(keyargs->key.u.ec.ecpointQ.len);
 1985|     10|			if (!key.u.ec.ecpointQ.value) {
  ------------------
  |  Branch (1985:8): [True: 0, False: 10]
  ------------------
 1986|      0|				r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1987|      0|				LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate EC 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1988|      0|			}
 1989|     10|			key.u.ec.ecpointQ.len = keyargs->key.u.ec.ecpointQ.len;
 1990|     10|			memcpy(key.u.ec.ecpointQ.value, keyargs->key.u.ec.ecpointQ.value, key.u.ec.ecpointQ.len);
 1991|     10|		}
 1992|     10|	}
 1993|       |
 1994|       |	/* Select a intrinsic Key ID if the user didn't specify one */
 1995|     22|	r = sc_pkcs15init_select_intrinsic_id(p15card, profile, SC_PKCS15_TYPE_PUBKEY, &keyargs->id, &key);
  ------------------
  |  |  425|     22|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
 1996|     22|	LOG_TEST_GOTO_ERR(ctx, r, "Get intrinsic ID error");
  ------------------
  |  |  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: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1997|       |
 1998|       |	/* Select a Key ID if the user didn't specify one and there is no intrinsic ID,
 1999|       |	 * otherwise make sure it's unique */
 2000|     22|	r = select_id(p15card, SC_PKCS15_TYPE_PUBKEY, &keyargs->id);
  ------------------
  |  |  425|     22|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
 2001|     22|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to select public key object ID");
  ------------------
  |  |  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: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2002|       |
 2003|       |	/* Make sure that private key's ID is the unique inside the PKCS#15 application */
 2004|     22|	r = sc_pkcs15_find_pubkey_by_id(p15card, &keyargs->id, NULL);
 2005|     22|	if (!r) {
  ------------------
  |  Branch (2005:6): [True: 0, False: 22]
  ------------------
 2006|      0|		r = SC_ERROR_NON_UNIQUE_ID;
  ------------------
  |  |  107|      0|#define SC_ERROR_NON_UNIQUE_ID			-1505
  ------------------
 2007|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Non unique ID of the public key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2008|     22|	} else if (r != SC_ERROR_OBJECT_NOT_FOUND)  {
  ------------------
  |  |   88|     22|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (2008:13): [True: 0, False: 22]
  ------------------
 2009|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Find 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2010|      0|	}
 2011|       |
 2012|     22|	key_info->id = keyargs->id;
 2013|       |
 2014|       |	/* DER encode public key components */
 2015|     22|	r = sc_pkcs15_encode_pubkey(p15card->card->ctx, &key, &object->content.value, &object->content.len);
 2016|     22|	LOG_TEST_GOTO_ERR(ctx, r, "Encode public key error");
  ------------------
  |  |  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: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2017|       |
 2018|     22|	r = sc_pkcs15_encode_pubkey(p15card->card->ctx, &key, &key_info->direct.raw.value, &key_info->direct.raw.len);
 2019|     22|	LOG_TEST_GOTO_ERR(ctx, r, "RAW encode public key error");
  ------------------
  |  |  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: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2020|       |
 2021|       |	/* EC key are encoded as SPKI to preserve domain parameter */
 2022|     22|	r = sc_pkcs15_encode_pubkey_as_spki(p15card->card->ctx, &key, &key_info->direct.spki.value, &key_info->direct.spki.len);
 2023|     22|	LOG_TEST_GOTO_ERR(ctx, r, "SPKI encode public key error");
  ------------------
  |  |  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: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2024|       |
 2025|       |	/* Now create key file and store key */
 2026|     22|	if (type == SC_PKCS15_TYPE_PUBKEY_EC ||
  ------------------
  |  |  428|     44|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  |  Branch (2026:6): [True: 10, False: 12]
  ------------------
 2027|     12|			type == SC_PKCS15_TYPE_PUBKEY_EDDSA ||
  ------------------
  |  |  429|     34|#define SC_PKCS15_TYPE_PUBKEY_EDDSA		0x205
  ------------------
  |  Branch (2027:4): [True: 0, False: 12]
  ------------------
 2028|     12|			type == SC_PKCS15_TYPE_PUBKEY_XEDDSA)
  ------------------
  |  |  430|     12|#define SC_PKCS15_TYPE_PUBKEY_XEDDSA		0x206
  ------------------
  |  Branch (2028:4): [True: 0, False: 12]
  ------------------
 2029|     10|		r = sc_pkcs15init_store_data(p15card, profile, object, &key_info->direct.spki, &key_info->path);
 2030|     12|	else
 2031|     12|		r = sc_pkcs15init_store_data(p15card, profile, object, &object->content, &key_info->path);
 2032|       |
 2033|     22|	path = &key_info->path;
 2034|     22|	if (path->count == 0) {
  ------------------
  |  Branch (2034:6): [True: 6, False: 16]
  ------------------
 2035|      6|		path->index = 0;
 2036|      6|		path->count = -1;
 2037|      6|	}
 2038|       |
 2039|       |	/* Update the PuKDF */
 2040|     22|	if (r >= 0)
  ------------------
  |  Branch (2040:6): [True: 9, False: 13]
  ------------------
 2041|      9|		r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_PUKDF, object);
  ------------------
  |  |  489|      9|#define SC_PKCS15_PUKDF			1
  ------------------
 2042|     22|	LOG_TEST_GOTO_ERR(ctx, r, "Add object error");
  ------------------
  |  |  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: 17, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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|     22|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 5]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2043|       |
 2044|      5|	if (r >= 0 && res_obj)
  ------------------
  |  Branch (2044:6): [True: 5, False: 0]
  |  Branch (2044:16): [True: 0, False: 5]
  ------------------
 2045|      0|		*res_obj = object;
 2046|      5|	object = NULL;
 2047|       |
 2048|      5|	profile->dirty = 1;
 2049|       |
 2050|     22|err:
 2051|     22|	sc_pkcs15_erase_pubkey(&key);
 2052|     22|	sc_pkcs15_free_object(object);
 2053|     22|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|     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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2054|     22|}
sc_pkcs15init_store_secret_key:
 2063|  6.65k|{
 2064|  6.65k|	struct sc_context *ctx = p15card->card->ctx;
 2065|  6.65k|	struct sc_pkcs15_object *object = NULL;
 2066|  6.65k|	int r = 0;
 2067|       |
 2068|  6.65k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  6.65k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.65k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.65k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.65k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.65k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2069|       |
 2070|       |	/* Now check whether the card is able to handle this key */
 2071|  6.65k|	if (check_key_compatibility(p15card, keyargs->algorithm, NULL, 0, keyargs->value_len, 0) != SC_SUCCESS) {
  ------------------
  |  |   28|  6.65k|#define SC_SUCCESS				0
  ------------------
  |  Branch (2071:6): [True: 6.09k, False: 563]
  ------------------
 2072|       |		/* Make sure the caller explicitly tells us to store
 2073|       |		 * the key as extractable. */
 2074|  6.09k|		if (!(keyargs->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE))
  ------------------
  |  |  317|  6.09k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  |  Branch (2074:7): [True: 0, False: 6.09k]
  ------------------
 2075|  6.09k|			LOG_TEST_RET(ctx, SC_ERROR_INCOMPATIBLE_KEY, "Card does not support this key for crypto. Cannot store it as non extractable.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2076|  6.09k|	}
 2077|       |
 2078|  6.65k|#ifdef ENABLE_OPENSSL
 2079|  6.65k|	if (!keyargs->id.len) {
  ------------------
  |  Branch (2079:6): [True: 2.21k, False: 4.43k]
  ------------------
 2080|       |		/* Calculating intrinsic Key ID for secret key does not make
 2081|       |		 * sense - just generate random one */
 2082|  2.21k|		if (RAND_bytes(keyargs->id.value, 20) == 1)
  ------------------
  |  Branch (2082:7): [True: 2.21k, False: 0]
  ------------------
 2083|  2.21k|			keyargs->id.len = 20;
 2084|  2.21k|	}
 2085|  6.65k|#endif
 2086|       |
 2087|       |	/* Make sure that secret key's ID is the unique inside the PKCS#15 application */
 2088|  6.65k|	r = sc_pkcs15_find_skey_by_id(p15card, &keyargs->id, NULL);
 2089|  6.65k|	if (!r)
  ------------------
  |  Branch (2089:6): [True: 2, False: 6.65k]
  ------------------
 2090|  6.65k|		LOG_TEST_RET(ctx, SC_ERROR_NON_UNIQUE_ID, "Non unique ID of the secret key object");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2091|  6.65k|	else if (r != SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|  6.65k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (2091:11): [True: 0, False: 6.65k]
  ------------------
 2092|      0|		LOG_TEST_RET(ctx, r, "Find secret key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2093|       |
 2094|       |	/* Set up the SKDF object */
 2095|  6.65k|	r = sc_pkcs15init_init_skdf(p15card, profile, keyargs, &object);
 2096|  6.65k|	LOG_TEST_RET(ctx, r, "Failed to initialize secret key object");
  ------------------
  |  |  174|  6.65k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  6.65k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  6.65k|	int _ret = (r); \
  |  |  |  |  168|  6.65k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.35k, False: 4.30k]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.35k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.35k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.35k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.35k|		return _ret; \
  |  |  |  |  172|  2.35k|	} \
  |  |  |  |  173|  6.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.30k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2097|       |
 2098|  4.30k|	if (profile->ops->create_key)
  ------------------
  |  Branch (2098:6): [True: 4.30k, False: 0]
  ------------------
 2099|  4.30k|		r = profile->ops->create_key(profile, p15card, object);
 2100|  4.30k|	LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'create key' failed");
  ------------------
  |  |  184|  4.30k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  4.30k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  4.30k|	int _ret = (r); \
  |  |  |  |  178|  4.30k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 3.29k, False: 1.01k]
  |  |  |  |  ------------------
  |  |  |  |  179|  3.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|  3.29k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  3.29k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  3.29k|		goto err; \
  |  |  |  |  182|  3.29k|	} \
  |  |  |  |  183|  4.30k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.01k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2101|       |
 2102|       |	/* If no key data, only an empty EF is created.
 2103|       |	 * It can be used to receive an unwrapped key later. */
 2104|  1.01k|	if (keyargs->key.data_len > 0) {
  ------------------
  |  Branch (2104:6): [True: 1.01k, False: 0]
  ------------------
 2105|  1.01k|		if (profile->ops->store_key) {
  ------------------
  |  Branch (2105:7): [True: 1.01k, False: 0]
  ------------------
 2106|  1.01k|			struct sc_pkcs15_prkey key;
 2107|  1.01k|			memset(&key, 0, sizeof(key));
 2108|  1.01k|			key.algorithm = keyargs->algorithm;
 2109|  1.01k|			key.u.secret = keyargs->key;
 2110|  1.01k|			r = profile->ops->store_key(profile, p15card, object, &key);
 2111|  1.01k|		}
 2112|  1.01k|	}
 2113|  1.01k|	LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'store key' failed");
  ------------------
  |  |  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: 953, False: 58]
  |  |  |  |  ------------------
  |  |  |  |  179|    953|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    953|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    953|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    953|		goto err; \
  |  |  |  |  182|    953|	} \
  |  |  |  |  183|  1.01k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2114|       |
 2115|     58|	sc_pkcs15_free_object_content(object);
 2116|       |
 2117|       |	/* Now update the SKDF, unless it is a session object.
 2118|       |	   If we have an on card session object, we have created the actual key object on card.
 2119|       |	   The card handles removing it when the session is finished or during the next reset.
 2120|       |	   We will maintain the object in the P15 structure in memory for duration of the session,
 2121|       |	   but we don't want it to be written into SKDF. */
 2122|     58|	if (!object->session_object) {
  ------------------
  |  Branch (2122:6): [True: 58, False: 0]
  ------------------
 2123|     58|		r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_SKDF, object);
  ------------------
  |  |  491|     58|#define SC_PKCS15_SKDF			3
  ------------------
 2124|     58|		LOG_TEST_GOTO_ERR(ctx, r, "Failed to add new secret key PKCS#15 object");
  ------------------
  |  |  184|     58|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     58|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     58|	int _ret = (r); \
  |  |  |  |  178|     58|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 54, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  179|     54|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     54|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     54|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     54|		goto err; \
  |  |  |  |  182|     54|	} \
  |  |  |  |  183|     58|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2125|     58|	}
 2126|       |
 2127|      4|	if (!r && profile->ops->emu_store_data && !object->session_object)   {
  ------------------
  |  Branch (2127:6): [True: 4, False: 0]
  |  Branch (2127:12): [True: 0, False: 4]
  |  Branch (2127:44): [True: 0, False: 0]
  ------------------
 2128|      0|		r = profile->ops->emu_store_data(p15card, profile, object, NULL, NULL);
 2129|      0|		if (r == SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  |  Branch (2129:7): [True: 0, False: 0]
  ------------------
 2130|      0|			r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 2131|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Card specific 'store data' 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2132|      0|	}
 2133|       |
 2134|      4|	if (r >= 0 && res_obj)
  ------------------
  |  Branch (2134:6): [True: 4, False: 0]
  |  Branch (2134:16): [True: 0, False: 4]
  ------------------
 2135|      0|		*res_obj = object;
 2136|      4|	object = NULL;
 2137|       |
 2138|      4|	profile->dirty = 1;
 2139|       |
 2140|  4.30k|err:
 2141|  4.30k|	sc_pkcs15_free_object(object);
 2142|  4.30k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  4.30k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.30k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.30k|	int _ret = r; \
  |  |  |  |  155|  4.30k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.30k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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|  4.29k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 4.29k, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.30k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.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|  4.30k|	return _ret; \
  |  |  |  |  163|  4.30k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2143|  4.30k|}
sc_pkcs15init_store_data_object:
 2262|  2.21k|{
 2263|  2.21k|	struct sc_context *ctx = p15card->card->ctx;
 2264|  2.21k|	struct sc_pkcs15_data_info *data_object_info;
 2265|  2.21k|	struct sc_pkcs15_object *object;
 2266|  2.21k|	struct sc_pkcs15_object *objs[32];
 2267|  2.21k|	const char	*label;
 2268|  2.21k|	int		r, i;
 2269|  2.21k|	unsigned int    tid = 0x01;
 2270|       |
 2271|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2272|  2.21k|	if (!profile)
  ------------------
  |  Branch (2272:6): [True: 0, False: 2.21k]
  ------------------
 2273|  2.21k|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Missing profile");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2274|  2.21k|	label = args->label;
 2275|       |
 2276|  2.21k|	if (!args->id.len) {
  ------------------
  |  Branch (2276:6): [True: 2.21k, False: 0]
  ------------------
 2277|       |		/* Select an ID if the user didn't specify one, otherwise
 2278|       |		 * make sure it's unique (even though data objects doesn't
 2279|       |		 * have a pkcs15 id we need one here to create a unique
 2280|       |		 * file id from the data file template */
 2281|  2.21k|		r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_DATA_OBJECT, objs, 32);
  ------------------
  |  |  442|  2.21k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 2282|  2.21k|		LOG_TEST_RET(ctx, r, "Get 'DATA' objects error");
  ------------------
  |  |  174|  2.21k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.21k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.21k|	int _ret = (r); \
  |  |  |  |  168|  2.21k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.21k]
  |  |  |  |  ------------------
  |  |  |  |  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.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.21k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2283|       |
 2284|  2.23k|		for (i = 0; i < r; i++) {
  ------------------
  |  Branch (2284:15): [True: 17, False: 2.21k]
  ------------------
 2285|     17|			unsigned char cid;
 2286|     17|			struct sc_pkcs15_data_info *cinfo = (struct sc_pkcs15_data_info *) objs[i]->data;
 2287|     17|			if (!cinfo->path.len)
  ------------------
  |  Branch (2287:8): [True: 0, False: 17]
  ------------------
 2288|      0|				continue;
 2289|     17|			cid = cinfo->path.value[cinfo->path.len - 1];
 2290|     17|			if (cid >= tid)
  ------------------
  |  Branch (2290:8): [True: 10, False: 7]
  ------------------
 2291|     10|				tid = cid + 1;
 2292|     17|		}
 2293|  2.21k|		if (tid > 0xff)
  ------------------
  |  Branch (2293:7): [True: 0, False: 2.21k]
  ------------------
 2294|       |			/* too many data objects ... */
 2295|      0|			return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
 2296|  2.21k|		args->id.len = 1;
 2297|  2.21k|		args->id.value[0] = tid;
 2298|  2.21k|	}
 2299|      0|	else   {
 2300|       |		/* in case the user specifies an id it should be at most
 2301|       |		 * one byte long */
 2302|      0|		if (args->id.len > 1)
  ------------------
  |  Branch (2302:7): [True: 0, False: 0]
  ------------------
 2303|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2304|      0|	}
 2305|       |
 2306|  2.21k|	object = sc_pkcs15init_new_object(SC_PKCS15_TYPE_DATA_OBJECT, label, &args->auth_id, NULL);
  ------------------
  |  |  442|  2.21k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
 2307|  2.21k|	if (object == NULL)
  ------------------
  |  Branch (2307:6): [True: 0, False: 2.21k]
  ------------------
 2308|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2309|       |
 2310|  2.21k|	data_object_info = (struct sc_pkcs15_data_info *) object->data;
 2311|  2.21k|	if (args->app_label != NULL)
  ------------------
  |  Branch (2311:6): [True: 2.21k, False: 0]
  ------------------
 2312|  2.21k|		strlcpy(data_object_info->app_label, args->app_label, sizeof(data_object_info->app_label));
  ------------------
  |  |   43|  2.21k|#define strlcpy _strlcpy
  ------------------
 2313|      0|	else if (label != NULL)
  ------------------
  |  Branch (2313:11): [True: 0, False: 0]
  ------------------
 2314|      0|		strlcpy(data_object_info->app_label, label, sizeof(data_object_info->app_label));
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
 2315|       |
 2316|  2.21k|	data_object_info->app_oid = args->app_oid;
 2317|  2.21k|	sc_der_copy(&data_object_info->data, &args->der_encoded);
 2318|       |
 2319|  2.21k|	r = sc_pkcs15init_store_data(p15card, profile, object, &args->der_encoded, &data_object_info->path);
 2320|  2.21k|	LOG_TEST_GOTO_ERR(ctx, r, "Store 'DATA' object error");
  ------------------
  |  |  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: 2.07k, False: 146]
  |  |  |  |  ------------------
  |  |  |  |  179|  2.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|  2.07k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  2.07k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  2.07k|		goto err; \
  |  |  |  |  182|  2.07k|	} \
  |  |  |  |  183|  2.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 146]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2321|       |
 2322|       |	/* Now update the DDF */
 2323|    146|	r = sc_pkcs15init_add_object(p15card, profile, SC_PKCS15_DODF, object);
  ------------------
  |  |  495|    146|#define SC_PKCS15_DODF			7
  ------------------
 2324|    146|	LOG_TEST_GOTO_ERR(ctx, r, "'DODF' update error");
  ------------------
  |  |  184|    146|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    146|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    146|	int _ret = (r); \
  |  |  |  |  178|    146|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 93, False: 53]
  |  |  |  |  ------------------
  |  |  |  |  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|    146|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 53]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2325|       |
 2326|     53|	if (r >= 0 && res_obj)
  ------------------
  |  Branch (2326:6): [True: 53, False: 0]
  |  Branch (2326:16): [True: 0, False: 53]
  ------------------
 2327|      0|		*res_obj = object;
 2328|     53|	object = NULL;
 2329|       |
 2330|     53|	profile->dirty = 1;
 2331|       |
 2332|  2.21k|err:
 2333|  2.21k|	sc_pkcs15_free_object(object);
 2334|  2.21k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|  2.16k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.16k, False: 53]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2335|  2.21k|}
sc_pkcs15init_get_pin_reference:
 2341|  2.48k|{
 2342|  2.48k|	struct sc_context *ctx = p15card->card->ctx;
 2343|  2.48k|	struct sc_pkcs15_auth_info auth_info;
 2344|  2.48k|	struct sc_pkcs15_object *auth_objs[0x10];
 2345|  2.48k|	int r, ii, nn_objs;
 2346|       |
 2347|  2.48k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.48k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.48k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.48k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.48k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2348|       |
 2349|       |	/* 1. Look for the corresponding pkcs15 PIN object. */
 2350|       |
 2351|       |	/* Get all existing pkcs15 AUTH objects */
 2352|  2.48k|	r = sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_AUTH_PIN, auth_objs, 0x10);
  ------------------
  |  |  445|  2.48k|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 2353|  2.48k|	LOG_TEST_RET(ctx, r, "Get PKCS#15 AUTH objects error");
  ------------------
  |  |  174|  2.48k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.48k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.48k|	int _ret = (r); \
  |  |  |  |  168|  2.48k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.48k]
  |  |  |  |  ------------------
  |  |  |  |  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.48k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.48k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2354|  2.48k|	nn_objs = r;
 2355|       |
 2356|  2.48k|	sc_log(ctx, "found %i auth objects; looking for AUTH object(auth_method:%i,reference:%i)",
  ------------------
  |  |   71|  2.48k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2357|  2.48k|			nn_objs, auth_method, reference);
 2358|  3.83k|	for (ii=0; ii<nn_objs; ii++)   {
  ------------------
  |  Branch (2358:13): [True: 2.39k, False: 1.43k]
  ------------------
 2359|  2.39k|		struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *)auth_objs[ii]->data;
 2360|  2.39k|		struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
 2361|       |
 2362|  2.39k|		sc_log(ctx, "check PIN(%.*s,auth_method:%i,type:%i,reference:%i,flags:%X)",
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 2363|  2.39k|				(int) sizeof auth_objs[ii]->label, auth_objs[ii]->label, auth_info->auth_method, pin_attrs->type,
 2364|  2.39k|				pin_attrs->reference, pin_attrs->flags);
 2365|       |		/* Find out if there is AUTH pkcs15 object with given 'type' and 'reference' */
 2366|  2.39k|		if (auth_info->auth_method == auth_method && pin_attrs->reference == reference)
  ------------------
  |  Branch (2366:7): [True: 319, False: 2.07k]
  |  Branch (2366:48): [True: 162, False: 157]
  ------------------
 2367|  2.39k|			LOG_FUNC_RETURN(ctx, pin_attrs->reference);
  ------------------
  |  |  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: 8, False: 154]
  |  |  |  |  ------------------
  |  |  |  |  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|    154|	} else { \
  |  |  |  |  159|    154|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    154|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    154|	} \
  |  |  |  |  162|    162|	return _ret; \
  |  |  |  |  163|    162|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2368|       |
 2369|  2.23k|		if (auth_method != SC_AC_SYMBOLIC)
  ------------------
  |  |  155|  2.23k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (2369:7): [True: 232, False: 2.00k]
  ------------------
 2370|    232|			continue;
 2371|       |
 2372|       |		/* Translate 'SYMBOLIC' PIN reference into the pkcs#15 pinAttributes.flags
 2373|       |		 * 	and check for the existing pkcs15 PIN object with these flags. */
 2374|  2.00k|		switch (reference)   {
 2375|    900|		case SC_PKCS15INIT_USER_PIN:
  ------------------
  |  |  171|    900|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  |  Branch (2375:3): [True: 900, False: 1.10k]
  ------------------
 2376|    900|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|    900|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (2376:8): [True: 426, False: 474]
  ------------------
 2377|    426|				continue;
 2378|    474|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|    474|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (2378:8): [True: 13, False: 461]
  ------------------
 2379|     13|				continue;
 2380|    461|			break;
 2381|  1.10k|		case SC_PKCS15INIT_SO_PIN:
  ------------------
  |  |  169|  1.10k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  |  Branch (2381:3): [True: 1.10k, False: 900]
  ------------------
 2382|  1.10k|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|  1.10k|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (2382:8): [True: 217, False: 887]
  ------------------
 2383|    217|				continue;
 2384|    887|			if (!(pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN))
  ------------------
  |  |   61|    887|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (2384:8): [True: 461, False: 426]
  ------------------
 2385|    461|				continue;
 2386|    426|			break;
 2387|    426|		case SC_PKCS15INIT_USER_PUK:
  ------------------
  |  |  172|      0|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  |  Branch (2387:3): [True: 0, False: 2.00k]
  ------------------
 2388|      0|			if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (2388:8): [True: 0, False: 0]
  ------------------
 2389|      0|				continue;
 2390|      0|			if (!(pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN))
  ------------------
  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (2390:8): [True: 0, False: 0]
  ------------------
 2391|      0|				continue;
 2392|      0|			break;
 2393|      0|		case SC_PKCS15INIT_SO_PUK:
  ------------------
  |  |  170|      0|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  |  Branch (2393:3): [True: 0, False: 2.00k]
  ------------------
 2394|      0|			if (!(pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN))
  ------------------
  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (2394:8): [True: 0, False: 0]
  ------------------
 2395|      0|				continue;
 2396|      0|			if (!(pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN))
  ------------------
  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (2396:8): [True: 0, False: 0]
  ------------------
 2397|      0|				continue;
 2398|      0|			break;
 2399|      0|		default:
  ------------------
  |  Branch (2399:3): [True: 0, False: 2.00k]
  ------------------
 2400|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid Symbolic PIN reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2401|  2.00k|		}
 2402|       |
 2403|    887|		LOG_FUNC_RETURN(ctx, pin_attrs->reference);
  ------------------
  |  |  164|    887|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    887|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    887|	int _ret = r; \
  |  |  |  |  155|    887|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8, False: 879]
  |  |  |  |  ------------------
  |  |  |  |  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|    879|	} else { \
  |  |  |  |  159|    879|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    879|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    879|	} \
  |  |  |  |  162|    887|	return _ret; \
  |  |  |  |  163|    887|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2404|       |
 2405|    887|	}
 2406|       |
 2407|       |	/* 2. No existing pkcs15 PIN object
 2408|       |	 *	-- check if profile defines some PIN with 'reference' as PIN reference. */
 2409|  1.43k|	r = sc_profile_get_pin_id_by_reference(profile, auth_method, reference, &auth_info);
 2410|  1.43k|	if (r < 0)
  ------------------
  |  Branch (2410:6): [True: 376, False: 1.06k]
  ------------------
 2411|  1.43k|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "PIN template not found");
  ------------------
  |  |  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: 376, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    376|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    376|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    376|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    376|		return _ret; \
  |  |  |  |  172|    376|	} \
  |  |  |  |  173|    376|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2412|       |
 2413|  1.06k|	LOG_FUNC_RETURN(ctx, auth_info.attrs.pin.reference);
  ------------------
  |  |  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: 295, False: 767]
  |  |  |  |  ------------------
  |  |  |  |  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|    286|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 286, False: 9]
  |  |  |  |  ------------------
  |  |  |  |  157|    295|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    767|	} else { \
  |  |  |  |  159|    767|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    767|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    767|	} \
  |  |  |  |  162|  1.06k|	return _ret; \
  |  |  |  |  163|  1.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2414|  1.06k|}
sc_pkcs15init_select_intrinsic_id:
 2837|     52|{
 2838|       |#ifndef ENABLE_OPENSSL
 2839|       |	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
 2840|       |#else
 2841|     52|	struct sc_context *ctx = p15card->card->ctx;
 2842|     52|	struct sc_pkcs15_pubkey *pubkey = NULL;
 2843|     52|	unsigned id_style;
 2844|     52|	struct sc_pkcs15_id id;
 2845|     52|	unsigned char *id_data = NULL;
 2846|     52|	size_t id_data_len = 0;
 2847|     52|	int rv, allocated = 0;
 2848|       |
 2849|     52|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2850|       |
 2851|     52|	if (!id_out || !profile)
  ------------------
  |  Branch (2851:6): [True: 0, False: 52]
  |  Branch (2851:17): [True: 0, False: 52]
  ------------------
 2852|     52|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2853|       |
 2854|     52|	id_style = profile->id_style;
 2855|       |
 2856|       |	/* ID already exists */
 2857|     52|	if (id_out->len)
  ------------------
  |  Branch (2857:6): [True: 22, False: 30]
  ------------------
 2858|     52|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2859|       |
 2860|       |	/* Native ID style is not intrinsic one */
 2861|     30|	if (id_style == SC_PKCS15INIT_ID_STYLE_NATIVE)
  ------------------
  |  |  165|     30|#define SC_PKCS15INIT_ID_STYLE_NATIVE		0
  ------------------
  |  Branch (2861:6): [True: 22, False: 8]
  ------------------
 2862|     30|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2863|       |
 2864|      8|	memset(&id, 0, sizeof(id));
 2865|       |	/* Get PKCS15 public key */
 2866|      8|	switch(type)   {
 2867|      0|	case SC_PKCS15_TYPE_CERT_X509:
  ------------------
  |  |  439|      0|#define SC_PKCS15_TYPE_CERT_X509		0x401
  ------------------
  |  Branch (2867:2): [True: 0, False: 8]
  ------------------
 2868|      0|		rv = sc_pkcs15_pubkey_from_cert(ctx, (struct sc_pkcs15_der *)data, &pubkey);
 2869|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2870|      0|		allocated = 1;
 2871|      0|		break;
 2872|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2872:2): [True: 0, False: 8]
  ------------------
 2873|      0|		rv = sc_pkcs15_pubkey_from_prvkey(ctx, (struct sc_pkcs15_prkey *)data, &pubkey);
 2874|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2875|      0|		allocated = 1;
 2876|      0|		break;
 2877|      8|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      8|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (2877:2): [True: 8, False: 0]
  ------------------
 2878|      8|		pubkey = (struct sc_pkcs15_pubkey *)data;
 2879|      8|		allocated = 0;
 2880|      8|		break;
 2881|      0|	default:
  ------------------
  |  Branch (2881:2): [True: 0, False: 8]
  ------------------
 2882|      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__
  |  |  ------------------
  ------------------
 2883|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2884|      8|	}
 2885|       |
 2886|       |	/* Skip silently if key is not initialized. */
 2887|      8|	if (pubkey->algorithm == SC_ALGORITHM_RSA && !pubkey->u.rsa.modulus.len)
  ------------------
  |  |   78|     16|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2887:6): [True: 8, False: 0]
  |  Branch (2887:47): [True: 1, False: 7]
  ------------------
 2888|      1|		goto done;
 2889|      7|	else if (pubkey->algorithm == SC_ALGORITHM_GOSTR3410 &&
  ------------------
  |  |   80|     14|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (2889:11): [True: 0, False: 7]
  ------------------
 2890|      0|			!pubkey->u.gostr3410.xy.data)
  ------------------
  |  Branch (2890:4): [True: 0, False: 0]
  ------------------
 2891|      0|		goto done;
 2892|      7|	else if (pubkey->algorithm == SC_ALGORITHM_EC && !pubkey->u.ec.ecpointQ.value)
  ------------------
  |  |   79|     14|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2892:11): [True: 0, False: 7]
  |  Branch (2892:51): [True: 0, False: 0]
  ------------------
 2893|      0|		goto done;
 2894|       |
 2895|       |	/* In Mozilla 'GOST R 34.10' is not yet supported.
 2896|       |	 * So, switch to the ID recommended by RFC2459 */
 2897|      7|	if (pubkey->algorithm == SC_ALGORITHM_GOSTR3410 && id_style == SC_PKCS15INIT_ID_STYLE_MOZILLA)
  ------------------
  |  |   80|     14|#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 (2897:6): [True: 0, False: 7]
  |  Branch (2897:53): [True: 0, False: 0]
  ------------------
 2898|      0|		id_style = SC_PKCS15INIT_ID_STYLE_RFC2459;
  ------------------
  |  |  167|      0|#define SC_PKCS15INIT_ID_STYLE_RFC2459		2
  ------------------
 2899|       |
 2900|      7|	switch (id_style)  {
 2901|      5|	case SC_PKCS15INIT_ID_STYLE_MOZILLA:
  ------------------
  |  |  166|      5|#define SC_PKCS15INIT_ID_STYLE_MOZILLA		1
  ------------------
  |  Branch (2901:2): [True: 5, False: 2]
  ------------------
 2902|      5|		if (pubkey->algorithm == SC_ALGORITHM_RSA)
  ------------------
  |  |   78|      5|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2902:7): [True: 5, False: 0]
  ------------------
 2903|      5|			SHA1(pubkey->u.rsa.modulus.data, pubkey->u.rsa.modulus.len, id.value);
 2904|      0|		else if (pubkey->algorithm == SC_ALGORITHM_EC)
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2904:12): [True: 0, False: 0]
  ------------------
 2905|       |			/* ID should be SHA1 of the X coordinate according to PKCS#15 v1.1 */
 2906|       |			/* skip the 04 tag and get the X component */
 2907|      0|			SHA1(pubkey->u.ec.ecpointQ.value+1, (pubkey->u.ec.ecpointQ.len - 1) / 2, id.value);
 2908|      0|		else
 2909|      0|			goto done;
 2910|       |
 2911|      5|		id.len = SHA_DIGEST_LENGTH;
 2912|      5|		break;
 2913|      1|	case SC_PKCS15INIT_ID_STYLE_RFC2459:
  ------------------
  |  |  167|      1|#define SC_PKCS15INIT_ID_STYLE_RFC2459		2
  ------------------
  |  Branch (2913:2): [True: 1, False: 6]
  ------------------
 2914|      1|		rv = sc_pkcs15_encode_pubkey(ctx, pubkey, &id_data, &id_data_len);
 2915|      1|		LOG_TEST_GOTO_ERR(ctx, rv, "Encoding public key error");
  ------------------
  |  |  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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2916|       |
 2917|      1|		if (!id_data || !id_data_len) {
  ------------------
  |  Branch (2917:7): [True: 0, False: 1]
  |  Branch (2917:19): [True: 0, False: 1]
  ------------------
 2918|      0|			rv = SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 2919|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2920|      0|		}
 2921|       |
 2922|      1|		SHA1(id_data, id_data_len, id.value);
 2923|      1|		id.len = SHA_DIGEST_LENGTH;
 2924|       |
 2925|      1|		break;
 2926|      1|	default:
  ------------------
  |  Branch (2926:2): [True: 1, False: 6]
  ------------------
 2927|      1|		sc_log(ctx, "Unsupported ID style: %i", id_style);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 2928|      1|		rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      1|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2929|      1|		LOG_TEST_GOTO_ERR(ctx, rv, "Non supported ID style");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2930|      7|	}
 2931|       |
 2932|      7|done:
 2933|      7|	memcpy(id_out, &id, sizeof(*id_out));
 2934|      7|	rv = (int)id_out->len;
 2935|       |
 2936|      8|err:
 2937|      8|	if (id_data)
  ------------------
  |  Branch (2937:6): [True: 1, False: 7]
  ------------------
 2938|      1|		free(id_data);
 2939|      8|	if (allocated)
  ------------------
  |  Branch (2939:6): [True: 0, False: 8]
  ------------------
 2940|      0|		sc_pkcs15_free_pubkey(pubkey);
 2941|       |
 2942|      8|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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: 2, False: 6]
  |  |  |  |  ------------------
  |  |  |  |  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|      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|      8|	return _ret; \
  |  |  |  |  163|      8|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2943|      8|#endif
 2944|      8|}
sc_pkcs15init_update_any_df:
 3323|  1.18k|{
 3324|  1.18k|	struct sc_context	*ctx = p15card->card->ctx;
 3325|  1.18k|	struct sc_card	*card = p15card->card;
 3326|  1.18k|	struct sc_file	*file = NULL;
 3327|  1.18k|	unsigned char	*buf = NULL;
 3328|  1.18k|	size_t		bufsize = 0;
 3329|  1.18k|	int		update_odf = is_new, r = 0;
 3330|       |
 3331|  1.18k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.18k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.18k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.18k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.18k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.18k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3332|  1.18k|	if (!df)
  ------------------
  |  Branch (3332:6): [True: 0, False: 1.18k]
  ------------------
 3333|  1.18k|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "DF missing");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3334|       |
 3335|  1.18k|	r = sc_profile_get_file_by_path(profile, &df->path, &file);
 3336|  1.18k|	if (r < 0 || file == NULL)
  ------------------
  |  Branch (3336:6): [True: 83, False: 1.09k]
  |  Branch (3336:15): [True: 0, False: 1.09k]
  ------------------
 3337|     83|		sc_select_file(card, &df->path, &file);
 3338|       |
 3339|  1.18k|	r = sc_pkcs15_encode_df(card->ctx, p15card, df, &buf, &bufsize);
 3340|  1.18k|	if (r >= 0) {
  ------------------
  |  Branch (3340:6): [True: 1.16k, False: 14]
  ------------------
 3341|  1.16k|		r = sc_pkcs15init_update_file(profile, p15card, file, buf, bufsize);
 3342|       |
 3343|       |		/* For better performance and robustness, we want
 3344|       |		 * to note which portion of the file actually
 3345|       |		 * contains valid data.
 3346|       |		 *
 3347|       |		 * This is particularly useful if we store certificates
 3348|       |		 * directly in the CDF - we may want to make the CDF
 3349|       |		 * fairly big, without having to read the entire file
 3350|       |		 * every time we parse the CDF.
 3351|       |		 */
 3352|  1.16k|		if (profile->pkcs15.encode_df_length) {
  ------------------
  |  Branch (3352:7): [True: 62, False: 1.10k]
  ------------------
 3353|     62|			df->path.count = (int)bufsize;
 3354|     62|			df->path.index = 0;
 3355|     62|			update_odf = 1;
 3356|     62|		}
 3357|  1.16k|		free(buf);
 3358|  1.16k|	}
 3359|  1.18k|	sc_file_free(file);
 3360|       |
 3361|  1.18k|	LOG_TEST_RET(ctx, r, "Failed to encode or update xDF");
  ------------------
  |  |  174|  1.18k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.18k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.18k|	int _ret = (r); \
  |  |  |  |  168|  1.18k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 221, False: 960]
  |  |  |  |  ------------------
  |  |  |  |  169|    221|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    221|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    221|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    221|		return _ret; \
  |  |  |  |  172|    221|	} \
  |  |  |  |  173|  1.18k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 960]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3362|       |
 3363|       |	/* Now update the ODF if we have to */
 3364|    960|	if (update_odf)
  ------------------
  |  Branch (3364:6): [True: 929, False: 31]
  ------------------
 3365|    929|		r = sc_pkcs15init_update_odf(p15card, profile);
 3366|    960|	LOG_TEST_RET(ctx, r, "Failed to encode or update ODF");
  ------------------
  |  |  174|    960|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    960|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    960|	int _ret = (r); \
  |  |  |  |  168|    960|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 88, False: 872]
  |  |  |  |  ------------------
  |  |  |  |  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|    960|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 872]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3367|       |
 3368|    872|	LOG_FUNC_RETURN(ctx, r > 0 ? SC_SUCCESS : r);
  ------------------
  |  |  164|    872|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    872|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.74k|	int _ret = r; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (154:13): [True: 870, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  155|    872|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 872, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    872|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 872]
  |  |  |  |  ------------------
  |  |  |  |  157|    872|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    872|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    872|	return _ret; \
  |  |  |  |  163|    872|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3369|    872|}
sc_pkcs15init_add_object:
 3377|  1.45k|{
 3378|  1.45k|	struct sc_context *ctx = p15card->card->ctx;
 3379|  1.45k|	struct sc_pkcs15_df *df;
 3380|  1.45k|	int is_new = 0, r = 0, object_added = 0;
 3381|       |
 3382|  1.45k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.45k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.45k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.45k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.45k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.45k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3383|  1.45k|	sc_log(ctx, "add object %p to DF of type %u", object, df_type);
  ------------------
  |  |   71|  1.45k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3384|       |
 3385|  1.45k|	df = find_df_by_type(p15card, df_type);
 3386|  1.45k|	if (df == NULL) {
  ------------------
  |  Branch (3386:6): [True: 1.28k, False: 174]
  ------------------
 3387|  1.28k|		struct sc_file	*file;
 3388|  1.28k|		file = profile->df[df_type];
 3389|  1.28k|		if (file == NULL) {
  ------------------
  |  Branch (3389:7): [True: 196, False: 1.08k]
  ------------------
 3390|    196|			sc_log(ctx, "Profile doesn't define a DF file %u", df_type);
  ------------------
  |  |   71|    196|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3391|    196|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "DF not found in profile");
  ------------------
  |  |  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: 196, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    196|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    196|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    196|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    196|		return _ret; \
  |  |  |  |  172|    196|	} \
  |  |  |  |  173|    196|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3392|    196|		}
 3393|  1.08k|		sc_pkcs15_add_df(p15card, df_type, &file->path);
 3394|  1.08k|		df = find_df_by_type(p15card, df_type);
 3395|  1.08k|		if (df == NULL)
  ------------------
  |  Branch (3395:7): [True: 0, False: 1.08k]
  ------------------
 3396|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3397|  1.08k|		is_new = 1;
 3398|       |
 3399|       |		/* Mark the df as enumerated, so libopensc doesn't try
 3400|       |		 * to load the file at a most inconvenient moment */
 3401|  1.08k|		df->enumerated = 1;
 3402|  1.08k|	}
 3403|       |
 3404|  1.25k|	if (object == NULL) {
  ------------------
  |  Branch (3404:6): [True: 830, False: 429]
  ------------------
 3405|    830|		sc_log(ctx, "Add nothing; just instantiate this directory file");
  ------------------
  |  |   71|    830|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3406|    830|	}
 3407|    429|	else if (object->df == NULL) {
  ------------------
  |  Branch (3407:11): [True: 429, False: 0]
  ------------------
 3408|    429|		sc_log(ctx, "Append object");
  ------------------
  |  |   71|    429|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3409|    429|		object->df = df;
 3410|    429|		r = sc_pkcs15_add_object(p15card, object);
 3411|    429|		LOG_TEST_RET(ctx, r, "Failed to add pkcs15 object");
  ------------------
  |  |  174|    429|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    429|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    429|	int _ret = (r); \
  |  |  |  |  168|    429|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 429]
  |  |  |  |  ------------------
  |  |  |  |  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|    429|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 429]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3412|    429|		object_added = 1;
 3413|    429|	}
 3414|      0|	else {
 3415|      0|		sc_log(ctx, "Reuse existing object");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3416|      0|		if (object->df != df)
  ------------------
  |  Branch (3416:7): [True: 0, False: 0]
  ------------------
 3417|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 3418|      0|	}
 3419|       |
 3420|  1.25k|	if (profile->ops->emu_update_any_df)
  ------------------
  |  Branch (3420:6): [True: 78, False: 1.18k]
  ------------------
 3421|     78|		r = profile->ops->emu_update_any_df(profile, p15card, SC_AC_OP_CREATE, object);
  ------------------
  |  |  169|     78|#define SC_AC_OP_CREATE			3
  ------------------
 3422|  1.18k|	else
 3423|  1.18k|		r = sc_pkcs15init_update_any_df(p15card, profile, df, is_new);
 3424|       |
 3425|  1.25k|	if (r < 0 && object_added)
  ------------------
  |  Branch (3425:6): [True: 320, False: 939]
  |  Branch (3425:15): [True: 222, False: 98]
  ------------------
 3426|    222|		sc_pkcs15_remove_object(p15card, object);
 3427|       |
 3428|  1.25k|	LOG_FUNC_RETURN(ctx, r > 0 ? SC_SUCCESS : r);
  ------------------
  |  |  164|  1.25k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.25k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.51k|	int _ret = r; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (154:13): [True: 50, False: 1.20k]
  |  |  |  |  ------------------
  |  |  |  |  155|  1.25k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.25k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|    320|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 320, False: 939]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.25k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.25k|	return _ret; \
  |  |  |  |  163|  1.25k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3429|  1.25k|}
sc_pkcs15init_new_object:
 3434|  13.9k|{
 3435|  13.9k|	struct sc_pkcs15_object	*object;
 3436|  13.9k|	unsigned int data_size = 0;
 3437|       |
 3438|  13.9k|	object = calloc(1, sizeof(*object));
 3439|  13.9k|	if (object == NULL)
  ------------------
  |  Branch (3439:6): [True: 0, False: 13.9k]
  ------------------
 3440|      0|		return NULL;
 3441|  13.9k|	object->type = type;
 3442|       |
 3443|  13.9k|	switch (type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  13.9k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (3443:10): [True: 13.9k, False: 0]
  ------------------
 3444|  2.55k|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|  2.55k|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (3444:2): [True: 2.55k, False: 11.3k]
  ------------------
 3445|  2.55k|		object->flags = DEFAULT_PIN_FLAGS;
  ------------------
  |  |   78|  2.55k|#define DEFAULT_PIN_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   50|  2.55k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  |  |  ------------------
  |  |               #define DEFAULT_PIN_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|  2.55k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3446|  2.55k|		data_size = sizeof(struct sc_pkcs15_auth_info);
 3447|  2.55k|		break;
 3448|  2.47k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  2.47k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (3448:2): [True: 2.47k, False: 11.4k]
  ------------------
 3449|  2.47k|		object->flags = DEFAULT_PRKEY_FLAGS;
  ------------------
  |  |   79|  2.47k|#define DEFAULT_PRKEY_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   50|  2.47k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  |  |  ------------------
  |  |               #define DEFAULT_PRKEY_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|  2.47k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3450|  2.47k|		data_size = sizeof(struct sc_pkcs15_prkey_info);
 3451|  2.47k|		break;
 3452|  6.65k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  6.65k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (3452:2): [True: 6.65k, False: 7.26k]
  ------------------
 3453|  6.65k|		object->flags = DEFAULT_SKEY_FLAGS;
  ------------------
  |  |   81|  6.65k|#define DEFAULT_SKEY_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   50|  6.65k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  |  |  ------------------
  |  |               #define DEFAULT_SKEY_FLAGS		(SC_PKCS15_CO_FLAG_PRIVATE|SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|  6.65k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3454|  6.65k|		data_size = sizeof(struct sc_pkcs15_skey_info);
 3455|  6.65k|		break;
 3456|     22|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|     22|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (3456:2): [True: 22, False: 13.9k]
  ------------------
 3457|     22|		object->flags = DEFAULT_PUBKEY_FLAGS;
  ------------------
  |  |   80|     22|#define DEFAULT_PUBKEY_FLAGS		(SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|     22|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3458|     22|		data_size = sizeof(struct sc_pkcs15_pubkey_info);
 3459|     22|		break;
 3460|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (3460:2): [True: 0, False: 13.9k]
  ------------------
 3461|      0|		object->flags = DEFAULT_CERT_FLAGS;
  ------------------
  |  |   82|      0|#define DEFAULT_CERT_FLAGS		(SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|      0|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3462|      0|		data_size = sizeof(struct sc_pkcs15_cert_info);
 3463|      0|		break;
 3464|  2.21k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  2.21k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (3464:2): [True: 2.21k, False: 11.7k]
  ------------------
 3465|  2.21k|		object->flags = DEFAULT_DATA_FLAGS;
  ------------------
  |  |   83|  2.21k|#define DEFAULT_DATA_FLAGS		(SC_PKCS15_CO_FLAG_MODIFIABLE)
  |  |  ------------------
  |  |  |  |   51|  2.21k|#define SC_PKCS15_CO_FLAG_MODIFIABLE	0x00000002
  |  |  ------------------
  ------------------
 3466|  2.21k|		if (auth_id->len != 0)
  ------------------
  |  Branch (3466:7): [True: 0, False: 2.21k]
  ------------------
 3467|      0|			object->flags |= SC_PKCS15_CO_FLAG_PRIVATE;
  ------------------
  |  |   50|      0|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
 3468|  2.21k|		data_size = sizeof(struct sc_pkcs15_data_info);
 3469|  2.21k|		break;
 3470|  13.9k|	}
 3471|       |
 3472|  13.9k|	if (data_size) {
  ------------------
  |  Branch (3472:6): [True: 13.9k, False: 0]
  ------------------
 3473|  13.9k|		object->data = calloc(1, data_size);
 3474|  13.9k|		if (!object->data) {
  ------------------
  |  Branch (3474:7): [True: 0, False: 13.9k]
  ------------------
 3475|      0|			free(object);
 3476|      0|			return NULL;
 3477|      0|		}
 3478|       |
 3479|  13.9k|		if (data)
  ------------------
  |  Branch (3479:7): [True: 555, False: 13.3k]
  ------------------
 3480|    555|			memcpy(object->data, data, data_size);
 3481|  13.9k|	}
 3482|       |
 3483|  13.9k|	if (label)
  ------------------
  |  Branch (3483:6): [True: 13.9k, False: 0]
  ------------------
 3484|  13.9k|		strlcpy(object->label, label, sizeof(object->label));
  ------------------
  |  |   43|  13.9k|#define strlcpy _strlcpy
  ------------------
 3485|  13.9k|	if (auth_id)
  ------------------
  |  Branch (3485:6): [True: 11.3k, False: 2.55k]
  ------------------
 3486|  11.3k|		object->auth_id = *auth_id;
 3487|       |
 3488|  13.9k|	return object;
 3489|  13.9k|}
sc_pkcs15init_free_object:
 3494|  9.12k|{
 3495|  9.12k|	if (object) {
  ------------------
  |  Branch (3495:6): [True: 2.59k, False: 6.53k]
  ------------------
 3496|  2.59k|		free(object->data);
 3497|  2.59k|		free(object);
 3498|  2.59k|	}
 3499|  9.12k|}
sc_pkcs15init_verify_secret:
 3907|    346|{
 3908|    346|	struct sc_context *ctx = p15card->card->ctx;
 3909|    346|	struct sc_pkcs15_object *pin_obj = NULL;
 3910|    346|	struct sc_pkcs15_auth_info auth_info;
 3911|    346|	struct sc_path	*path;
 3912|    346|	int		r, use_pinpad = 0, pin_id = -1;
 3913|    346|	const char	*ident, *label = NULL;
 3914|    346|	unsigned char	pinbuf[0x100];
 3915|    346|	size_t		pinsize = 0;
 3916|       |
 3917|       |
 3918|    346|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    346|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    346|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    346|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    346|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 346]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3919|    346|	path = file? &file->path : NULL;
  ------------------
  |  Branch (3919:9): [True: 346, False: 0]
  ------------------
 3920|       |
 3921|    346|	ident = get_pin_ident_name(type, reference);
 3922|    346|	sc_log(ctx, "get and verify PIN('%s',type:0x%X,reference:0x%X)", ident, type, reference);
  ------------------
  |  |   71|    346|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3923|       |
 3924|    346|	if (type == SC_AC_SEN)   {
  ------------------
  |  |  156|    346|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (3924:6): [True: 8, False: 338]
  ------------------
 3925|      8|		r = sc_card_ctl(p15card->card, SC_CARDCTL_GET_CHV_REFERENCE_IN_SE, (void *)(&reference));
 3926|      8|		sc_log(ctx, "Card CTL(GET_CHV_REFERENCE_IN_SE) returned %i", r);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3927|      8|		if (r > 0)   {
  ------------------
  |  Branch (3927:7): [True: 0, False: 8]
  ------------------
 3928|      0|			sc_log(ctx, "CHV(ref:%i) found in SE(ref:%i)", r, 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__
  |  |  ------------------
  ------------------
 3929|      0|			type = SC_AC_CHV;
  ------------------
  |  |  151|      0|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 3930|      0|			reference = r;
 3931|      0|		}
 3932|      8|		else if (r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|      8|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (3932:12): [True: 2, False: 6]
  ------------------
 3933|      2|			LOG_TEST_RET(ctx, r, "Card CTL error: cannot get CHV reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3934|      8|	}
 3935|       |
 3936|    344|	memset(&auth_info, 0, sizeof(auth_info));
 3937|    344|	auth_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    344|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 3938|    344|	auth_info.auth_method = type;
 3939|    344|	auth_info.attrs.pin.reference = reference;
 3940|       |
 3941|    344|	pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, type, reference);
 3942|    344|	sc_log(ctx, "found PIN reference %i", pin_id);
  ------------------
  |  |   71|    344|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3943|    344|	if (type == SC_AC_SYMBOLIC) {
  ------------------
  |  |  155|    344|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (3943:6): [True: 1, False: 343]
  ------------------
 3944|      1|		if (pin_id == -1)
  ------------------
  |  Branch (3944:7): [True: 0, False: 1]
  ------------------
 3945|      1|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3946|      1|		reference = pin_id;
 3947|      1|		type = SC_AC_CHV;
  ------------------
  |  |  151|      1|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 3948|      1|		sc_log(ctx, "Symbolic PIN resolved to PIN(type:CHV,reference:%i)", reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3949|      1|	}
 3950|       |
 3951|    344|	if (path && path->len && path->len <= SC_MAX_PATH_SIZE) {
  ------------------
  |  |   47|    339|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (3951:6): [True: 344, False: 0]
  |  Branch (3951:14): [True: 339, False: 5]
  |  Branch (3951:27): [True: 339, False: 0]
  ------------------
 3952|    339|		struct sc_path tmp_path = *path;
 3953|    339|		int iter;
 3954|    339|		r = SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|    339|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
 3955|  1.26k|		for (iter = (int)tmp_path.len/2; iter >= 0 && r == SC_ERROR_OBJECT_NOT_FOUND; iter--, tmp_path.len -= 2) {
  ------------------
  |  |   88|    980|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (3955:36): [True: 980, False: 284]
  |  Branch (3955:49): [True: 925, False: 55]
  ------------------
 3956|    925|			r = sc_pkcs15_find_pin_by_type_and_reference(p15card,
 3957|    925|					tmp_path.len ? &tmp_path : NULL,
  ------------------
  |  Branch (3957:6): [True: 641, False: 284]
  ------------------
 3958|    925|					type, reference, &pin_obj);
 3959|    925|		}
 3960|    339|	}
 3961|      5|	else {
 3962|      5|		r = sc_pkcs15_find_pin_by_type_and_reference(p15card, NULL, type, reference, &pin_obj);
 3963|      5|	}
 3964|       |
 3965|    344|	if (!r && pin_obj)   {
  ------------------
  |  Branch (3965:6): [True: 162, False: 182]
  |  Branch (3965:12): [True: 162, False: 0]
  ------------------
 3966|    162|		memcpy(&auth_info, pin_obj->data, sizeof(auth_info));
 3967|    162|		sc_log(ctx, "found PIN object '%.*s'", (int) sizeof pin_obj->label, pin_obj->label);
  ------------------
  |  |   71|    162|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3968|    162|	}
 3969|       |
 3970|    344|	if (pin_obj)   {
  ------------------
  |  Branch (3970:6): [True: 162, False: 182]
  ------------------
 3971|    162|		sc_log(ctx,
  ------------------
  |  |   71|    162|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3972|    162|		       "PIN object '%.*s'; pin_obj->content.len:%"SC_FORMAT_LEN_SIZE_T"u",
 3973|    162|		       (int) sizeof pin_obj->label, pin_obj->label,
 3974|    162|		       pin_obj->content.len);
 3975|    162|		if (pin_obj->content.value && pin_obj->content.len)   {
  ------------------
  |  Branch (3975:7): [True: 3, False: 159]
  |  Branch (3975:33): [True: 3, False: 0]
  ------------------
 3976|      3|			if (pin_obj->content.len > sizeof(pinbuf))
  ------------------
  |  Branch (3976:8): [True: 0, False: 3]
  ------------------
 3977|      3|				LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "PIN buffer is 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3978|      3|			memcpy(pinbuf, pin_obj->content.value, pin_obj->content.len);
 3979|      3|			pinsize = pin_obj->content.len;
 3980|      3|			sc_log(ctx, "'ve got '%s' value from cache", ident);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 3981|      3|			goto found;
 3982|      3|		}
 3983|    162|	}
 3984|       |
 3985|    341|	if (pin_obj && pin_obj->label[0])
  ------------------
  |  Branch (3985:6): [True: 159, False: 182]
  |  Branch (3985:17): [True: 159, False: 0]
  ------------------
 3986|    159|		label = pin_obj->label;
 3987|       |
 3988|    341|	switch (type) {
 3989|    294|	case SC_AC_CHV:
  ------------------
  |  |  151|    294|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (3989:2): [True: 294, False: 47]
  ------------------
 3990|    294|		if (callbacks.get_pin)   {
  ------------------
  |  Branch (3990:7): [True: 0, False: 294]
  ------------------
 3991|      0|			pinsize = sizeof(pinbuf);
 3992|      0|			r = callbacks.get_pin(profile, pin_id, &auth_info, label, pinbuf, &pinsize);
 3993|      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__
  |  |  ------------------
  ------------------
 3994|      0|			       "'get_pin' callback returned %i; pinsize:%"SC_FORMAT_LEN_SIZE_T"u",
 3995|      0|			       r, pinsize);
 3996|      0|		}
 3997|    294|		break;
 3998|     19|	case SC_AC_SCB:
  ------------------
  |  |  157|     19|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (3998:2): [True: 19, False: 322]
  ------------------
 3999|     19|	case SC_AC_PRO:
  ------------------
  |  |  153|     19|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (3999:2): [True: 0, False: 341]
  ------------------
 4000|     19|		pinsize = 0;
 4001|     19|		r = 0;
 4002|     19|		break;
 4003|     28|	default:
  ------------------
  |  Branch (4003:2): [True: 28, False: 313]
  ------------------
 4004|     28|		pinsize = sizeof(pinbuf);
 4005|     28|		r = sc_pkcs15init_get_transport_key(profile, p15card, type, reference, pinbuf, &pinsize);
 4006|     28|		break;
 4007|    341|	}
 4008|       |
 4009|    341|	if (r == SC_ERROR_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   88|    341|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (4009:6): [True: 135, False: 206]
  ------------------
 4010|    135|		if (p15card->card->reader->capabilities & SC_READER_CAP_PIN_PAD)
  ------------------
  |  |  383|    135|#define SC_READER_CAP_PIN_PAD	0x00000002
  ------------------
  |  Branch (4010:7): [True: 0, False: 135]
  ------------------
 4011|      0|			r = 0, use_pinpad = 1;
 4012|    135|		else
 4013|    135|			r = SC_ERROR_SECURITY_STATUS_NOT_SATISFIED;
  ------------------
  |  |   61|    135|#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED	-1211
  ------------------
 4014|    135|	}
 4015|       |
 4016|    341|	LOG_TEST_RET(ctx, r, "Failed to get secret");
  ------------------
  |  |  174|    341|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    341|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    341|	int _ret = (r); \
  |  |  |  |  168|    341|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 162, False: 179]
  |  |  |  |  ------------------
  |  |  |  |  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|    341|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 179]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4017|    179|	if (type == SC_AC_PRO)   {
  ------------------
  |  |  153|    179|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (4017:6): [True: 0, False: 179]
  ------------------
 4018|      0|		sc_log(ctx, "No 'verify' for secure messaging");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4019|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4020|      0|	}
 4021|       |
 4022|    182|found:
 4023|    182|	if (pin_obj)   {
  ------------------
  |  Branch (4023:6): [True: 162, False: 20]
  ------------------
 4024|       |		/*
 4025|       |		 * If pin cache is disabled or the reader is using pinpad, we can get here
 4026|       |		 * with no PIN data. This is ok as we can not asynchronously invoke the prompt
 4027|       |		 * (unless the pinpad is in use).
 4028|       |		 * In this case, check if the PIN has been already verified and
 4029|       |		 * the access condition is still open on card.
 4030|       |		 */
 4031|    162|		if (pinsize == 0) {
  ------------------
  |  Branch (4031:7): [True: 159, False: 3]
  ------------------
 4032|    159|			r = sc_pkcs15_get_pin_info(p15card, pin_obj);
 4033|       |			/* update local copy of auth info */
 4034|    159|			memcpy(&auth_info, pin_obj->data, sizeof(auth_info));
 4035|       |
 4036|    159|			if (r == SC_SUCCESS && auth_info.logged_in & SC_PIN_STATE_LOGGED_IN)
  ------------------
  |  |   28|    318|#define SC_SUCCESS				0
  ------------------
              			if (r == SC_SUCCESS && auth_info.logged_in & SC_PIN_STATE_LOGGED_IN)
  ------------------
  |  |  439|     99|#define SC_PIN_STATE_LOGGED_IN  2
  ------------------
  |  Branch (4036:8): [True: 99, False: 60]
  |  Branch (4036:27): [True: 99, False: 0]
  ------------------
 4037|    159|				LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|     99|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|     99|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|     99|	int _ret = r; \
  |  |  |  |  155|     99|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 99, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|     99|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 99]
  |  |  |  |  ------------------
  |  |  |  |  157|     99|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|     99|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|     99|	return _ret; \
  |  |  |  |  163|     99|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4038|    159|		}
 4039|       |
 4040|     63|		r = sc_pkcs15_verify_pin(p15card, pin_obj, use_pinpad || pinsize == 0 ? NULL : pinbuf, use_pinpad ? 0 : pinsize);
  ------------------
  |  Branch (4040:46): [True: 0, False: 63]
  |  Branch (4040:60): [True: 60, False: 3]
  |  Branch (4040:90): [True: 0, False: 63]
  ------------------
 4041|     63|		LOG_TEST_RET(ctx, r, "Cannot validate pkcs15 PIN");
  ------------------
  |  |  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: 56, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  169|     56|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     56|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     56|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     56|		return _ret; \
  |  |  |  |  172|     56|	} \
  |  |  |  |  173|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4042|     63|	}
 4043|       |
 4044|     27|	if (file)   {
  ------------------
  |  Branch (4044:6): [True: 27, False: 0]
  ------------------
 4045|     27|		r = sc_select_file(p15card->card, &file->path, NULL);
 4046|     27|		LOG_TEST_RET(ctx, r, "Failed to select PIN path");
  ------------------
  |  |  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: 5, False: 22]
  |  |  |  |  ------------------
  |  |  |  |  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|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 22]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4047|     27|	}
 4048|       |
 4049|     22|	if (!pin_obj) {
  ------------------
  |  Branch (4049:6): [True: 16, False: 6]
  ------------------
 4050|     16|		struct sc_pin_cmd_data pin_cmd;
 4051|       |
 4052|     16|		memset(&pin_cmd, 0, sizeof(pin_cmd));
 4053|     16|		pin_cmd.cmd = SC_PIN_CMD_VERIFY;
  ------------------
  |  |  422|     16|#define SC_PIN_CMD_VERIFY	0
  ------------------
 4054|     16|		pin_cmd.pin_type = type;
 4055|     16|		pin_cmd.pin_reference = reference;
 4056|     16|		pin_cmd.pin1.data = use_pinpad ? NULL : pinbuf;
  ------------------
  |  Branch (4056:23): [True: 0, False: 16]
  ------------------
 4057|     16|		pin_cmd.pin1.len = use_pinpad ? 0: pinsize;
  ------------------
  |  Branch (4057:22): [True: 0, False: 16]
  ------------------
 4058|       |
 4059|     16|		r = sc_pin_cmd(p15card->card, &pin_cmd);
 4060|     16|		LOG_TEST_RET(ctx, r, "'VERIFY' pin cmd 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: 9, False: 7]
  |  |  |  |  ------------------
  |  |  |  |  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|     16|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 7]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4061|     16|	}
 4062|       |
 4063|     13|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4064|     13|}
sc_pkcs15init_authenticate:
 4083|  5.45k|{
 4084|  5.45k|	struct sc_context *ctx = p15card->card->ctx;
 4085|  5.45k|	const struct sc_acl_entry *acl = NULL;
 4086|  5.45k|	struct sc_file *file_tmp = NULL;
 4087|  5.45k|	int  r = 0;
 4088|       |
 4089|  5.45k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  5.45k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  5.45k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  5.45k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  5.45k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 5.45k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4090|  5.45k|	if (file == NULL)
  ------------------
  |  Branch (4090:6): [True: 0, False: 5.45k]
  ------------------
 4091|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4092|  5.45k|	sc_log(ctx, "path '%s', op=%u", sc_print_path(&file->path), op);
  ------------------
  |  |   71|  5.45k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4093|       |
 4094|  5.45k|	if (file->acl_inactive) {
  ------------------
  |  Branch (4094:6): [True: 2.73k, False: 2.72k]
  ------------------
 4095|  2.73k|		sc_log(ctx, "access control mechanism is not active (always allowed)");
  ------------------
  |  |   71|  2.73k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4096|  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2.73k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4097|  2.73k|	}
 4098|       |
 4099|  2.72k|	if (p15card->card->caps & SC_CARD_CAP_USE_FCI_AC) {
  ------------------
  |  |  564|  2.72k|#define SC_CARD_CAP_USE_FCI_AC		0x00000010
  ------------------
  |  Branch (4099:6): [True: 672, False: 2.05k]
  ------------------
 4100|    672|		r = sc_select_file(p15card->card, &file->path, &file_tmp);
 4101|    672|		LOG_TEST_RET(ctx, r, "Authentication failed: cannot select file.");
  ------------------
  |  |  174|    672|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    672|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    672|	int _ret = (r); \
  |  |  |  |  168|    672|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 415, False: 257]
  |  |  |  |  ------------------
  |  |  |  |  169|    415|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    415|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    415|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    415|		return _ret; \
  |  |  |  |  172|    415|	} \
  |  |  |  |  173|    672|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 257]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4102|       |
 4103|    257|		acl = sc_file_get_acl_entry(file_tmp, op);
 4104|    257|	}
 4105|  2.05k|	else   {
 4106|  2.05k|		acl = sc_file_get_acl_entry(file, op);
 4107|  2.05k|	}
 4108|  2.30k|	sc_log(ctx, "acl %p",acl);
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 4109|       |
 4110|  2.65k|	for (; r == 0 && acl; acl = acl->next) {
  ------------------
  |  Branch (4110:9): [True: 2.42k, False: 234]
  |  Branch (4110:19): [True: 718, False: 1.70k]
  ------------------
 4111|    718|		if (acl->method == SC_AC_NEVER)   {
  ------------------
  |  |  163|    718|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (4111:7): [True: 11, False: 707]
  ------------------
 4112|     11|			sc_file_free(file_tmp);
 4113|     11|			LOG_TEST_RET(ctx, SC_ERROR_SECURITY_STATUS_NOT_SATISFIED, "Authentication failed: never allowed");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4114|     11|		}
 4115|    707|		else if (acl->method == SC_AC_NONE)   {
  ------------------
  |  |  150|    707|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (4115:12): [True: 352, False: 355]
  ------------------
 4116|    352|			sc_log(ctx, "always allowed");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4117|    352|			break;
 4118|    352|		}
 4119|    355|		else if (acl->method == SC_AC_UNKNOWN)  {
  ------------------
  |  |  162|    355|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  |  Branch (4119:12): [True: 9, False: 346]
  ------------------
 4120|      9|			sc_log(ctx, "unknown acl method");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4121|      9|			break;
 4122|      9|		}
 4123|    346|		sc_log(ctx, "verify acl(method:%i,reference:%i)", acl->method, acl->key_ref);
  ------------------
  |  |   71|    346|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4124|    346|		r = sc_pkcs15init_verify_secret(profile, p15card, file_tmp ? file_tmp : file, acl->method, acl->key_ref);
  ------------------
  |  Branch (4124:53): [True: 10, False: 336]
  ------------------
 4125|    346|	}
 4126|       |
 4127|  2.29k|	sc_file_free(file_tmp);
 4128|       |
 4129|  2.29k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  2.29k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.29k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.29k|	int _ret = r; \
  |  |  |  |  155|  2.29k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.29k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|    234|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 234, False: 2.06k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.29k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.29k|	return _ret; \
  |  |  |  |  163|  2.29k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4130|  2.29k|}
sc_pkcs15init_create_file:
 4194|  2.44k|{
 4195|  2.44k|	struct sc_context *ctx = p15card->card->ctx;
 4196|  2.44k|	struct sc_file	*parent = NULL;
 4197|  2.44k|	int		r;
 4198|       |
 4199|  2.44k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.44k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.44k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.44k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.44k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.44k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4200|  2.44k|	if (!file) {
  ------------------
  |  Branch (4200:6): [True: 0, False: 2.44k]
  ------------------
 4201|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 4202|      0|	}
 4203|       |
 4204|  2.44k|	sc_log(ctx, "create file '%s'", sc_print_path(&file->path));
  ------------------
  |  |   71|  2.44k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4205|       |	/* Select parent DF and verify PINs/key as necessary */
 4206|  2.44k|	r = do_select_parent(profile, p15card, file, &parent);
 4207|  2.44k|	LOG_TEST_RET(ctx, r, "Cannot create file: select parent error");
  ------------------
  |  |  174|  2.44k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.44k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.44k|	int _ret = (r); \
  |  |  |  |  168|  2.44k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 464, False: 1.98k]
  |  |  |  |  ------------------
  |  |  |  |  169|    464|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    464|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    464|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    464|		return _ret; \
  |  |  |  |  172|    464|	} \
  |  |  |  |  173|  2.44k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.98k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4208|       |
 4209|  1.98k|	r = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_CREATE);
  ------------------
  |  |  169|  1.98k|#define SC_AC_OP_CREATE			3
  ------------------
 4210|  1.98k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot create file: 'CREATE' authentication failed");
  ------------------
  |  |  184|  1.98k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.98k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.98k|	int _ret = (r); \
  |  |  |  |  178|  1.98k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 88, False: 1.89k]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     88|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     88|		goto err; \
  |  |  |  |  182|     88|	} \
  |  |  |  |  183|  1.98k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.89k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4211|       |
 4212|       |	/* Fix up the file's ACLs */
 4213|  1.89k|	r = sc_pkcs15init_fixup_file(profile, p15card, file);
 4214|  1.89k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot create file: file fixup failed");
  ------------------
  |  |  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: 7, False: 1.88k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.89k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.88k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4215|       |
 4216|       |	/* ensure we are in the correct lifecycle */
 4217|  1.88k|	r = sc_pkcs15init_set_lifecycle(p15card->card, SC_CARDCTRL_LIFECYCLE_ADMIN);
 4218|  1.88k|	if (r != SC_ERROR_NOT_SUPPORTED)
  ------------------
  |  |   89|  1.88k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (4218:6): [True: 45, False: 1.84k]
  ------------------
 4219|  1.88k|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot create file: failed to set lifecycle 'ADMIN'");
  ------------------
  |  |  184|     45|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     45|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     45|	int _ret = (r); \
  |  |  |  |  178|     45|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 45]
  |  |  |  |  ------------------
  |  |  |  |  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|     45|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 45]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4220|       |
 4221|  1.88k|	r = sc_create_file(p15card->card, file);
 4222|  1.88k|	LOG_TEST_GOTO_ERR(ctx, r, "Create file failed");
  ------------------
  |  |  184|  1.88k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  1.88k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  1.88k|	int _ret = (r); \
  |  |  |  |  178|  1.88k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 181, False: 1.70k]
  |  |  |  |  ------------------
  |  |  |  |  179|    181|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    181|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    181|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    181|		goto err; \
  |  |  |  |  182|    181|	} \
  |  |  |  |  183|  1.88k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 1.70k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4223|       |
 4224|  1.98k|err:
 4225|  1.98k|	sc_file_free(parent);
 4226|  1.98k|	LOG_FUNC_RETURN(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|    276|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 276, False: 1.70k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4227|  1.98k|}
sc_pkcs15init_update_file:
 4234|  2.78k|{
 4235|  2.78k|	struct sc_context *ctx = p15card->card->ctx;
 4236|  2.78k|	struct sc_file	*selected_file = NULL;
 4237|  2.78k|	void		*copy = NULL;
 4238|  2.78k|	int		r, need_to_zap = 0;
 4239|       |
 4240|  2.78k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.78k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4241|  2.78k|	if (!file)
  ------------------
  |  Branch (4241:6): [True: 59, False: 2.72k]
  ------------------
 4242|  2.78k|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4243|       |
 4244|  2.72k|	sc_log(ctx, "path:%s; datalen:%zu", sc_print_path(&file->path), datalen);
  ------------------
  |  |   71|  2.72k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4245|       |
 4246|  2.72k|	r = sc_select_file(p15card->card, &file->path, &selected_file);
 4247|  2.72k|	if (!r)   {
  ------------------
  |  Branch (4247:6): [True: 988, False: 1.73k]
  ------------------
 4248|    988|		need_to_zap = 1;
 4249|    988|	}
 4250|  1.73k|	else if (r == SC_ERROR_FILE_NOT_FOUND)   {
  ------------------
  |  |   51|  1.73k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (4250:11): [True: 1.35k, False: 381]
  ------------------
 4251|       |		/* Create file if it doesn't exist */
 4252|  1.35k|		if (file->size < datalen)
  ------------------
  |  Branch (4252:7): [True: 218, False: 1.13k]
  ------------------
 4253|    218|			file->size = datalen;
 4254|       |
 4255|  1.35k|		r = sc_pkcs15init_create_file(profile, p15card, file);
 4256|  1.35k|		LOG_TEST_RET(ctx, r, "Failed to create file");
  ------------------
  |  |  174|  1.35k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.35k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.35k|	int _ret = (r); \
  |  |  |  |  168|  1.35k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 151, False: 1.20k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.20k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4257|       |
 4258|  1.20k|		r = sc_select_file(p15card->card, &file->path, &selected_file);
 4259|  1.20k|		LOG_TEST_RET(ctx, r, "Failed to select newly created file");
  ------------------
  |  |  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: 40, False: 1.16k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.20k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.16k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4260|  1.20k|	}
 4261|    381|	else   {
 4262|    381|		LOG_TEST_RET(ctx, r, "Failed to select file");
  ------------------
  |  |  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: 381, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    381|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    381|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    381|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    381|		return _ret; \
  |  |  |  |  172|    381|	} \
  |  |  |  |  173|    381|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4263|    381|	}
 4264|       |
 4265|  2.15k|	if (selected_file->size < datalen) {
  ------------------
  |  Branch (4265:6): [True: 45, False: 2.10k]
  ------------------
 4266|     45|		sc_log(ctx,
  ------------------
  |  |   71|     45|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4267|     45|		       "File %s too small (require %zu, have %"SC_FORMAT_LEN_SIZE_T"u)",
 4268|     45|		       sc_print_path(&file->path), datalen,
 4269|     45|		       selected_file->size);
 4270|     45|		sc_file_free(selected_file);
 4271|     45|		LOG_TEST_RET(ctx, SC_ERROR_FILE_TOO_SMALL, "Update file failed");
  ------------------
  |  |  174|     45|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     45|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     45|	int _ret = (r); \
  |  |  |  |  168|     45|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 45, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|     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
  |  |  |  |  ------------------
  |  |  |  |  170|     45|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     45|		return _ret; \
  |  |  |  |  172|     45|	} \
  |  |  |  |  173|     45|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4272|     45|	}
 4273|  2.10k|	else if (selected_file->size > datalen && need_to_zap) {
  ------------------
  |  Branch (4273:11): [True: 1.98k, False: 123]
  |  Branch (4273:44): [True: 934, False: 1.05k]
  ------------------
 4274|       |		/* zero out the rest of the file - we may have shrunk
 4275|       |		 * the file contents */
 4276|    934|		if (selected_file->size > MAX_FILE_SIZE) {
  ------------------
  |  |  229|    934|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (4276:7): [True: 0, False: 934]
  ------------------
 4277|      0|			sc_file_free(selected_file);
 4278|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4279|      0|		}
 4280|       |
 4281|    934|		copy = calloc(1, selected_file->size);
 4282|    934|		if (copy == NULL) {
  ------------------
  |  Branch (4282:7): [True: 0, False: 934]
  ------------------
 4283|      0|			sc_file_free(selected_file);
 4284|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4285|      0|		}
 4286|    934|		memcpy(copy, data, datalen);
 4287|    934|		datalen = selected_file->size;
 4288|    934|		data = copy;
 4289|    934|	}
 4290|       |
 4291|       |	/* Present authentication info needed */
 4292|  2.10k|	r = sc_pkcs15init_authenticate(profile, p15card, selected_file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|  2.10k|#define SC_AC_OP_UPDATE			23
  ------------------
 4293|  2.10k|	if (r >= 0 && datalen)
  ------------------
  |  Branch (4293:6): [True: 2.05k, False: 55]
  |  Branch (4293:16): [True: 1.21k, False: 836]
  ------------------
 4294|  1.21k|		r = sc_update_binary(p15card->card, 0, (const unsigned char *) data, datalen, 0);
 4295|       |
 4296|  2.10k|	if (copy)
  ------------------
  |  Branch (4296:6): [True: 934, False: 1.17k]
  ------------------
 4297|    934|		free(copy);
 4298|  2.10k|	sc_file_free(selected_file);
 4299|  2.10k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  2.10k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.10k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.10k|	int _ret = r; \
  |  |  |  |  155|  2.10k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.00k, False: 1.10k]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.00k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    168|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 168, False: 839]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.00k|			"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|  2.10k|	return _ret; \
  |  |  |  |  163|  2.10k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4300|  2.10k|}
sc_pkcs15init_fixup_file:
 4372|  3.28k|{
 4373|  3.28k|	struct sc_context	*ctx = profile->card->ctx;
 4374|  3.28k|	struct sc_acl_entry	so_acl, user_acl;
 4375|  3.28k|	unsigned int	op, needfix = 0;
 4376|  3.28k|	int		rv, pin_ref;
 4377|       |
 4378|  3.28k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.28k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.28k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.28k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.28k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.28k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4379|       |	/* First, loop over all ACLs to find out whether there
 4380|       |	 * are still any symbolic references.
 4381|       |	 */
 4382|   105k|	for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|   105k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (4382:15): [True: 101k, False: 3.28k]
  ------------------
 4383|   101k|		const struct sc_acl_entry *acl;
 4384|       |
 4385|   101k|		acl = sc_file_get_acl_entry(file, op);
 4386|   203k|		for (; acl; acl = acl->next)
  ------------------
  |  Branch (4386:10): [True: 101k, False: 101k]
  ------------------
 4387|   101k|			if (acl->method == SC_AC_SYMBOLIC)
  ------------------
  |  |  155|   101k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (4387:8): [True: 2.47k, False: 98.9k]
  ------------------
 4388|  2.47k|				needfix++;
 4389|   101k|	}
 4390|       |
 4391|  3.28k|	if (!needfix)
  ------------------
  |  Branch (4391:6): [True: 2.21k, False: 1.06k]
  ------------------
 4392|  3.28k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2.21k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4393|       |
 4394|  1.06k|	pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC, SC_PKCS15INIT_SO_PIN);
  ------------------
  |  |  155|  1.06k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
              	pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC, SC_PKCS15INIT_SO_PIN);
  ------------------
  |  |  169|  1.06k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
 4395|  1.06k|	if (pin_ref < 0) {
  ------------------
  |  Branch (4395:6): [True: 194, False: 875]
  ------------------
 4396|    194|		so_acl.method = SC_AC_NONE;
  ------------------
  |  |  150|    194|#define SC_AC_NONE			0x00000000
  ------------------
 4397|    194|		so_acl.key_ref = 0;
 4398|    194|	}
 4399|    875|	else {
 4400|    875|		so_acl.method = SC_AC_CHV;
  ------------------
  |  |  151|    875|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 4401|    875|		so_acl.key_ref = pin_ref;
 4402|    875|	}
 4403|       |
 4404|  1.06k|	pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
  ------------------
  |  |  155|  1.06k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
              	pin_ref = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC, SC_PKCS15INIT_USER_PIN);
  ------------------
  |  |  171|  1.06k|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
 4405|  1.06k|	if (pin_ref < 0) {
  ------------------
  |  Branch (4405:6): [True: 310, False: 759]
  ------------------
 4406|    310|		user_acl.method = SC_AC_NONE;
  ------------------
  |  |  150|    310|#define SC_AC_NONE			0x00000000
  ------------------
 4407|    310|		user_acl.key_ref = 0;
 4408|    310|	}
 4409|    759|	else {
 4410|    759|		user_acl.method = SC_AC_CHV;
  ------------------
  |  |  151|    759|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 4411|    759|		user_acl.key_ref = pin_ref;
 4412|    759|	}
 4413|  1.06k|	sc_log(ctx, "so_acl(method:%X,ref:%X), user_acl(method:%X,ref:%X)",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4414|  1.06k|			so_acl.method, so_acl.key_ref, user_acl.method, user_acl.key_ref);
 4415|       |
 4416|  1.06k|	rv = sc_pkcs15init_fixup_acls(p15card, file, &so_acl, &user_acl);
 4417|       |
 4418|  1.06k|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|     10|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 10, False: 1.05k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4419|  1.06k|}
sc_pkcs15init_get_pin_info:
 4439|  5.50k|{
 4440|  5.50k|	sc_profile_get_pin_info(profile, id, pin);
 4441|  5.50k|	return SC_SUCCESS;
  ------------------
  |  |   28|  5.50k|#define SC_SUCCESS				0
  ------------------
 4442|  5.50k|}
sc_pkcs15init_set_serial:
 4462|    105|{
 4463|    105|	if (profile->p15_spec->tokeninfo->serial_number)
  ------------------
  |  Branch (4463:6): [True: 105, False: 0]
  ------------------
 4464|    105|		free(profile->p15_spec->tokeninfo->serial_number);
 4465|    105|	profile->p15_spec->tokeninfo->serial_number = strdup(serial);
 4466|       |
 4467|    105|	return SC_SUCCESS;
  ------------------
  |  |   28|    105|#define SC_SUCCESS				0
  ------------------
 4468|    105|}
sc_pkcs15init_sanity_check:
 4476|  2.21k|{
 4477|  2.21k|	struct sc_context *ctx = p15card->card->ctx;
 4478|  2.21k|	int rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  2.21k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 4479|       |
 4480|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4481|  2.21k|	if (profile->ops->sanity_check)
  ------------------
  |  Branch (4481:6): [True: 73, False: 2.14k]
  ------------------
 4482|     73|		rv = profile->ops->sanity_check(profile, p15card);
 4483|       |
 4484|  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|  2.14k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.14k, False: 73]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4485|  2.21k|}
fuzz_pkcs15init.c:sc_pkcs15init_create_pin:
 1114|  1.69k|{
 1115|  1.69k|	struct sc_context *ctx = p15card->card->ctx;
 1116|  1.69k|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
 1117|  1.69k|	struct sc_pkcs15_pin_attributes *pin_attrs = &auth_info->attrs.pin;
 1118|  1.69k|	struct sc_file	*df = profile->df_info->file;
 1119|  1.69k|	int		r, retry = 0;
 1120|       |
 1121|  1.69k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.69k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.69k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.69k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.69k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1122|       |	/* Some cards need to keep all their PINs in separate directories.
 1123|       |	 * Create a subdirectory now, and put the pin into
 1124|       |	 * this subdirectory
 1125|       |	 */
 1126|  1.69k|	if (profile->pin_domains) {
  ------------------
  |  Branch (1126:6): [True: 0, False: 1.69k]
  ------------------
 1127|      0|		if (!profile->ops->create_domain)
  ------------------
  |  Branch (1127:7): [True: 0, False: 0]
  ------------------
 1128|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "PIN domains 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1129|       |
 1130|      0|		r = profile->ops->create_domain(profile, p15card, &auth_info->auth_id, &df);
 1131|      0|		LOG_TEST_RET(ctx, r, "Card specific create domain 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1132|      0|	}
 1133|       |
 1134|       |	/* Path encoded only for local PINs */
 1135|  1.69k|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|  1.69k|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (1135:6): [True: 1.66k, False: 22]
  ------------------
 1136|  1.66k|		auth_info->path = df->path;
 1137|       |
 1138|       |	/* pin_info->reference = 0; */
 1139|       |
 1140|       |	/* Loop until we come up with an acceptable pin reference */
 1141|  1.69k|	while (1) {
  ------------------
  |  Branch (1141:9): [True: 1.69k, Folded]
  ------------------
 1142|  1.69k|		if (profile->ops->select_pin_reference) {
  ------------------
  |  Branch (1142:7): [True: 1.57k, False: 120]
  ------------------
 1143|  1.57k|			r = profile->ops->select_pin_reference(profile, p15card, auth_info);
 1144|  1.57k|			LOG_TEST_RET(ctx, r, "Card specific select PIN reference failed");
  ------------------
  |  |  174|  1.57k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.57k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.57k|	int _ret = (r); \
  |  |  |  |  168|  1.57k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 623, False: 951]
  |  |  |  |  ------------------
  |  |  |  |  169|    623|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    623|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    623|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    623|		return _ret; \
  |  |  |  |  172|    623|	} \
  |  |  |  |  173|  1.57k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 951]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1145|       |
 1146|    951|			retry = 1;
 1147|    951|		}
 1148|       |
 1149|  1.07k|		r = sc_pkcs15_find_pin_by_reference(p15card, &auth_info->path, pin_attrs->reference, NULL);
 1150|  1.07k|		if (r == SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|  1.07k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1150:7): [True: 1.06k, False: 4]
  ------------------
 1151|  1.06k|			break;
 1152|       |
 1153|      4|		if (r != 0 || !retry)
  ------------------
  |  Branch (1153:7): [True: 0, False: 4]
  |  Branch (1153:17): [True: 0, False: 4]
  ------------------
 1154|       |			/* Other error trying to retrieve pin obj */
 1155|      4|			LOG_TEST_RET(ctx, SC_ERROR_TOO_MANY_OBJECTS, "Failed to allocate PIN reference.");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1156|       |
 1157|      4|		pin_attrs->reference++;
 1158|      4|	}
 1159|       |
 1160|  1.06k|	if (args->puk_len == 0)
  ------------------
  |  Branch (1160:6): [True: 0, False: 1.06k]
  ------------------
 1161|      0|		pin_attrs->flags |= SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED;
  ------------------
  |  |   57|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED		0x0008
  ------------------
 1162|       |
 1163|  1.06k|	sc_log(ctx, "create PIN with reference:%X, flags:%X, path:%s",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1164|  1.06k|			pin_attrs->reference, pin_attrs->flags, sc_print_path(&auth_info->path));
 1165|  1.06k|	r = profile->ops->create_pin(profile, p15card,
 1166|  1.06k|			df, pin_obj,
 1167|  1.06k|			args->pin, args->pin_len,
 1168|  1.06k|			args->puk, args->puk_len);
 1169|       |
 1170|  1.06k|	if (df != profile->df_info->file)
  ------------------
  |  Branch (1170:6): [True: 0, False: 1.06k]
  ------------------
 1171|      0|		sc_file_free(df);
 1172|       |
 1173|  1.06k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|    875|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 875, False: 192]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1174|  1.06k|}
fuzz_pkcs15init.c:sc_pkcs15init_init_prkdf:
 1228|  2.47k|{
 1229|  2.47k|	struct sc_context *ctx = p15card->card->ctx;
 1230|  2.47k|	struct sc_pkcs15_prkey_info *key_info = NULL;
 1231|  2.47k|	struct sc_pkcs15_keyinfo_gostparams *keyinfo_gostparams;
 1232|  2.47k|	struct sc_pkcs15_object *object = NULL;
 1233|  2.47k|	const char	*label;
 1234|  2.47k|	unsigned int	usage;
 1235|  2.47k|	int		r = 0, key_type;
 1236|  2.47k|	struct sc_ec_parameters *new_ecparams = NULL;
 1237|       |
 1238|  2.47k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.47k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.47k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.47k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.47k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1239|  2.47k|	if (!res_obj || !keybits) {
  ------------------
  |  Branch (1239:6): [True: 0, False: 2.47k]
  |  Branch (1239:18): [True: 0, False: 2.47k]
  ------------------
 1240|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1241|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Initialize PrKDF entry 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1242|      0|	}
 1243|       |
 1244|  2.47k|	*res_obj = NULL;
 1245|       |
 1246|  2.47k|	if ((usage = keyargs->usage) == 0) {
  ------------------
  |  Branch (1246:6): [True: 2.47k, False: 0]
  ------------------
 1247|  2.47k|		usage = SC_PKCS15_PRKEY_USAGE_SIGN;
  ------------------
  |  |  307|  2.47k|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
 1248|  2.47k|		if (keyargs->x509_usage)
  ------------------
  |  Branch (1248:7): [True: 0, False: 2.47k]
  ------------------
 1249|      0|			usage = sc_pkcs15init_map_usage(keyargs->x509_usage, 1);
 1250|  2.47k|	}
 1251|       |
 1252|  2.47k|	if ((label = keyargs->label) == NULL)
  ------------------
  |  Branch (1252:6): [True: 2.47k, False: 0]
  ------------------
 1253|  2.47k|		label = DEFAULT_PRIVATE_KEY_LABEL;
  ------------------
  |  |   30|  2.47k|#define DEFAULT_PRIVATE_KEY_LABEL "Private Key"
  ------------------
 1254|       |
 1255|       |	/* Create the prkey object now.
 1256|       |	 * If we find out below that we're better off reusing an
 1257|       |	 * existing object, we'll ditch this one */
 1258|  2.47k|	key_type = key_pkcs15_algo(p15card, key->algorithm);
 1259|  2.47k|	r = key_type;
 1260|  2.47k|	LOG_TEST_GOTO_ERR(ctx, r, "Unsupported key type");
  ------------------
  |  |  184|  2.47k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.47k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.47k|	int _ret = (r); \
  |  |  |  |  178|  2.47k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2.47k]
  |  |  |  |  ------------------
  |  |  |  |  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.47k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1261|       |
 1262|  2.47k|	object = sc_pkcs15init_new_object(key_type, label, &keyargs->auth_id, NULL);
 1263|  2.47k|	if (object == NULL) {
  ------------------
  |  Branch (1263:6): [True: 0, False: 2.47k]
  ------------------
 1264|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1265|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate new PrKey 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1266|      0|	}
 1267|       |
 1268|  2.47k|	key_info = (struct sc_pkcs15_prkey_info *) object->data;
 1269|  2.47k|	key_info->usage = usage;
 1270|  2.47k|	key_info->native = 1;
 1271|  2.47k|	key_info->key_reference = 0;
 1272|  2.47k|	key_info->modulus_length = keybits;
 1273|  2.47k|	key_info->access_flags = keyargs->access_flags;
 1274|  2.47k|	object->user_consent = keyargs->user_consent;
 1275|       |	/* Path is selected below */
 1276|       |
 1277|  2.47k|	if (keyargs->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) {
  ------------------
  |  |  317|  2.47k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  |  Branch (1277:6): [True: 0, False: 2.47k]
  ------------------
 1278|      0|		key_info->access_flags &= ~SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE;
  ------------------
  |  |  319|      0|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
 1279|      0|	}
 1280|       |
 1281|       |	/* Select a Key ID if the user didn't specify one,
 1282|       |	 * otherwise make sure it's compatible with our intended use */
 1283|  2.47k|	r = select_id(p15card, SC_PKCS15_TYPE_PRKEY, &keyargs->id);
  ------------------
  |  |  418|  2.47k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
 1284|  2.47k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot select ID for PrKey object");
  ------------------
  |  |  184|  2.47k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.47k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.47k|	int _ret = (r); \
  |  |  |  |  178|  2.47k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 2.47k]
  |  |  |  |  ------------------
  |  |  |  |  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.47k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1285|       |
 1286|  2.47k|	key_info->id = keyargs->id;
 1287|       |
 1288|  2.47k|	if (key->algorithm == SC_ALGORITHM_GOSTR3410) {
  ------------------
  |  |   80|  2.47k|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (1288:6): [True: 0, False: 2.47k]
  ------------------
 1289|      0|		key_info->params.len = sizeof(*keyinfo_gostparams);
 1290|       |		/* FIXME: malloc() call in pkcs15init, but free() call
 1291|       |		 * in libopensc (sc_pkcs15_free_prkey_info) */
 1292|      0|		key_info->params.data = malloc(key_info->params.len);
 1293|      0|		if (!key_info->params.data) {
  ------------------
  |  Branch (1293:7): [True: 0, False: 0]
  ------------------
 1294|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1295|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate memory for GOST 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1296|      0|		}
 1297|      0|		keyinfo_gostparams = key_info->params.data;
 1298|      0|		keyinfo_gostparams->gostr3410 = keyargs->params.gost.gostr3410;
 1299|      0|		keyinfo_gostparams->gostr3411 = keyargs->params.gost.gostr3411;
 1300|      0|		keyinfo_gostparams->gost28147 = keyargs->params.gost.gost28147;
 1301|  2.47k|	} else if (key->algorithm == SC_ALGORITHM_EC ||
  ------------------
  |  |   79|  4.94k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (1301:13): [True: 705, False: 1.76k]
  ------------------
 1302|  1.76k|			key->algorithm == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   81|  4.24k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (1302:4): [True: 0, False: 1.76k]
  ------------------
 1303|  1.76k|			key->algorithm == SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   82|  1.76k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (1303:4): [True: 0, False: 1.76k]
  ------------------
 1304|       |		/* keyargs->key.u.ec.params.der.value is allocated in keyargs, which is on stack */
 1305|    705|		struct sc_ec_parameters *ecparams = &keyargs->key.u.ec.params;
 1306|       |
 1307|    705|		new_ecparams = calloc(1, sizeof(struct sc_ec_parameters));
 1308|    705|		if (!new_ecparams) {
  ------------------
  |  Branch (1308:7): [True: 0, False: 705]
  ------------------
 1309|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1310|      0|			LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate memory for 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1311|      0|		}
 1312|    705|		r = sc_copy_ec_params(new_ecparams, &keyargs->key.u.ec.params);
 1313|    705|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot copy EC parameters");
  ------------------
  |  |  184|    705|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    705|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    705|	int _ret = (r); \
  |  |  |  |  178|    705|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 705]
  |  |  |  |  ------------------
  |  |  |  |  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|    705|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 705]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1314|       |
 1315|    705|		key_info->params.data = new_ecparams;
 1316|    705|		key_info->params.free_params = sc_pkcs15init_free_ec_params;
 1317|    705|		key_info->field_length = ecparams->field_length;
 1318|    705|		key_info->modulus_length = 0;
 1319|    705|	}
 1320|       |
 1321|  2.47k|	r = select_object_path(p15card, profile, object, &key_info->path);
 1322|  2.47k|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to select private key object path");
  ------------------
  |  |  184|  2.47k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.47k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.47k|	int _ret = (r); \
  |  |  |  |  178|  2.47k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 29, False: 2.44k]
  |  |  |  |  ------------------
  |  |  |  |  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|  2.47k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 2.44k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1323|       |
 1324|       |	/* See if we need to select a key reference for this object */
 1325|  2.44k|	if (profile->ops->select_key_reference) {
  ------------------
  |  Branch (1325:6): [True: 784, False: 1.66k]
  ------------------
 1326|    784|		while (1) {
  ------------------
  |  Branch (1326:10): [True: 784, Folded]
  ------------------
 1327|    784|			sc_log(ctx, "Look for usable key reference starting from %i", key_info->key_reference);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 1328|    784|			r = profile->ops->select_key_reference(profile, p15card, key_info);
 1329|    784|			LOG_TEST_GOTO_ERR(ctx, r, "Failed to select card specific key reference");
  ------------------
  |  |  184|    784|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    784|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    784|	int _ret = (r); \
  |  |  |  |  178|    784|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 211, False: 573]
  |  |  |  |  ------------------
  |  |  |  |  179|    211|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    211|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    211|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    211|		goto err; \
  |  |  |  |  182|    211|	} \
  |  |  |  |  183|    784|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 573]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1330|       |
 1331|    573|			r = sc_pkcs15_find_prkey_by_reference(p15card, &key_info->path, key_info->key_reference, NULL);
 1332|    573|			if (r == SC_ERROR_OBJECT_NOT_FOUND)   {
  ------------------
  |  |   88|    573|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (1332:8): [True: 573, False: 0]
  ------------------
 1333|    573|				sc_log(ctx, "Will use key reference %i", key_info->key_reference);
  ------------------
  |  |   71|    573|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 1334|    573|				break;
 1335|    573|			}
 1336|       |
 1337|      0|			if (r != 0) {
  ------------------
  |  Branch (1337:8): [True: 0, False: 0]
  ------------------
 1338|       |				/* Other error trying to retrieve pin obj */
 1339|      0|				r = SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
 1340|      0|				LOG_TEST_GOTO_ERR(ctx, r, "Failed to select key reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1341|      0|			}
 1342|       |
 1343|      0|			key_info->key_reference++;
 1344|      0|		}
 1345|    784|	}
 1346|       |
 1347|  2.23k|	*res_obj = object;
 1348|  2.23k|	object = NULL;
 1349|  2.23k|	new_ecparams = NULL;
 1350|  2.23k|	r = SC_SUCCESS;
  ------------------
  |  |   28|  2.23k|#define SC_SUCCESS				0
  ------------------
 1351|       |
 1352|  2.47k|err:
 1353|  2.47k|	if (new_ecparams) {
  ------------------
  |  Branch (1353:6): [True: 29, False: 2.44k]
  ------------------
 1354|     29|		sc_clear_ec_params(new_ecparams);
 1355|     29|		free(new_ecparams);
 1356|     29|		key_info->params.data = NULL;
 1357|     29|	}
 1358|  2.47k|	sc_pkcs15init_free_object(object);
 1359|  2.47k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|    240|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 240, False: 2.23k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1360|  2.47k|}
fuzz_pkcs15init.c:key_pkcs15_algo:
 2796|  9.12k|{
 2797|  9.12k|	struct sc_context *ctx = p15card->card->ctx;
 2798|       |
 2799|  9.12k|	switch (algorithm) {
  ------------------
  |  Branch (2799:10): [True: 9.12k, False: 0]
  ------------------
 2800|  1.76k|	case SC_ALGORITHM_RSA:
  ------------------
  |  |   78|  1.76k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2800:2): [True: 1.76k, False: 7.36k]
  ------------------
 2801|  1.76k|		return SC_PKCS15_TYPE_PRKEY_RSA;
  ------------------
  |  |  419|  1.76k|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
 2802|      0|	case SC_ALGORITHM_GOSTR3410:
  ------------------
  |  |   80|      0|#define SC_ALGORITHM_GOSTR3410		3
  ------------------
  |  Branch (2802:2): [True: 0, False: 9.12k]
  ------------------
 2803|      0|		return SC_PKCS15_TYPE_PRKEY_GOSTR3410;
  ------------------
  |  |  420|      0|#define SC_PKCS15_TYPE_PRKEY_GOSTR3410		0x103
  ------------------
 2804|    705|	case SC_ALGORITHM_EC:
  ------------------
  |  |   79|    705|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2804:2): [True: 705, False: 8.42k]
  ------------------
 2805|    705|		return SC_PKCS15_TYPE_PRKEY_EC;
  ------------------
  |  |  421|    705|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
 2806|      0|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (2806:2): [True: 0, False: 9.12k]
  ------------------
 2807|      0|		return SC_PKCS15_TYPE_PRKEY_EDDSA;
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
 2808|      0|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2808:2): [True: 0, False: 9.12k]
  ------------------
 2809|      0|		return SC_PKCS15_TYPE_PRKEY_XEDDSA;
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
 2810|  2.21k|	case SC_ALGORITHM_DES:
  ------------------
  |  |   85|  2.21k|#define SC_ALGORITHM_DES		64
  ------------------
  |  Branch (2810:2): [True: 2.21k, False: 6.91k]
  ------------------
 2811|  2.21k|		return SC_PKCS15_TYPE_SKEY_DES;
  ------------------
  |  |  434|  2.21k|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
 2812|  2.21k|	case SC_ALGORITHM_3DES:
  ------------------
  |  |   86|  2.21k|#define SC_ALGORITHM_3DES		65
  ------------------
  |  Branch (2812:2): [True: 2.21k, False: 6.91k]
  ------------------
 2813|  2.21k|		return SC_PKCS15_TYPE_SKEY_3DES;
  ------------------
  |  |  436|  2.21k|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
 2814|  2.21k|	case SC_ALGORITHM_AES:
  ------------------
  |  |   88|  2.21k|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (2814:2): [True: 2.21k, False: 6.91k]
  ------------------
 2815|  2.21k|	case SC_ALGORITHM_UNDEFINED:
  ------------------
  |  |   89|  2.21k|#define SC_ALGORITHM_UNDEFINED		68	/* used with CKK_GENERIC_SECRET type keys */
  ------------------
  |  Branch (2815:2): [True: 0, False: 9.12k]
  ------------------
 2816|  2.21k|		return SC_PKCS15_TYPE_SKEY_GENERIC;
  ------------------
  |  |  433|  2.21k|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
 2817|  9.12k|	}
 2818|      0|	sc_log(ctx, "Unsupported 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__
  |  |  ------------------
  ------------------
 2819|      0|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 2820|  9.12k|}
fuzz_pkcs15init.c:sc_pkcs15init_free_ec_params:
  176|    676|{
  177|    676|	struct sc_ec_parameters *ecparams = (struct sc_ec_parameters *)ptr;
  178|    676|	if (ecparams) {
  ------------------
  |  Branch (178:6): [True: 676, False: 0]
  ------------------
  179|    676|		sc_clear_ec_params(ecparams);
  180|    676|		free(ecparams);
  181|    676|	}
  182|    676|}
fuzz_pkcs15init.c:_pkcd15init_set_aux_md_data:
 1464|  2.23k|{
 1465|  2.23k|	struct sc_context *ctx = p15card->card->ctx;
 1466|  2.23k|	unsigned char flags = SC_MD_CONTAINER_MAP_VALID_CONTAINER;
  ------------------
  |  |   54|  2.23k|#define SC_MD_CONTAINER_MAP_VALID_CONTAINER	0x01
  ------------------
 1467|  2.23k|	char gd[SC_MD_MAX_CONTAINER_NAME_LEN + 1];
 1468|  2.23k|	int rv;
 1469|       |
 1470|  2.23k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.23k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.23k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.23k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.23k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.23k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1471|       |
 1472|  2.23k|	if(!guid || !guid_len)
  ------------------
  |  Branch (1472:5): [True: 2.23k, False: 0]
  |  Branch (1472:14): [True: 0, False: 0]
  ------------------
 1473|  2.23k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  2.23k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.23k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.23k|	int _ret = r; \
  |  |  |  |  155|  2.23k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.23k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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: 2.23k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.23k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.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|  2.23k|	return _ret; \
  |  |  |  |  163|  2.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1474|       |
 1475|      0|	if (!aux_data)
  ------------------
  |  Branch (1475:6): [True: 0, False: 0]
  ------------------
 1476|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1477|       |
 1478|      0|	if (guid_len > SC_MD_MAX_CONTAINER_NAME_LEN)
  ------------------
  |  |   53|      0|#define SC_MD_MAX_CONTAINER_NAME_LEN	39
  ------------------
  |  Branch (1478:6): [True: 0, False: 0]
  ------------------
 1479|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1480|       |
 1481|      0|	memset(gd, 0, sizeof(gd));
 1482|      0|	memcpy(gd, guid, guid_len);
 1483|       |
 1484|      0|	if (*aux_data == NULL)   {
  ------------------
  |  Branch (1484:6): [True: 0, False: 0]
  ------------------
 1485|      0|		rv = sc_aux_data_allocate(ctx, aux_data, NULL);
 1486|      0|		LOG_TEST_RET(ctx, rv, "Failed to allocate aux 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1487|      0|	}
 1488|       |
 1489|      0|	rv = sc_aux_data_set_md_guid(ctx, *aux_data, gd);
 1490|      0|	LOG_TEST_RET(ctx, rv, "Failed to set private key CMAP record GUID");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1491|       |
 1492|      0|	if (sc_pkcs15_get_objects(p15card, SC_PKCS15_TYPE_PRKEY, NULL, 0) == 0)
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (1492:6): [True: 0, False: 0]
  ------------------
 1493|      0|		flags |= SC_MD_CONTAINER_MAP_DEFAULT_CONTAINER;
  ------------------
  |  |   55|      0|#define SC_MD_CONTAINER_MAP_DEFAULT_CONTAINER	0x02
  ------------------
 1494|       |
 1495|      0|	rv = sc_aux_data_set_md_flags(ctx, *aux_data, flags);
 1496|      0|	LOG_TEST_RET(ctx, rv, "Failed to set private key CMAP record flags");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1497|       |
 1498|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1499|      0|}
fuzz_pkcs15init.c:sc_pkcs15init_init_skdf:
 1368|  6.65k|{
 1369|  6.65k|	struct sc_context *ctx = p15card->card->ctx;
 1370|  6.65k|	struct sc_pkcs15_skey_info *key_info;
 1371|  6.65k|	struct sc_pkcs15_object *object = NULL;
 1372|  6.65k|	const char	*label;
 1373|  6.65k|	unsigned int	usage;
 1374|  6.65k|	unsigned long	keybits = keyargs->value_len;
 1375|  6.65k|	int		r = 0, key_type;
 1376|       |
 1377|  6.65k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  6.65k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  6.65k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  6.65k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  6.65k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 6.65k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1378|  6.65k|	if (!res_obj || !keybits) {
  ------------------
  |  Branch (1378:6): [True: 0, False: 6.65k]
  |  Branch (1378:18): [True: 0, False: 6.65k]
  ------------------
 1379|      0|		r = SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1380|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Initialize SKDF entry 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1381|      0|	}
 1382|       |
 1383|  6.65k|	*res_obj = NULL;
 1384|       |
 1385|  6.65k|	if ((usage = keyargs->usage) == 0) {
  ------------------
  |  Branch (1385:6): [True: 0, False: 6.65k]
  ------------------
 1386|      0|		usage = SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  305|      0|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
              		usage = SC_PKCS15_PRKEY_USAGE_ENCRYPT|SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  306|      0|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
 1387|      0|	}
 1388|       |
 1389|  6.65k|	if ((label = keyargs->label) == NULL)
  ------------------
  |  Branch (1389:6): [True: 6.65k, False: 0]
  ------------------
 1390|  6.65k|		label = DEFAULT_SECRET_KEY_LABEL;
  ------------------
  |  |   31|  6.65k|#define DEFAULT_SECRET_KEY_LABEL  "Secret Key"
  ------------------
 1391|       |
 1392|       |	/* Create the skey object now.
 1393|       |	 * If we find out below that we're better off reusing an
 1394|       |	 * existing object, we'll ditch this one */
 1395|  6.65k|	key_type = key_pkcs15_algo(p15card, keyargs->algorithm);
 1396|  6.65k|	r = key_type;
 1397|  6.65k|	LOG_TEST_GOTO_ERR(ctx, r, "Unsupported key type");
  ------------------
  |  |  184|  6.65k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  6.65k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  6.65k|	int _ret = (r); \
  |  |  |  |  178|  6.65k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 6.65k]
  |  |  |  |  ------------------
  |  |  |  |  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|  6.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 6.65k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1398|       |
 1399|  6.65k|	object = sc_pkcs15init_new_object(key_type, label, &keyargs->auth_id, NULL);
 1400|  6.65k|	if (object == NULL) {
  ------------------
  |  Branch (1400:6): [True: 0, False: 6.65k]
  ------------------
 1401|      0|		r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1402|      0|		LOG_TEST_GOTO_ERR(ctx, r, "Cannot allocate new SKey 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1403|      0|	}
 1404|       |
 1405|  6.65k|	key_info = (struct sc_pkcs15_skey_info *) object->data;
 1406|  6.65k|	key_info->usage = usage;
 1407|  6.65k|	key_info->native = 1;
 1408|  6.65k|	key_info->key_reference = 0;
 1409|  6.65k|	switch (keyargs->algorithm) {
 1410|  2.21k|	case SC_ALGORITHM_DES:
  ------------------
  |  |   85|  2.21k|#define SC_ALGORITHM_DES		64
  ------------------
  |  Branch (1410:2): [True: 2.21k, False: 4.43k]
  ------------------
 1411|  2.21k|		key_info->key_type = CKK_DES;
  ------------------
  |  |  473|  2.21k|#define CKK_DES 0x00000013UL
  ------------------
 1412|  2.21k|		break;
 1413|  2.21k|	case SC_ALGORITHM_3DES:
  ------------------
  |  |   86|  2.21k|#define SC_ALGORITHM_3DES		65
  ------------------
  |  Branch (1413:2): [True: 2.21k, False: 4.43k]
  ------------------
 1414|  2.21k|		key_info->key_type = CKK_DES3;
  ------------------
  |  |  475|  2.21k|#define CKK_DES3 0x00000015UL
  ------------------
 1415|  2.21k|		break;
 1416|  2.21k|	case SC_ALGORITHM_AES:
  ------------------
  |  |   88|  2.21k|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (1416:2): [True: 2.21k, False: 4.43k]
  ------------------
 1417|  2.21k|		key_info->key_type = CKK_AES;
  ------------------
  |  |  485|  2.21k|#define CKK_AES 0x0000001FUL
  ------------------
 1418|  2.21k|		break;
 1419|      0|	default:
  ------------------
  |  Branch (1419:2): [True: 0, False: 6.65k]
  ------------------
 1420|      0|		key_info->key_type = CKK_GENERIC_SECRET;
  ------------------
  |  |  470|      0|#define CKK_GENERIC_SECRET 0x00000010UL
  ------------------
 1421|      0|		break;
 1422|  6.65k|	}
 1423|  6.65k|	key_info->value_len = keybits;
 1424|  6.65k|	key_info->access_flags = keyargs->access_flags;
 1425|       |	/* Path is selected below */
 1426|       |
 1427|  6.65k|	if (keyargs->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) {
  ------------------
  |  |  317|  6.65k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  |  Branch (1427:6): [True: 6.65k, False: 0]
  ------------------
 1428|  6.65k|		key_info->access_flags &= ~SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE;
  ------------------
  |  |  319|  6.65k|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
 1429|  6.65k|	}
 1430|       |
 1431|  6.65k|	if (keyargs->session_object > 0)
  ------------------
  |  Branch (1431:6): [True: 0, False: 6.65k]
  ------------------
 1432|      0|	    object->session_object = 1;
 1433|       |
 1434|  6.65k|	object->user_consent = keyargs->user_consent;
 1435|       |
 1436|       |	/* Select a Key ID if the user didn't specify one,
 1437|       |	 * otherwise make sure it's compatible with our intended use */
 1438|  6.65k|	r = select_id(p15card, SC_PKCS15_TYPE_SKEY, &keyargs->id);
  ------------------
  |  |  432|  6.65k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
 1439|  6.65k|	LOG_TEST_GOTO_ERR(ctx, r, "Cannot select ID for SKey object");
  ------------------
  |  |  184|  6.65k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  6.65k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  6.65k|	int _ret = (r); \
  |  |  |  |  178|  6.65k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 0, False: 6.65k]
  |  |  |  |  ------------------
  |  |  |  |  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|  6.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 6.65k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1440|       |
 1441|  6.65k|	key_info->id = keyargs->id;
 1442|       |
 1443|  6.65k|	r = select_object_path(p15card, profile, object, &key_info->path);
 1444|  6.65k|	LOG_TEST_GOTO_ERR(ctx, r, "Failed to select secret key object path");
  ------------------
  |  |  184|  6.65k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  6.65k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  6.65k|	int _ret = (r); \
  |  |  |  |  178|  6.65k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 53, False: 6.60k]
  |  |  |  |  ------------------
  |  |  |  |  179|     53|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     53|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|     53|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     53|		goto err; \
  |  |  |  |  182|     53|	} \
  |  |  |  |  183|  6.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 6.60k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1445|       |
 1446|       |	/* See if we need to select a key reference for this object */
 1447|  6.60k|	if (profile->ops->select_key_reference) {
  ------------------
  |  Branch (1447:6): [True: 2.29k, False: 4.30k]
  ------------------
 1448|  2.29k|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  2.29k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 1449|  2.29k|		LOG_TEST_GOTO_ERR(ctx, r, "SKey keyreference selection not supported");
  ------------------
  |  |  184|  2.29k|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|  2.29k|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|  2.29k|	int _ret = (r); \
  |  |  |  |  178|  2.29k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 2.29k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|  2.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|  2.29k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|  2.29k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|  2.29k|		goto err; \
  |  |  |  |  182|  2.29k|	} \
  |  |  |  |  183|  2.29k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1450|  2.29k|	}
 1451|       |
 1452|  4.30k|	*res_obj = object;
 1453|  4.30k|	object = NULL;
 1454|  4.30k|	r = SC_SUCCESS;
  ------------------
  |  |   28|  4.30k|#define SC_SUCCESS				0
  ------------------
 1455|       |
 1456|  6.65k|err:
 1457|  6.65k|	sc_pkcs15init_free_object(object);
 1458|  6.65k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  6.65k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.65k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.65k|	int _ret = r; \
  |  |  |  |  155|  6.65k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.65k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.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|  2.35k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.35k, False: 4.30k]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.65k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.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|  6.65k|	return _ret; \
  |  |  |  |  163|  6.65k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 1459|  6.65k|}
fuzz_pkcs15init.c:sc_pkcs15init_store_data:
 2421|  2.24k|{
 2422|  2.24k|	struct sc_context *ctx = p15card->card->ctx;
 2423|  2.24k|	struct sc_file	*file = NULL;
 2424|  2.24k|	int		r;
 2425|       |
 2426|  2.24k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.24k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.24k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.24k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.24k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.24k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2427|       |
 2428|  2.24k|	if (profile->ops->emu_store_data)   {
  ------------------
  |  Branch (2428:6): [True: 603, False: 1.63k]
  ------------------
 2429|    603|		r = profile->ops->emu_store_data(p15card, profile, object, data, path);
 2430|    603|		if (r == SC_SUCCESS || r != SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   28|  1.20k|#define SC_SUCCESS				0
  ------------------
              		if (r == SC_SUCCESS || r != SC_ERROR_NOT_IMPLEMENTED)
  ------------------
  |  |   97|    600|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  |  Branch (2430:7): [True: 3, False: 600]
  |  Branch (2430:26): [True: 462, False: 138]
  ------------------
 2431|    603|			LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    465|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    465|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    465|	int _ret = r; \
  |  |  |  |  155|    465|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 337, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  156|    337|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    334|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 334, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  157|    337|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    337|	} else { \
  |  |  |  |  159|    128|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    128|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    128|	} \
  |  |  |  |  162|    465|	return _ret; \
  |  |  |  |  163|    465|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2432|    603|	}
 2433|       |
 2434|  1.77k|	r = select_object_path(p15card, profile, object, path);
 2435|  1.77k|	LOG_TEST_RET(ctx, r, "Failed to select object path");
  ------------------
  |  |  174|  1.77k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.77k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.77k|	int _ret = (r); \
  |  |  |  |  168|  1.77k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 1.76k]
  |  |  |  |  ------------------
  |  |  |  |  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|  1.77k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1.76k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2436|       |
 2437|  1.76k|	r = sc_profile_get_file_by_path(profile, path, &file);
 2438|  1.76k|	LOG_TEST_RET(ctx, r, "Failed to get file by path");
  ------------------
  |  |  174|  1.76k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  1.76k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  1.76k|	int _ret = (r); \
  |  |  |  |  168|  1.76k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 1.21k, False: 552]
  |  |  |  |  ------------------
  |  |  |  |  169|  1.21k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __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.21k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  1.21k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  1.21k|		return _ret; \
  |  |  |  |  172|  1.21k|	} \
  |  |  |  |  173|  1.76k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 552]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2439|       |
 2440|    552|	if (file->path.count == 0) {
  ------------------
  |  Branch (2440:6): [True: 36, False: 516]
  ------------------
 2441|     36|		file->path.index = 0;
 2442|     36|		file->path.count = -1;
 2443|     36|	}
 2444|       |
 2445|    552|	r = sc_pkcs15init_delete_by_path(profile, p15card, &file->path);
 2446|    552|	if (r && r != SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|    515|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (2446:6): [True: 515, False: 37]
  |  Branch (2446:11): [True: 386, False: 129]
  ------------------
 2447|    386|		sc_file_free(file);
 2448|    386|		LOG_TEST_RET(ctx, r, "Cannot delete file");
  ------------------
  |  |  174|    386|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    386|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    386|	int _ret = (r); \
  |  |  |  |  168|    386|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 386, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    386|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    386|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    386|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    386|		return _ret; \
  |  |  |  |  172|    386|	} \
  |  |  |  |  173|    386|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2449|    386|	}
 2450|       |
 2451|    166|	r = sc_pkcs15init_update_file(profile, p15card, file, data->value, data->len);
 2452|       |
 2453|    166|	*path = file->path;
 2454|       |
 2455|    166|	sc_file_free(file);
 2456|    166|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    166|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (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: 142, False: 24]
  |  |  |  |  ------------------
  |  |  |  |  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|     24|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     24|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     24|	} \
  |  |  |  |  162|    166|	return _ret; \
  |  |  |  |  163|    166|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2457|    166|}
fuzz_pkcs15init.c:sc_pkcs15init_keybits:
 2515|     12|{
 2516|     12|	unsigned int	mask;
 2517|     12|	size_t bits;
 2518|       |
 2519|     12|	if (!bn || !bn->len)
  ------------------
  |  Branch (2519:6): [True: 0, False: 12]
  |  Branch (2519:13): [True: 0, False: 12]
  ------------------
 2520|      0|		return 0;
 2521|     12|	bits = bn->len << 3;
 2522|     50|	for (mask = 0x80; mask && !(bn->data[0] & mask); mask >>= 1)
  ------------------
  |  Branch (2522:20): [True: 47, False: 3]
  |  Branch (2522:28): [True: 38, False: 9]
  ------------------
 2523|     38|		bits--;
 2524|     12|	return bits;
 2525|     12|}
fuzz_pkcs15init.c:check_keygen_params_consistency:
 2535|  11.0k|{
 2536|  11.0k|	struct sc_context *ctx = card->ctx;
 2537|  11.0k|	int i, rv;
 2538|       |
 2539|  11.0k|	if (prkey && (alg == SC_ALGORITHM_EC ||
  ------------------
  |  |   79|  8.87k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2539:6): [True: 4.43k, False: 6.65k]
  |  Branch (2539:16): [True: 2.21k, False: 2.21k]
  ------------------
 2540|  2.21k|				     alg == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   81|  6.65k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (2540:10): [True: 0, False: 2.21k]
  ------------------
 2541|  2.21k|				     alg == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   82|  2.21k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2541:10): [True: 0, False: 2.21k]
  ------------------
 2542|  2.21k|		struct sc_ec_parameters *ecparams = &prkey->key.u.ec.params;
 2543|       |
 2544|  2.21k|		rv = sc_pkcs15_fix_ec_parameters(ctx, ecparams);
 2545|  2.21k|		LOG_TEST_RET(ctx, rv, "Cannot fix EC parameters");
  ------------------
  |  |  174|  2.21k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.21k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.21k|	int _ret = (r); \
  |  |  |  |  168|  2.21k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 2.21k]
  |  |  |  |  ------------------
  |  |  |  |  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.21k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2.21k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2546|       |
 2547|  2.21k|		sc_log(ctx, "EC parameters: %s", sc_dump_hex(ecparams->der.value, ecparams->der.len));
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 2548|  2.21k|		if (!*keybits)
  ------------------
  |  Branch (2548:7): [True: 2.21k, False: 0]
  ------------------
 2549|  2.21k|			*keybits = (unsigned int)ecparams->field_length;
 2550|  2.21k|	}
 2551|       |
 2552|  56.1k|	for (i = 0; i < card->algorithm_count; i++) {
  ------------------
  |  Branch (2552:14): [True: 48.1k, False: 8.03k]
  ------------------
 2553|  48.1k|		struct sc_algorithm_info *info = &card->algorithms[i];
 2554|       |
 2555|  48.1k|		if (info->algorithm != alg)
  ------------------
  |  Branch (2555:7): [True: 41.7k, False: 6.38k]
  ------------------
 2556|  41.7k|			continue;
 2557|       |
 2558|  6.38k|		if (info->key_length != *keybits)
  ------------------
  |  Branch (2558:7): [True: 3.32k, False: 3.06k]
  ------------------
 2559|  3.32k|			continue;
 2560|       |
 2561|  3.06k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.06k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.06k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.06k|	int _ret = r; \
  |  |  |  |  155|  3.06k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.06k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 3.06k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.06k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.06k|	return _ret; \
  |  |  |  |  163|  3.06k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2562|  3.06k|	}
 2563|       |
 2564|  8.03k|	if (prkey && (alg == SC_ALGORITHM_EC ||
  ------------------
  |  |   79|  3.87k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2564:6): [True: 1.93k, False: 6.09k]
  |  Branch (2564:16): [True: 1.51k, False: 425]
  ------------------
 2565|    425|				     alg == SC_ALGORITHM_EDDSA ||
  ------------------
  |  |   81|  2.36k|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (2565:10): [True: 0, False: 425]
  ------------------
 2566|  1.51k|				     alg == SC_ALGORITHM_XEDDSA)) {
  ------------------
  |  |   82|    425|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2566:10): [True: 0, False: 425]
  ------------------
 2567|       |		/* allocated in sc_pkcs15_fix_ec_parameters */
 2568|  1.51k|		free(prkey->key.u.ec.params.der.value);
 2569|  1.51k|		prkey->key.u.ec.params.der.value = NULL;
 2570|  1.51k|	}
 2571|       |
 2572|  8.03k|	LOG_FUNC_RETURN(ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|  8.03k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  8.03k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  8.03k|	int _ret = r; \
  |  |  |  |  155|  8.03k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 8.03k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  8.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|  8.03k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 8.03k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  8.03k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  8.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|  8.03k|	return _ret; \
  |  |  |  |  163|  8.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2573|  8.03k|}
fuzz_pkcs15init.c:check_key_compatibility:
 2582|  9.72k|{
 2583|  9.72k|	struct sc_context *ctx = p15card->card->ctx;
 2584|  9.72k|	struct sc_algorithm_info *info;
 2585|  9.72k|	unsigned int count;
 2586|  9.72k|	unsigned long talg = alg;
 2587|       |
 2588|  9.72k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  9.72k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  9.72k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  9.72k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  9.72k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 9.72k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2589|       |
 2590|  9.72k|	if (alg == SC_ALGORITHM_EDDSA || alg == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   81|  19.4k|#define SC_ALGORITHM_EDDSA		4
  ------------------
              	if (alg == SC_ALGORITHM_EDDSA || alg == SC_ALGORITHM_XEDDSA)
  ------------------
  |  |   82|  9.72k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2590:6): [True: 0, False: 9.72k]
  |  Branch (2590:35): [True: 0, False: 9.72k]
  ------------------
 2591|      0|		talg = SC_ALGORITHM_EC; /* really testing ecparams */
  ------------------
  |  |   79|      0|#define SC_ALGORITHM_EC		2
  ------------------
 2592|       |
 2593|  9.72k|	count = p15card->card->algorithm_count;
 2594|  58.2k|	for (info = p15card->card->algorithms; count--; info++) {
  ------------------
  |  Branch (2594:41): [True: 51.5k, False: 6.68k]
  ------------------
 2595|       |		/* don't check flags if none was specified */
 2596|       |
 2597|  51.5k|		if (alg != SC_ALGORITHM_EDDSA && alg != SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   81|   103k|#define SC_ALGORITHM_EDDSA		4
  ------------------
              		if (alg != SC_ALGORITHM_EDDSA && alg != SC_ALGORITHM_XEDDSA) {
  ------------------
  |  |   82|  51.5k|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (2597:7): [True: 51.5k, False: 0]
  |  Branch (2597:36): [True: 51.5k, False: 0]
  ------------------
 2598|  51.5k|			if (info->algorithm != alg || info->key_length != key_length)
  ------------------
  |  Branch (2598:8): [True: 44.3k, False: 7.21k]
  |  Branch (2598:34): [True: 3.58k, False: 3.62k]
  ------------------
 2599|  47.9k|				continue;
 2600|  51.5k|		}
 2601|  3.62k|		if (flags != 0 && ((info->flags & flags) != flags))
  ------------------
  |  Branch (2601:7): [True: 3.06k, False: 563]
  |  Branch (2601:21): [True: 590, False: 2.47k]
  ------------------
 2602|    590|			continue;
 2603|       |
 2604|  3.03k|		if (alg == SC_ALGORITHM_RSA && prkey)   {
  ------------------
  |  |   78|  6.07k|#define SC_ALGORITHM_RSA		0
  ------------------
  |  Branch (2604:7): [True: 1.76k, False: 1.26k]
  |  Branch (2604:34): [True: 1.76k, False: 0]
  ------------------
 2605|  1.76k|			if (info->u._rsa.exponent != 0 && prkey->u.rsa.exponent.len != 0) {
  ------------------
  |  Branch (2605:8): [True: 314, False: 1.45k]
  |  Branch (2605:38): [True: 0, False: 314]
  ------------------
 2606|      0|				struct sc_pkcs15_bignum *e = &prkey->u.rsa.exponent;
 2607|      0|				unsigned long	exponent = 0;
 2608|      0|				unsigned int	n;
 2609|       |
 2610|      0|				if (e->len > 4)
  ------------------
  |  Branch (2610:9): [True: 0, False: 0]
  ------------------
 2611|      0|					continue;
 2612|      0|				for (n = 0; n < e->len; n++) {
  ------------------
  |  Branch (2612:17): [True: 0, False: 0]
  ------------------
 2613|      0|					exponent <<= 8;
 2614|      0|					exponent |= e->data[n];
 2615|      0|				}
 2616|      0|				if (info->u._rsa.exponent != exponent)
  ------------------
  |  Branch (2616:9): [True: 0, False: 0]
  ------------------
 2617|      0|					continue;
 2618|      0|			}
 2619|  1.76k|		} else if (talg == SC_ALGORITHM_EC) { /* includes EDDSA and XEDDSA */
  ------------------
  |  |   79|  1.26k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (2619:14): [True: 706, False: 563]
  ------------------
 2620|    706|			if (!sc_valid_oid(&prkey->u.ec.params.id))
  ------------------
  |  Branch (2620:8): [True: 0, False: 706]
  ------------------
 2621|      0|				if (sc_pkcs15_fix_ec_parameters(ctx, &prkey->u.ec.params))
  ------------------
  |  Branch (2621:9): [True: 0, False: 0]
  ------------------
 2622|      0|					LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2623|    706|			if (sc_valid_oid(&info->u._ec.params.id))
  ------------------
  |  Branch (2623:8): [True: 497, False: 209]
  ------------------
 2624|    497|				if (!sc_compare_oid(&info->u._ec.params.id, &prkey->u.ec.params.id))
  ------------------
  |  Branch (2624:9): [True: 0, False: 497]
  ------------------
 2625|      0|					continue;
 2626|    706|		}
 2627|       |
 2628|  3.03k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  3.03k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  3.03k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  3.03k|	int _ret = r; \
  |  |  |  |  155|  3.03k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 3.03k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  3.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: 3.03k]
  |  |  |  |  ------------------
  |  |  |  |  157|  3.03k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  3.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|  3.03k|	return _ret; \
  |  |  |  |  163|  3.03k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2629|  3.03k|	}
 2630|       |
 2631|  6.68k|	LOG_FUNC_RETURN(ctx, SC_ERROR_OBJECT_NOT_VALID);
  ------------------
  |  |  164|  6.68k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  6.68k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  6.68k|	int _ret = r; \
  |  |  |  |  155|  6.68k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 6.68k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  6.68k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.68k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6.68k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  6.68k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  6.68k|	} else { \
  |  |  |  |  159|      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.68k|	return _ret; \
  |  |  |  |  163|  6.68k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2632|  6.68k|}
fuzz_pkcs15init.c:select_id:
 2949|  9.15k|{
 2950|  9.15k|	struct sc_context *ctx = p15card->card->ctx;
 2951|  9.15k|	struct sc_pkcs15_id unused_id;
 2952|  9.15k|	struct sc_pkcs15_object *obj;
 2953|  9.15k|	unsigned int nid = DEFAULT_ID;
  ------------------
  |  |   77|  9.15k|#define DEFAULT_ID			0x45
  ------------------
 2954|  9.15k|	int r;
 2955|       |
 2956|  9.15k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  9.15k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  9.15k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  9.15k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  9.15k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 9.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2957|       |	/* If the user provided an ID, make sure we can use it */
 2958|  9.15k|	if (id->len != 0) {
  ------------------
  |  Branch (2958:6): [True: 7.28k, False: 1.86k]
  ------------------
 2959|  7.28k|		r = sc_pkcs15_find_object_by_id(p15card, type, id, &obj);
 2960|       |
 2961|  7.28k|		if (r == SC_ERROR_OBJECT_NOT_FOUND)
  ------------------
  |  |   88|  7.28k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (2961:7): [True: 7.28k, False: 0]
  ------------------
 2962|  7.28k|			r = 0;
 2963|      0|		else if (!r)
  ------------------
  |  Branch (2963:12): [True: 0, False: 0]
  ------------------
 2964|      0|			r = SC_ERROR_NON_UNIQUE_ID;
  ------------------
  |  |  107|      0|#define SC_ERROR_NON_UNIQUE_ID			-1505
  ------------------
 2965|       |
 2966|  7.28k|		LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  7.28k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  7.28k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  7.28k|	int _ret = r; \
  |  |  |  |  155|  7.28k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 7.28k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  7.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 7.28k]
  |  |  |  |  ------------------
  |  |  |  |  157|  7.28k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  7.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|  7.28k|	return _ret; \
  |  |  |  |  163|  7.28k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 2967|  7.28k|	}
 2968|       |
 2969|  1.86k|	memset(&unused_id, 0, sizeof(unused_id));
 2970|   348k|	while (nid < 255) {
  ------------------
  |  Branch (2970:9): [True: 346k, False: 1.86k]
  ------------------
 2971|   346k|		id->value[0] = nid++;
 2972|   346k|		id->len = 1;
 2973|       |
 2974|   346k|		r = sc_pkcs15_find_object_by_id(p15card, type, id, &obj);
 2975|   346k|		if (r == SC_ERROR_OBJECT_NOT_FOUND) {
  ------------------
  |  |   88|   346k|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  |  Branch (2975:7): [True: 346k, False: 24]
  ------------------
 2976|       |			/* We don't have an object of that type yet.
 2977|       |			 * If we're allocating a PRKEY object, make
 2978|       |			 * sure there's no conflicting pubkey or cert
 2979|       |			 * object either. */
 2980|   346k|			if (type == SC_PKCS15_TYPE_PRKEY) {
  ------------------
  |  |  418|   346k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (2980:8): [True: 346k, False: 0]
  ------------------
 2981|   346k|				struct sc_pkcs15_search_key search_key;
 2982|       |
 2983|   346k|				memset(&search_key, 0, sizeof(search_key));
 2984|   346k|				search_key.class_mask = SC_PKCS15_SEARCH_CLASS_PUBKEY | SC_PKCS15_SEARCH_CLASS_CERT;
  ------------------
  |  |  451|   346k|#define SC_PKCS15_SEARCH_CLASS_PUBKEY		0x0004U
  ------------------
              				search_key.class_mask = SC_PKCS15_SEARCH_CLASS_PUBKEY | SC_PKCS15_SEARCH_CLASS_CERT;
  ------------------
  |  |  453|   346k|#define SC_PKCS15_SEARCH_CLASS_CERT		0x0010U
  ------------------
 2985|   346k|				search_key.id = id;
 2986|       |
 2987|   346k|				r = sc_pkcs15_search_objects(p15card, &search_key, NULL, 0);
 2988|       |				/* If there is a pubkey or cert with
 2989|       |				 * this ID, skip it. */
 2990|   346k|				if (r > 0)
  ------------------
  |  Branch (2990:9): [True: 13, False: 346k]
  ------------------
 2991|     13|					continue;
 2992|   346k|			}
 2993|   346k|			if (!unused_id.len)
  ------------------
  |  Branch (2993:8): [True: 1.86k, False: 344k]
  ------------------
 2994|  1.86k|				unused_id = *id;
 2995|   346k|			continue;
 2996|   346k|		}
 2997|   346k|	}
 2998|       |
 2999|  1.86k|	if (unused_id.len) {
  ------------------
  |  Branch (2999:6): [True: 1.86k, False: 0]
  ------------------
 3000|  1.86k|		*id = unused_id;
 3001|  1.86k|		LOG_FUNC_RETURN(ctx, 0);
  ------------------
  |  |  164|  1.86k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.86k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.86k|	int _ret = r; \
  |  |  |  |  155|  1.86k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.86k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.86k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.86k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.86k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.86k|	} else { \
  |  |  |  |  159|      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.86k|	return _ret; \
  |  |  |  |  163|  1.86k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3002|  1.86k|	}
 3003|       |
 3004|      0|	LOG_FUNC_RETURN(ctx, SC_ERROR_TOO_MANY_OBJECTS);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3005|      0|}
fuzz_pkcs15init.c:sc_pkcs15init_update_dir:
 3175|     98|{
 3176|     98|	struct sc_context *ctx = p15card->card->ctx;
 3177|     98|	struct sc_card	*card = p15card->card;
 3178|     98|	int r, retry = 1;
 3179|       |
 3180|     98|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|     98|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|     98|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|     98|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|     98|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 98]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3181|     98|	if (profile->ops->emu_update_dir)   {
  ------------------
  |  Branch (3181:6): [True: 0, False: 98]
  ------------------
 3182|      0|		r = profile->ops->emu_update_dir(profile, p15card, app);
 3183|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3184|      0|	}
 3185|       |
 3186|    179|	do {
 3187|    179|		struct sc_file	*dir_file;
 3188|    179|		struct sc_path	path;
 3189|       |
 3190|    179|		r = sc_enum_apps(card);
 3191|    179|		if (r != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    179|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (3191:7): [True: 87, False: 92]
  ------------------
 3192|     87|			break;
 3193|       |		/* DIR file is not yet created. */
 3194|       |
 3195|     92|		sc_format_path("3F002F00", &path);
 3196|     92|		r = sc_profile_get_file_by_path(profile, &path, &dir_file);
 3197|     92|		LOG_TEST_RET(ctx, r, "DIR file not defined in profile");
  ------------------
  |  |  174|     92|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     92|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     92|	int _ret = (r); \
  |  |  |  |  168|     92|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 88]
  |  |  |  |  ------------------
  |  |  |  |  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|     92|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 88]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3198|       |
 3199|       |		/* Create DIR file */
 3200|     88|		r = sc_pkcs15init_update_file(profile, p15card, dir_file, NULL, 0);
 3201|     88|		sc_file_free(dir_file);
 3202|     88|	} while (retry--);
  ------------------
  |  Branch (3202:11): [True: 81, False: 7]
  ------------------
 3203|       |
 3204|     94|	if (r >= 0) {
  ------------------
  |  Branch (3204:6): [True: 69, False: 25]
  ------------------
 3205|     69|		card->app[card->app_count++] = app;
 3206|     69|		r = sc_update_dir(card, NULL);
 3207|     69|	}
 3208|     94|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|     64|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 64, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3209|     94|}
fuzz_pkcs15init.c:sc_pkcs15init_update_tokeninfo:
 3214|    667|{
 3215|    667|	struct sc_context *ctx = p15card->card->ctx;
 3216|    667|	unsigned char	*buf = NULL;
 3217|    667|	size_t		size;
 3218|    667|	int		rv;
 3219|       |
 3220|    667|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    667|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3221|       |
 3222|       |	/* set lastUpdate field */
 3223|    667|	if (p15card->tokeninfo->last_update.gtime != NULL)   {
  ------------------
  |  Branch (3223:6): [True: 22, False: 645]
  ------------------
 3224|     22|		free(p15card->tokeninfo->last_update.gtime);
 3225|     22|		p15card->tokeninfo->last_update.gtime = NULL;
 3226|     22|	}
 3227|    667|	rv = sc_pkcs15_get_generalized_time(ctx, &p15card->tokeninfo->last_update.gtime);
 3228|    667|	LOG_TEST_RET(ctx, rv, "Cannot allocate generalized time string");
  ------------------
  |  |  174|    667|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    667|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    667|	int _ret = (r); \
  |  |  |  |  168|    667|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 667]
  |  |  |  |  ------------------
  |  |  |  |  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|    667|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 667]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3229|       |
 3230|    667|	if (profile->ops->emu_update_tokeninfo)
  ------------------
  |  Branch (3230:6): [True: 8, False: 659]
  ------------------
 3231|      8|		return profile->ops->emu_update_tokeninfo(profile, p15card, p15card->tokeninfo);
 3232|       |
 3233|    659|	if (!p15card->file_tokeninfo)   {
  ------------------
  |  Branch (3233:6): [True: 224, False: 435]
  ------------------
 3234|    224|		sc_log(ctx, "No TokenInfo to update");
  ------------------
  |  |   71|    224|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3235|    224|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    224|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    224|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    224|	int _ret = r; \
  |  |  |  |  155|    224|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 224, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    224|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 224]
  |  |  |  |  ------------------
  |  |  |  |  157|    224|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    224|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    224|	return _ret; \
  |  |  |  |  163|    224|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3236|    224|	}
 3237|       |
 3238|    435|	rv = sc_pkcs15_encode_tokeninfo(ctx, p15card->tokeninfo, &buf, &size);
 3239|    435|	if (rv >= 0)
  ------------------
  |  Branch (3239:6): [True: 335, False: 100]
  ------------------
 3240|    335|		rv = sc_pkcs15init_update_file(profile, p15card, p15card->file_tokeninfo, buf, size);
 3241|    435|	if (buf)
  ------------------
  |  Branch (3241:6): [True: 335, False: 100]
  ------------------
 3242|    335|		free(buf);
 3243|       |
 3244|    435|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    435|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    435|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    435|	int _ret = r; \
  |  |  |  |  155|    435|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 399, False: 36]
  |  |  |  |  ------------------
  |  |  |  |  156|    399|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    398|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 398, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|    399|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    399|	} else { \
  |  |  |  |  159|     36|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     36|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     36|	} \
  |  |  |  |  162|    435|	return _ret; \
  |  |  |  |  163|    435|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3245|    435|}
fuzz_pkcs15init.c:sc_pkcs15init_update_lastupdate:
 3250|    737|{
 3251|    737|	struct sc_context *ctx = p15card->card->ctx;
 3252|    737|	int		r;
 3253|       |
 3254|    737|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    737|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    737|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    737|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    737|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 737]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3255|    737|	if (p15card->tokeninfo->last_update.path.len)    {
  ------------------
  |  Branch (3255:6): [True: 100, False: 637]
  ------------------
 3256|    100|		static const struct sc_asn1_entry c_asn1_last_update[2] = {
 3257|    100|		        { "generalizedTime",    SC_ASN1_GENERALIZEDTIME, SC_ASN1_TAG_GENERALIZEDTIME,   SC_ASN1_OPTIONAL, NULL, NULL },
  ------------------
  |  |  166|    100|#define SC_ASN1_GENERALIZEDTIME         24
  ------------------
              		        { "generalizedTime",    SC_ASN1_GENERALIZEDTIME, SC_ASN1_TAG_GENERALIZEDTIME,   SC_ASN1_OPTIONAL, NULL, NULL },
  ------------------
  |  |  215|    100|#define SC_ASN1_TAG_GENERALIZEDTIME	24
  ------------------
              		        { "generalizedTime",    SC_ASN1_GENERALIZEDTIME, SC_ASN1_TAG_GENERALIZEDTIME,   SC_ASN1_OPTIONAL, NULL, NULL },
  ------------------
  |  |  148|    100|#define SC_ASN1_OPTIONAL		0x00000002
  ------------------
 3258|    100|			{ NULL, 0, 0, 0, NULL, NULL }
 3259|    100|		};
 3260|    100|		struct sc_asn1_entry asn1_last_update[2];
 3261|    100|		size_t lupdate_len;
 3262|    100|		struct sc_file *file = NULL;
 3263|    100|		struct sc_pkcs15_last_update *last_update = &p15card->tokeninfo->last_update;
 3264|    100|		unsigned char *buf = NULL;
 3265|    100|		size_t buflen;
 3266|       |
 3267|       |		/* update 'lastUpdate' file */
 3268|    100|		if (last_update->gtime != NULL)
  ------------------
  |  Branch (3268:7): [True: 1, False: 99]
  ------------------
 3269|      1|			free(last_update->gtime);
 3270|    100|		r = sc_pkcs15_get_generalized_time(ctx, &last_update->gtime);
 3271|    100|		LOG_TEST_RET(ctx, r, "Cannot allocate generalized time string");
  ------------------
  |  |  174|    100|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    100|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    100|	int _ret = (r); \
  |  |  |  |  168|    100|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 100]
  |  |  |  |  ------------------
  |  |  |  |  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|    100|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 100]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3272|       |
 3273|    100|		sc_copy_asn1_entry(c_asn1_last_update, asn1_last_update);
 3274|    100|		lupdate_len = strlen(last_update->gtime);
 3275|    100|		sc_format_asn1_entry(asn1_last_update + 0, last_update->gtime, &lupdate_len, 1);
 3276|       |
 3277|    100|		r = sc_asn1_encode(ctx, asn1_last_update, &buf, &buflen);
 3278|    100|		LOG_TEST_RET(ctx, r, "select object path failed");
  ------------------
  |  |  174|    100|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    100|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    100|	int _ret = (r); \
  |  |  |  |  168|    100|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 100]
  |  |  |  |  ------------------
  |  |  |  |  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|    100|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 100]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3279|       |
 3280|    100|		r = sc_select_file(p15card->card, &last_update->path, &file);
 3281|    100|		if (r < 0)
  ------------------
  |  Branch (3281:7): [True: 98, False: 2]
  ------------------
 3282|     98|			free(buf);
 3283|    100|		LOG_TEST_RET(ctx, r, "select object path failed");
  ------------------
  |  |  174|    100|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    100|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    100|	int _ret = (r); \
  |  |  |  |  168|    100|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 98, False: 2]
  |  |  |  |  ------------------
  |  |  |  |  169|     98|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     98|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     98|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     98|		return _ret; \
  |  |  |  |  172|     98|	} \
  |  |  |  |  173|    100|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 2]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3284|       |
 3285|      2|		r = sc_pkcs15init_update_file(profile, p15card, file, buf, buflen);
 3286|      2|		sc_file_free(file);
 3287|      2|		if (buf)
  ------------------
  |  Branch (3287:7): [True: 2, False: 0]
  ------------------
 3288|      2|			free(buf);
 3289|      2|		LOG_TEST_RET(ctx, r, "Cannot update 'LastUpdate' file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3290|      1|		LOG_FUNC_RETURN(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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3291|      1|	}
 3292|       |
 3293|    637|	r = sc_pkcs15init_update_tokeninfo(p15card, profile);
 3294|    637|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    637|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    637|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    637|	int _ret = r; \
  |  |  |  |  155|    637|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 614, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  156|    614|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    386|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 386, False: 228]
  |  |  |  |  ------------------
  |  |  |  |  157|    614|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    614|	} else { \
  |  |  |  |  159|     23|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|     23|			"returning with: %d\n", _ret); \
  |  |  |  |  161|     23|	} \
  |  |  |  |  162|    637|	return _ret; \
  |  |  |  |  163|    637|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3295|    637|}
fuzz_pkcs15init.c:sc_pkcs15init_update_odf:
 3300|    929|{
 3301|    929|	struct sc_context	*ctx = p15card->card->ctx;
 3302|    929|	unsigned char	*buf = NULL;
 3303|    929|	size_t		size;
 3304|    929|	int		r;
 3305|       |
 3306|    929|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    929|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    929|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    929|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    929|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 929]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3307|    929|	r = sc_pkcs15_encode_odf(ctx, p15card, &buf, &size);
 3308|    929|	if (r >= 0)
  ------------------
  |  Branch (3308:6): [True: 928, False: 1]
  ------------------
 3309|    928|		r = sc_pkcs15init_update_file(profile, p15card, p15card->file_odf, buf, size);
 3310|    929|	if (buf)
  ------------------
  |  Branch (3310:6): [True: 928, False: 1]
  ------------------
 3311|    928|		free(buf);
 3312|    929|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    929|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    929|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    929|	int _ret = r; \
  |  |  |  |  155|    929|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 89, False: 840]
  |  |  |  |  ------------------
  |  |  |  |  156|     89|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 1]
  |  |  |  |  ------------------
  |  |  |  |  157|     89|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    840|	} else { \
  |  |  |  |  159|    840|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    840|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    840|	} \
  |  |  |  |  162|    929|	return _ret; \
  |  |  |  |  163|    929|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3313|    929|}
fuzz_pkcs15init.c:find_df_by_type:
 2825|  2.54k|{
 2826|  2.54k|	struct sc_pkcs15_df *df = p15card->df_list;
 2827|       |
 2828|  8.73k|	while (df != NULL && df->type != type)
  ------------------
  |  Branch (2828:9): [True: 7.45k, False: 1.28k]
  |  Branch (2828:23): [True: 6.19k, False: 1.25k]
  ------------------
 2829|  6.19k|		df = df->next;
 2830|  2.54k|	return df;
 2831|  2.54k|}
fuzz_pkcs15init.c:get_object_path_from_object:
 3046|  3.47k|{
 3047|  3.47k|	if (!ret_path)
  ------------------
  |  Branch (3047:6): [True: 0, False: 3.47k]
  ------------------
 3048|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 3049|       |
 3050|  3.47k|	memset(ret_path, 0, sizeof(struct sc_path));
 3051|       |
 3052|  3.47k|	switch(obj->type & SC_PKCS15_TYPE_CLASS_MASK)   {
  ------------------
  |  |  416|  3.47k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (3052:9): [True: 3.47k, False: 0]
  ------------------
 3053|  2.16k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  2.16k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (3053:2): [True: 2.16k, False: 1.30k]
  ------------------
 3054|  2.16k|		*ret_path = ((struct sc_pkcs15_prkey_info *)obj->data)->path;
 3055|  2.16k|		return SC_SUCCESS;
  ------------------
  |  |   28|  2.16k|#define SC_SUCCESS				0
  ------------------
 3056|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (3056:2): [True: 0, False: 3.47k]
  ------------------
 3057|      0|		*ret_path = ((struct sc_pkcs15_pubkey_info *)obj->data)->path;
 3058|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3059|  1.30k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  1.30k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (3059:2): [True: 1.30k, False: 2.16k]
  ------------------
 3060|  1.30k|		*ret_path = ((struct sc_pkcs15_skey_info *)obj->data)->path;
 3061|  1.30k|		return SC_SUCCESS;
  ------------------
  |  |   28|  1.30k|#define SC_SUCCESS				0
  ------------------
 3062|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (3062:2): [True: 0, False: 3.47k]
  ------------------
 3063|      0|		*ret_path = ((struct sc_pkcs15_cert_info *)obj->data)->path;
 3064|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3065|      0|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (3065:2): [True: 0, False: 3.47k]
  ------------------
 3066|      0|		*ret_path = ((struct sc_pkcs15_data_info *)obj->data)->path;
 3067|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3068|      0|	case SC_PKCS15_TYPE_AUTH:
  ------------------
  |  |  444|      0|#define SC_PKCS15_TYPE_AUTH			0x600
  ------------------
  |  Branch (3068:2): [True: 0, False: 3.47k]
  ------------------
 3069|      0|		*ret_path = ((struct sc_pkcs15_auth_info *)obj->data)->path;
 3070|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
 3071|  3.47k|	}
 3072|      0|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
 3073|  3.47k|}
fuzz_pkcs15init.c:select_object_path:
 3079|  10.9k|{
 3080|  10.9k|	struct sc_context *ctx = p15card->card->ctx;
 3081|  10.9k|	struct sc_file	*file;
 3082|  10.9k|	struct sc_pkcs15_object	*objs[32];
 3083|  10.9k|	struct sc_pkcs15_id index_id;
 3084|  10.9k|	struct sc_path obj_path;
 3085|  10.9k|	int ii, r, nn_objs, index;
 3086|  10.9k|	const char *name;
 3087|       |
 3088|  10.9k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  10.9k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3089|  10.9k|	r = sc_pkcs15_get_objects(p15card, obj->type & SC_PKCS15_TYPE_CLASS_MASK, objs, sizeof(objs)/sizeof(objs[0]));
  ------------------
  |  |  416|  10.9k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
 3090|  10.9k|	LOG_TEST_RET(ctx, r, "Get PKCS#15 objects error");
  ------------------
  |  |  174|  10.9k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  10.9k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  10.9k|	int _ret = (r); \
  |  |  |  |  168|  10.9k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 10.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|  10.9k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 10.9k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3091|  10.9k|	nn_objs = r;
 3092|       |
 3093|       |	/* For cards with a pin-domain profile, we need
 3094|       |	 * to put the key below the DF of the specified PIN
 3095|       |	 */
 3096|  10.9k|	memset(path, 0, sizeof(*path));
 3097|  10.9k|	if (obj->auth_id.len && profile->pin_domains != 0) {
  ------------------
  |  Branch (3097:6): [True: 9.12k, False: 1.77k]
  |  Branch (3097:26): [True: 3, False: 9.12k]
  ------------------
 3098|      3|		r = sc_pkcs15init_get_pin_path(p15card, &obj->auth_id, path);
 3099|      3|		LOG_TEST_RET(ctx, r, "Cannot get PIN path");
  ------------------
  |  |  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: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3100|      3|	}
 3101|  10.9k|	else {
 3102|  10.9k|		*path = profile->df_info->file->path;
 3103|  10.9k|	}
 3104|       |
 3105|       |	/* If the profile specifies a key directory template,
 3106|       |	 * instantiate it now and create the DF
 3107|       |	 */
 3108|  10.9k|	name = get_template_name_from_object (obj);
 3109|  10.9k|	if (!name)
  ------------------
  |  Branch (3109:6): [True: 0, False: 10.9k]
  ------------------
 3110|  10.9k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3111|       |
 3112|  10.9k|	sc_log(ctx, "key-domain.%s @%s (auth_id.len=%"SC_FORMAT_LEN_SIZE_T"u)",
  ------------------
  |  |   71|  10.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__
  |  |  ------------------
  ------------------
 3113|  10.9k|	       name, sc_print_path(path), obj->auth_id.len);
 3114|       |
 3115|  10.9k|	index_id.len = 1;
 3116|  14.2k|	for (index = TEMPLATE_INSTANTIATE_MIN_INDEX; index <= TEMPLATE_INSTANTIATE_MAX_INDEX; index++)   {
  ------------------
  |  |   85|  10.9k|#define TEMPLATE_INSTANTIATE_MIN_INDEX	0x0
  ------------------
              	for (index = TEMPLATE_INSTANTIATE_MIN_INDEX; index <= TEMPLATE_INSTANTIATE_MAX_INDEX; index++)   {
  ------------------
  |  |   86|  14.2k|#define TEMPLATE_INSTANTIATE_MAX_INDEX	0xFE
  ------------------
  |  Branch (3116:47): [True: 14.2k, False: 13]
  ------------------
 3117|  14.2k|		index_id.value[0] = index;
 3118|  14.2k|		r = sc_profile_instantiate_template(profile, "key-domain", path, name, &index_id, &file);
 3119|  14.2k|		if (r == SC_ERROR_TEMPLATE_NOT_FOUND)   {
  ------------------
  |  |  110|  14.2k|#define SC_ERROR_TEMPLATE_NOT_FOUND		-1508
  ------------------
  |  Branch (3119:7): [True: 14.1k, False: 106]
  ------------------
 3120|       |			/* No template in 'key-domain' -- try to instantiate the template-'object name'
 3121|       |			 * outside of the 'key-domain' scope. */
 3122|  14.1k|			char t_name[0x40];
 3123|       |
 3124|  14.1k|			snprintf(t_name, sizeof(t_name), "template-%s", name);
 3125|  14.1k|			sc_log(ctx, "get instance %i of '%s'", index, t_name);
  ------------------
  |  |   71|  14.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__
  |  |  ------------------
  ------------------
 3126|  14.1k|			r = sc_profile_get_file_instance(profile, t_name, index, &file);
 3127|  14.1k|			if (r == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|  14.1k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (3127:8): [True: 9.98k, False: 4.12k]
  ------------------
 3128|  14.1k|				LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  9.98k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  9.98k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  9.98k|	int _ret = r; \
  |  |  |  |  155|  9.98k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9.98k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  9.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 9.98k]
  |  |  |  |  ------------------
  |  |  |  |  157|  9.98k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  9.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|  9.98k|	return _ret; \
  |  |  |  |  163|  9.98k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3129|  14.1k|		}
 3130|  4.23k|		LOG_TEST_RET(ctx, r, "Template instantiation error");
  ------------------
  |  |  174|  4.23k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  4.23k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  4.23k|	int _ret = (r); \
  |  |  |  |  168|  4.23k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 81, False: 4.15k]
  |  |  |  |  ------------------
  |  |  |  |  169|     81|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|     81|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|     81|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     81|		return _ret; \
  |  |  |  |  172|     81|	} \
  |  |  |  |  173|  4.23k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4.15k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3131|       |
 3132|  4.15k|		if (file->type == SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|  4.15k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (3132:7): [True: 0, False: 4.15k]
  ------------------
 3133|      0|			break;
 3134|       |
 3135|  4.15k|		sc_log(ctx, "instantiated template path %s", sc_print_path(&file->path));
  ------------------
  |  |   71|  4.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__
  |  |  ------------------
  ------------------
 3136|  4.16k|		for (ii=0; ii<nn_objs; ii++)   {
  ------------------
  |  Branch (3136:14): [True: 3.47k, False: 699]
  ------------------
 3137|  3.47k|			r = get_object_path_from_object(objs[ii], &obj_path);
 3138|  3.47k|			LOG_TEST_RET(ctx, r, "Failed to get object path from pkcs15 object");
  ------------------
  |  |  174|  3.47k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  3.47k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  3.47k|	int _ret = (r); \
  |  |  |  |  168|  3.47k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 3.47k]
  |  |  |  |  ------------------
  |  |  |  |  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.47k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3139|       |
 3140|  3.47k|			if (obj_path.len != file->path.len)
  ------------------
  |  Branch (3140:8): [True: 132, False: 3.33k]
  ------------------
 3141|    132|				break;
 3142|       |
 3143|  3.33k|			if (!memcmp(obj_path.value, file->path.value, obj_path.len))
  ------------------
  |  Branch (3143:8): [True: 3.32k, False: 16]
  ------------------
 3144|  3.32k|				break;
 3145|  3.33k|		}
 3146|       |
 3147|  4.15k|		if (ii==nn_objs)
  ------------------
  |  Branch (3147:7): [True: 699, False: 3.45k]
  ------------------
 3148|    699|			break;
 3149|       |
 3150|  3.45k|		if (obj_path.len != file->path.len)
  ------------------
  |  Branch (3150:7): [True: 132, False: 3.32k]
  ------------------
 3151|    132|			break;
 3152|       |
 3153|  3.32k|		sc_file_free(file);
 3154|       |
 3155|  3.32k|		index_id.value[0] += 1;
 3156|  3.32k|	}
 3157|       |
 3158|    844|	if (index > TEMPLATE_INSTANTIATE_MAX_INDEX)
  ------------------
  |  |   86|    844|#define TEMPLATE_INSTANTIATE_MAX_INDEX	0xFE
  ------------------
  |  Branch (3158:6): [True: 13, False: 831]
  ------------------
 3159|    844|		LOG_TEST_RET(ctx, SC_ERROR_TOO_MANY_OBJECTS, "Template instantiation error");
  ------------------
  |  |  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: 13, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     13|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3160|       |
 3161|    831|	*path = file->path;
 3162|    831|	sc_file_free(file);
 3163|       |
 3164|    831|	sc_log(ctx, "returns object path '%s'", sc_print_path(path));
  ------------------
  |  |   71|    831|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 3165|    831|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    831|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    831|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    831|	int _ret = r; \
  |  |  |  |  155|    831|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 831, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    831|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 831]
  |  |  |  |  ------------------
  |  |  |  |  157|    831|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    831|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    831|	return _ret; \
  |  |  |  |  163|    831|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3166|    831|}
fuzz_pkcs15init.c:sc_pkcs15init_get_pin_path:
 4425|      3|{
 4426|      3|	struct sc_pkcs15_object *obj;
 4427|      3|	int	r;
 4428|       |
 4429|      3|	r = sc_pkcs15_find_pin_by_auth_id(p15card, auth_id, &obj);
 4430|      3|	if (r < 0)
  ------------------
  |  Branch (4430:6): [True: 0, False: 3]
  ------------------
 4431|      0|		return r;
 4432|      3|	*path = ((struct sc_pkcs15_auth_info *) obj->data)->path;
 4433|      3|	return SC_SUCCESS;
  ------------------
  |  |   28|      3|#define SC_SUCCESS				0
  ------------------
 4434|      3|}
fuzz_pkcs15init.c:get_template_name_from_object:
 3022|  10.9k|{
 3023|  10.9k|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|  10.9k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (3023:10): [True: 10.9k, False: 0]
  ------------------
 3024|  2.47k|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|  2.47k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (3024:2): [True: 2.47k, False: 8.43k]
  ------------------
 3025|  2.47k|		return "private-key";
 3026|     19|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|     19|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (3026:2): [True: 19, False: 10.8k]
  ------------------
 3027|     19|		return "public-key";
 3028|  6.65k|	case SC_PKCS15_TYPE_SKEY:
  ------------------
  |  |  432|  6.65k|#define SC_PKCS15_TYPE_SKEY			0x300
  ------------------
  |  Branch (3028:2): [True: 6.65k, False: 4.25k]
  ------------------
 3029|  6.65k|		return "secret-key";
 3030|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (3030:2): [True: 0, False: 10.9k]
  ------------------
 3031|      0|		return "certificate";
 3032|  1.75k|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|  1.75k|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (3032:2): [True: 1.75k, False: 9.14k]
  ------------------
 3033|  1.75k|		if (obj->flags & SC_PKCS15_CO_FLAG_PRIVATE)
  ------------------
  |  |   50|  1.75k|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (3033:7): [True: 0, False: 1.75k]
  ------------------
 3034|      0|			return "privdata";
 3035|  1.75k|		else
 3036|  1.75k|			return "data";
 3037|  10.9k|	}
 3038|       |
 3039|      0|	return NULL;
 3040|  10.9k|}
fuzz_pkcs15init.c:get_pin_ident_name:
 3814|    346|{
 3815|    346|	switch (type)   {
  ------------------
  |  Branch (3815:10): [True: 330, False: 16]
  ------------------
 3816|    296|	case SC_AC_CHV:
  ------------------
  |  |  151|    296|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (3816:2): [True: 296, False: 50]
  ------------------
 3817|    296|		return "PIN";
 3818|      0|	case SC_AC_PRO:
  ------------------
  |  |  153|      0|#define SC_AC_PRO			0x00000004 /* Secure Messaging */
  ------------------
  |  Branch (3818:2): [True: 0, False: 346]
  ------------------
 3819|      0|		return "secure messaging key";
 3820|      1|	case SC_AC_AUT:
  ------------------
  |  |  154|      1|#define SC_AC_AUT			0x00000008 /* Key auth. */
  ------------------
  |  Branch (3820:2): [True: 1, False: 345]
  ------------------
 3821|      1|		return "authentication key";
 3822|      8|	case SC_AC_SEN:
  ------------------
  |  |  156|      8|#define SC_AC_SEN                       0x00000020 /* Security Environment. */
  ------------------
  |  Branch (3822:2): [True: 8, False: 338]
  ------------------
 3823|      8|		return "security environment";
 3824|      5|	case SC_AC_IDA:
  ------------------
  |  |  158|      5|#define SC_AC_IDA                       0x00000080 /* PKCS#15 authentication ID */
  ------------------
  |  Branch (3824:2): [True: 5, False: 341]
  ------------------
 3825|      5|		return "PKCS#15 reference";
 3826|     19|	case SC_AC_SCB:
  ------------------
  |  |  157|     19|#define SC_AC_SCB                       0x00000040 /* IAS/ECC SCB byte. */
  ------------------
  |  Branch (3826:2): [True: 19, False: 327]
  ------------------
 3827|     19|		return "SCB byte in IAS/ECC";
 3828|      1|	case SC_AC_SYMBOLIC:
  ------------------
  |  |  155|      1|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (3828:2): [True: 1, False: 345]
  ------------------
 3829|      1|		switch (reference) {
  ------------------
  |  Branch (3829:11): [True: 1, False: 0]
  ------------------
 3830|      0|	        case SC_PKCS15INIT_USER_PIN:
  ------------------
  |  |  171|      0|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  |  Branch (3830:10): [True: 0, False: 1]
  ------------------
 3831|      0|			return "user PIN";
 3832|      1|		case SC_PKCS15INIT_SO_PIN:
  ------------------
  |  |  169|      1|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  |  Branch (3832:3): [True: 1, False: 0]
  ------------------
 3833|      1|			return "SO PIN";
 3834|      0|	        case SC_PKCS15INIT_USER_PUK:
  ------------------
  |  |  172|      0|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  |  Branch (3834:10): [True: 0, False: 1]
  ------------------
 3835|      0|			return "user PUK";
 3836|      0|		case SC_PKCS15INIT_SO_PUK:
  ------------------
  |  |  170|      0|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  |  Branch (3836:3): [True: 0, False: 1]
  ------------------
 3837|      0|			return "SO PUK";
 3838|      1|		}
 3839|    346|	}
 3840|     16|	return "authentication data";
 3841|    346|}
fuzz_pkcs15init.c:sc_pkcs15init_get_transport_key:
 3847|     28|{
 3848|     28|	struct sc_context *ctx = p15card->card->ctx;
 3849|     28|	struct sc_pkcs15_object *pin_obj = NULL;
 3850|     28|	struct sc_pkcs15_auth_info auth_info;
 3851|     28|	struct sc_cardctl_default_key data;
 3852|     28|	size_t		defsize = 0;
 3853|     28|	unsigned char	defbuf[0x100];
 3854|     28|	int rv;
 3855|       |
 3856|     28|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3857|       |
 3858|     28|	data.method = type;
 3859|     28|	data.key_ref = reference;
 3860|     28|	data.len = sizeof(defbuf);
 3861|     28|	data.key_data = defbuf;
 3862|     28|	rv = sc_card_ctl(p15card->card, SC_CARDCTL_GET_DEFAULT_KEY, &data);
 3863|     28|	if (rv >= 0)
  ------------------
  |  Branch (3863:6): [True: 1, False: 27]
  ------------------
 3864|      1|		defsize = data.len;
 3865|       |
 3866|     28|	if (callbacks.get_key)   {
  ------------------
  |  Branch (3866:6): [True: 0, False: 28]
  ------------------
 3867|      0|		rv = callbacks.get_key(profile, type, reference, defbuf, defsize, pinbuf, pinsize);
 3868|      0|		LOG_TEST_RET(ctx, rv, "Cannot get 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3869|     28|	} else if (rv >= 0) {
  ------------------
  |  Branch (3869:13): [True: 1, False: 27]
  ------------------
 3870|      1|		if (*pinsize < defsize)
  ------------------
  |  Branch (3870:7): [True: 0, False: 1]
  ------------------
 3871|      1|			LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "Get transport key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3872|       |
 3873|      1|		memcpy(pinbuf, data.key_data, data.len);
 3874|      1|		*pinsize = data.len;
 3875|     27|	} else {
 3876|       |		/* pinbuf and pinsize were not filled */
 3877|     27|		LOG_TEST_RET(ctx, SC_ERROR_INTERNAL, "Get transport key error");
  ------------------
  |  |  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: 27, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|     27|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3878|     27|	}
 3879|       |
 3880|      1|	memset(&auth_info, 0, sizeof(auth_info));
 3881|      1|	auth_info.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|      1|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 3882|      1|	auth_info.auth_method = type;
 3883|      1|	auth_info.attrs.pin.reference = reference;
 3884|      1|	auth_info.attrs.pin.stored_length = *pinsize;
 3885|      1|	auth_info.attrs.pin.max_length = *pinsize;
 3886|      1|	auth_info.attrs.pin.min_length = *pinsize;
 3887|       |
 3888|      1|	pin_obj = sc_pkcs15init_new_object(SC_PKCS15_TYPE_AUTH_PIN, "Default transport key", NULL, &auth_info);
  ------------------
  |  |  445|      1|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
 3889|      1|	if (!pin_obj)
  ------------------
  |  Branch (3889:6): [True: 0, False: 1]
  ------------------
 3890|      1|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot allocate AUTH 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3891|       |
 3892|      1|	rv = sc_pkcs15_add_object(p15card, pin_obj);
 3893|      1|	LOG_TEST_RET(ctx, rv, "Cannot add PKCS#15 AUTH object");
  ------------------
  |  |  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: 0, False: 1]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 1]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3894|       |
 3895|      1|	sc_pkcs15_pincache_add(p15card, pin_obj, pinbuf, *pinsize);
 3896|       |
 3897|      1|	LOG_FUNC_RETURN(ctx, 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 3898|      1|}
fuzz_pkcs15init.c:do_select_parent:
 4136|  2.44k|{
 4137|  2.44k|	struct sc_context *ctx = p15card->card->ctx;
 4138|  2.44k|	struct sc_path	path;
 4139|  2.44k|	int		r;
 4140|       |
 4141|  2.44k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.44k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.44k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.44k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.44k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.44k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4142|       |	/* Get the parent's path */
 4143|  2.44k|	path = file->path;
 4144|  2.44k|	if (path.len >= 2)
  ------------------
  |  Branch (4144:6): [True: 2.37k, False: 75]
  ------------------
 4145|  2.37k|		path.len -= 2;
 4146|  2.44k|	if (!path.len && !path.aid.len)
  ------------------
  |  Branch (4146:6): [True: 418, False: 2.03k]
  |  Branch (4146:19): [True: 398, False: 20]
  ------------------
 4147|    398|		sc_format_path("3F00", &path);
 4148|       |
 4149|       |	/* Select the parent DF. */
 4150|  2.44k|	*parent = NULL;
 4151|  2.44k|	r = sc_select_file(p15card->card, &path, parent);
 4152|       |	/* If DF doesn't exist, create it (unless it's the MF,
 4153|       |	 * but then something's badly broken anyway :-) */
 4154|  2.44k|	if (r == SC_ERROR_FILE_NOT_FOUND && path.len > 2) {
  ------------------
  |  |   51|  4.89k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (4154:6): [True: 272, False: 2.17k]
  |  Branch (4154:38): [True: 240, False: 32]
  ------------------
 4155|    240|		r = sc_profile_get_file_by_path(profile, &path, parent);
 4156|    240|		if (r < 0) {
  ------------------
  |  Branch (4156:7): [True: 3, False: 237]
  ------------------
 4157|      3|			sc_log(ctx, "no profile template for DF %s", sc_print_path(&path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4158|      3|			LOG_FUNC_RETURN(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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4159|      3|		}
 4160|       |
 4161|    237|		r = sc_pkcs15init_create_file(profile, p15card, *parent);
 4162|    237|		if (r < 0) {
  ------------------
  |  Branch (4162:7): [True: 64, False: 173]
  ------------------
 4163|     64|			sc_file_free(*parent);
 4164|     64|			*parent = NULL;
 4165|     64|		}
 4166|    237|		LOG_TEST_RET(ctx, r, "Cannot create parent DF");
  ------------------
  |  |  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: 64, False: 173]
  |  |  |  |  ------------------
  |  |  |  |  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|    237|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 173]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4167|       |
 4168|    173|		r = sc_select_file(p15card->card, &path, NULL);
 4169|    173|		if (r < 0) {
  ------------------
  |  Branch (4169:7): [True: 24, False: 149]
  ------------------
 4170|     24|			sc_file_free(*parent);
 4171|     24|			*parent = NULL;
 4172|     24|		}
 4173|    173|		LOG_TEST_RET(ctx, r, "Cannot select parent DF");
  ------------------
  |  |  174|    173|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    173|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    173|	int _ret = (r); \
  |  |  |  |  168|    173|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 24, False: 149]
  |  |  |  |  ------------------
  |  |  |  |  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|    173|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 149]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4174|    173|	}
 4175|  2.20k|	else if (r == SC_SUCCESS && !strcmp(p15card->card->name, "STARCOS")) {
  ------------------
  |  |   28|  4.41k|#define SC_SUCCESS				0
  ------------------
  |  Branch (4175:11): [True: 1.83k, False: 371]
  |  Branch (4175:30): [True: 2, False: 1.83k]
  ------------------
 4176|       |		/* in case of starcos spk 2.3 SELECT FILE does not
 4177|       |		 * give us the ACLs => ask the profile */
 4178|      2|		sc_file_free(*parent);
 4179|       |
 4180|      2|		r = sc_profile_get_file_by_path(profile, &path, parent);
 4181|      2|		if (r < 0) {
  ------------------
  |  Branch (4181:7): [True: 2, False: 0]
  ------------------
 4182|      2|			sc_log(ctx, "in StarCOS profile there is no template for DF %s", sc_print_path(&path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4183|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4184|      2|		}
 4185|      2|	}
 4186|       |
 4187|  2.35k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  2.35k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.35k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.35k|	int _ret = r; \
  |  |  |  |  155|  2.35k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.35k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.35k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    371|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 371, False: 1.98k]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.35k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.35k|	} else { \
  |  |  |  |  159|      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.35k|	return _ret; \
  |  |  |  |  163|  2.35k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4188|  2.35k|}
fuzz_pkcs15init.c:sc_pkcs15init_fixup_acls:
 4309|  1.06k|{
 4310|  1.06k|	struct sc_context *ctx = p15card->card->ctx;
 4311|  1.06k|	unsigned int	op;
 4312|  1.06k|	int		r = 0;
 4313|       |
 4314|  1.06k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  1.06k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  1.06k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  1.06k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  1.06k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 1.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4315|  33.9k|	for (op = 0; r == 0 && op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|  33.9k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (4315:15): [True: 33.9k, False: 0]
  |  Branch (4315:25): [True: 32.8k, False: 1.05k]
  ------------------
 4316|  32.8k|		struct sc_acl_entry acls[SC_MAX_OP_ACS];
 4317|  32.8k|		const struct sc_acl_entry *acl;
 4318|  32.8k|		const char	*what;
 4319|  32.8k|		int		added = 0, num, ii;
 4320|       |
 4321|       |		/* First, get original ACLs */
 4322|  32.8k|		acl = sc_file_get_acl_entry(file, op);
 4323|  65.7k|		for (num = 0; num < SC_MAX_OP_ACS && acl; num++, acl = acl->next)
  ------------------
  |  |   89|   131k|#define SC_MAX_OP_ACS                   16
  ------------------
  |  Branch (4323:17): [True: 65.7k, False: 0]
  |  Branch (4323:40): [True: 32.8k, False: 32.8k]
  ------------------
 4324|  32.8k|			acls[num] = *acl;
 4325|       |
 4326|  32.8k|		sc_file_clear_acl_entries(file, op);
 4327|  65.7k|		for (ii = 0; ii < num; ii++) {
  ------------------
  |  Branch (4327:16): [True: 32.8k, False: 32.8k]
  ------------------
 4328|  32.8k|			acl = acls + ii;
 4329|  32.8k|			if (acl->method != SC_AC_SYMBOLIC)
  ------------------
  |  |  155|  32.8k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (4329:8): [True: 30.3k, False: 2.47k]
  ------------------
 4330|  30.3k|				goto next;
 4331|       |
 4332|  2.47k|			if (acl->key_ref == SC_PKCS15INIT_SO_PIN) {
  ------------------
  |  |  169|  2.47k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  |  Branch (4332:8): [True: 919, False: 1.55k]
  ------------------
 4333|    919|				acl = so_acl;
 4334|    919|				what = "SO PIN";
 4335|    919|			}
 4336|  1.55k|			else if (acl->key_ref == SC_PKCS15INIT_USER_PIN) {
  ------------------
  |  |  171|  1.55k|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  |  Branch (4336:13): [True: 1.54k, False: 10]
  ------------------
 4337|  1.54k|				acl = user_acl;
 4338|  1.54k|				what = "user PIN";
 4339|  1.54k|			}
 4340|     10|			else {
 4341|     10|				sc_log(ctx, "ACL references unknown symbolic PIN %d", acl->key_ref);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4342|     10|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|     10|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 4343|     10|			}
 4344|       |
 4345|       |			/* If we weren't given a replacement ACL,
 4346|       |			 * leave the original ACL untouched */
 4347|  2.46k|			if (acl->key_ref == (unsigned int)-1) {
  ------------------
  |  Branch (4347:8): [True: 0, False: 2.46k]
  ------------------
 4348|      0|				sc_log(ctx, "ACL references %s, which is not defined", what);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 4349|      0|				return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 4350|      0|			}
 4351|       |
 4352|  2.46k|			if (acl->method == SC_AC_NONE)
  ------------------
  |  |  150|  2.46k|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (4352:8): [True: 476, False: 1.99k]
  ------------------
 4353|    476|				continue;
 4354|  32.3k|		next:
 4355|  32.3k|			sc_file_add_acl_entry(file, op, acl->method, acl->key_ref);
 4356|  32.3k|			added++;
 4357|  32.3k|		}
 4358|  32.8k|		if (!added)
  ------------------
  |  Branch (4358:7): [True: 476, False: 32.3k]
  ------------------
 4359|    476|			sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|    476|#define SC_AC_NONE			0x00000000
  ------------------
 4360|  32.8k|	}
 4361|       |
 4362|  1.05k|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|  1.05k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.05k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.05k|	int _ret = r; \
  |  |  |  |  155|  1.05k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.05k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 1.05k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.05k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.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|  1.05k|	return _ret; \
  |  |  |  |  163|  1.05k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4363|  1.05k|}
fuzz_pkcs15init.c:sc_pkcs15init_qualify_pin:
 4491|  3.47k|{
 4492|  3.47k|	struct sc_context *ctx = card->ctx;
 4493|  3.47k|	struct sc_pkcs15_pin_attributes *pin_attrs;
 4494|       |
 4495|  3.47k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.47k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.47k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.47k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.47k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.47k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4496|  3.47k|	if (auth_info == NULL)
  ------------------
  |  Branch (4496:6): [True: 0, False: 3.47k]
  ------------------
 4497|  3.47k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4498|       |
 4499|  3.47k|	if (pin_len == 0 || auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  3.34k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (4499:6): [True: 128, False: 3.34k]
  |  Branch (4499:22): [True: 0, False: 3.34k]
  ------------------
 4500|  3.47k|		LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    128|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    128|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    128|	int _ret = r; \
  |  |  |  |  155|    128|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 128, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    128|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  157|    128|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    128|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    128|	return _ret; \
  |  |  |  |  163|    128|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4501|       |
 4502|  3.34k|	pin_attrs = &auth_info->attrs.pin;
 4503|       |
 4504|  3.34k|	if (pin_len < pin_attrs->min_length) {
  ------------------
  |  Branch (4504:6): [True: 0, False: 3.34k]
  ------------------
 4505|      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__
  |  |  ------------------
  ------------------
 4506|      0|		       "%s too short (min length %"SC_FORMAT_LEN_SIZE_T"u)",
 4507|      0|		       pin_name, pin_attrs->min_length);
 4508|      0|		LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4509|      0|	}
 4510|  3.34k|	if (pin_len > pin_attrs->max_length) {
  ------------------
  |  Branch (4510:6): [True: 2.07k, False: 1.27k]
  ------------------
 4511|  2.07k|		sc_log(ctx,
  ------------------
  |  |   71|  2.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__
  |  |  ------------------
  ------------------
 4512|  2.07k|		       "%s too long (max length %"SC_FORMAT_LEN_SIZE_T"u)",
 4513|  2.07k|		       pin_name, pin_attrs->max_length);
 4514|  2.07k|		LOG_FUNC_RETURN(ctx, SC_ERROR_WRONG_LENGTH);
  ------------------
  |  |  164|  2.07k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  2.07k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  2.07k|	int _ret = r; \
  |  |  |  |  155|  2.07k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 2.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  2.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|  2.07k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 2.07k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  2.07k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  2.07k|	} else { \
  |  |  |  |  159|      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.07k|	return _ret; \
  |  |  |  |  163|  2.07k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4515|  2.07k|	}
 4516|       |
 4517|  1.27k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  1.27k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.27k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.27k|	int _ret = r; \
  |  |  |  |  155|  1.27k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.27k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.27k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, 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.27k]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.27k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.27k|	} else { \
  |  |  |  |  159|      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.27k|	return _ret; \
  |  |  |  |  163|  1.27k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
 4518|  1.27k|}
fuzz_pkcs15init.c:sc_pkcs15init_read_info:
 4526|  3.27k|{
 4527|  3.27k|	struct sc_path	path;
 4528|  3.27k|	struct sc_file	*file = NULL;
 4529|  3.27k|	unsigned char	*mem = NULL;
 4530|  3.27k|	size_t		len = 0;
 4531|  3.27k|	int		r;
 4532|       |
 4533|  3.27k|	sc_format_path(OPENSC_INFO_FILEPATH, &path);
  ------------------
  |  |   71|  3.27k|#define OPENSC_INFO_FILEPATH		"3F0050154946"
  ------------------
 4534|  3.27k|	r = sc_select_file(card, &path, &file);
 4535|  3.27k|	if (r >= 0) {
  ------------------
  |  Branch (4535:6): [True: 141, False: 3.13k]
  ------------------
 4536|    141|		len = file->size;
 4537|    141|		sc_file_free(file);
 4538|    141|		if (len > MAX_FILE_SIZE)
  ------------------
  |  |  229|    141|#define MAX_FILE_SIZE 65535
  ------------------
  |  Branch (4538:7): [True: 0, False: 141]
  ------------------
 4539|      0|			return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
 4540|    141|		mem = malloc(len);
 4541|    141|		if (mem != NULL)
  ------------------
  |  Branch (4541:7): [True: 141, False: 0]
  ------------------
 4542|    141|			r = sc_read_binary(card, 0, mem, len, 0);
 4543|      0|		else
 4544|      0|			r = SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4545|    141|	}
 4546|  3.13k|	else   {
 4547|  3.13k|		r = 0;
 4548|  3.13k|		sc_file_free(file);
 4549|  3.13k|	}
 4550|       |
 4551|  3.27k|	if (r >= 0)
  ------------------
  |  Branch (4551:6): [True: 3.26k, False: 13]
  ------------------
 4552|  3.26k|		r = sc_pkcs15init_parse_info(card, mem, r, profile);
 4553|       |
 4554|  3.27k|	if (mem)
  ------------------
  |  Branch (4554:6): [True: 141, False: 3.13k]
  ------------------
 4555|    141|		free(mem);
 4556|  3.27k|	return r;
 4557|  3.27k|}
fuzz_pkcs15init.c:sc_pkcs15init_parse_info:
 4587|  3.26k|{
 4588|  3.26k|	unsigned char	tag;
 4589|  3.26k|	const unsigned char *end;
 4590|  3.26k|	unsigned int	nopts = 0;
 4591|  3.26k|	size_t		n;
 4592|  3.26k|	int	r = 0;
 4593|       |
 4594|  3.26k|	if ((p == NULL) || (len == 0))
  ------------------
  |  Branch (4594:6): [True: 3.13k, False: 128]
  |  Branch (4594:21): [True: 91, False: 37]
  ------------------
 4595|  3.22k|		return 0;
 4596|       |
 4597|     37|	end = p + (len - 1);
 4598|    940|	while (p < end) {	/* more bytes to look at */
  ------------------
  |  Branch (4598:9): [True: 939, False: 1]
  ------------------
 4599|    939|		r = 0;
 4600|       |
 4601|    939|		tag = *p; p++;
 4602|    939|		if ((tag == 0) || (tag == 0xff) || (p >= end))
  ------------------
  |  Branch (4602:7): [True: 28, False: 911]
  |  Branch (4602:21): [True: 4, False: 907]
  |  Branch (4602:38): [True: 0, False: 907]
  ------------------
 4603|     32|			break;
 4604|       |
 4605|    907|		n = *p;
 4606|    907|		p++;
 4607|       |
 4608|    907|		if (p >= end || p + n > end) { /* invalid length byte n */
  ------------------
  |  Branch (4608:7): [True: 0, False: 907]
  |  Branch (4608:19): [True: 4, False: 903]
  ------------------
 4609|      4|			r = SC_ERROR_PKCS15INIT;
  ------------------
  |  |  102|      4|#define SC_ERROR_PKCS15INIT			-1500
  ------------------
 4610|      4|			goto error;
 4611|      4|		}
 4612|       |
 4613|    903|		switch (tag) {
 4614|    632|		case OPENSC_INFO_TAG_PROFILE:
  ------------------
  |  |   73|    632|#define OPENSC_INFO_TAG_PROFILE		0x01
  ------------------
  |  Branch (4614:3): [True: 632, False: 271]
  ------------------
 4615|    632|			r = set_info_string(&profile->name, p, n);
 4616|    632|			if (r < 0)
  ------------------
  |  Branch (4616:8): [True: 0, False: 632]
  ------------------
 4617|      0|				goto error;
 4618|    632|			break;
 4619|    632|		case OPENSC_INFO_TAG_OPTION:
  ------------------
  |  |   74|     30|#define OPENSC_INFO_TAG_OPTION		0x02
  ------------------
  |  Branch (4619:3): [True: 30, False: 873]
  ------------------
 4620|     30|			if (nopts >= SC_PKCS15INIT_MAX_OPTIONS - 1) {
  ------------------
  |  |   95|     30|#define SC_PKCS15INIT_MAX_OPTIONS 16
  ------------------
  |  Branch (4620:8): [True: 0, False: 30]
  ------------------
 4621|      0|				sc_log(card->ctx, "Too many options in OpenSC Info 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__
  |  |  ------------------
  ------------------
 4622|      0|				r = SC_ERROR_PKCS15INIT;
  ------------------
  |  |  102|      0|#define SC_ERROR_PKCS15INIT			-1500
  ------------------
 4623|      0|				goto error;
 4624|      0|			}
 4625|     30|			r = set_info_string(&profile->options[nopts], p, n);
 4626|     30|			if (r < 0)
  ------------------
  |  Branch (4626:8): [True: 0, False: 30]
  ------------------
 4627|      0|				goto error;
 4628|     30|			profile->options[++nopts] = NULL;
 4629|     30|			break;
 4630|    241|		default:
  ------------------
  |  Branch (4630:3): [True: 241, False: 662]
  ------------------
 4631|    241|			/* Unknown options ignored */ ;
 4632|    903|		}
 4633|    903|		p += n;
 4634|    903|	}
 4635|     33|	return 0;
 4636|       |
 4637|      4|error:
 4638|      4|	sc_log(card->ctx, "OpenSC info file corrupted");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
 4639|      4|	if (profile->name) {
  ------------------
  |  Branch (4639:6): [True: 4, False: 0]
  ------------------
 4640|      4|		free(profile->name);
 4641|      4|		profile->name = NULL;
 4642|      4|	}
 4643|      8|	for (size_t i = 0; i < nopts; i++) {
  ------------------
  |  Branch (4643:21): [True: 4, False: 4]
  ------------------
 4644|      4|		if (profile->options[i])
  ------------------
  |  Branch (4644:7): [True: 4, False: 0]
  ------------------
 4645|      4|			free(profile->options[i]);
 4646|       |		profile->options[i] = NULL;
 4647|      4|	}
 4648|      4|	return r;
 4649|     37|}
fuzz_pkcs15init.c:set_info_string:
 4562|    662|{
 4563|    662|	char	*s;
 4564|       |
 4565|    662|	if (!(s = malloc(len+1)))
  ------------------
  |  Branch (4565:6): [True: 0, False: 662]
  ------------------
 4566|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 4567|    662|	memcpy(s, p, len);
 4568|    662|	s[len] = '\0';
 4569|    662|	if (*strp)
  ------------------
  |  Branch (4569:6): [True: 632, False: 30]
  ------------------
 4570|    632|		free(*strp);
 4571|    662|	*strp = s;
 4572|    662|	return SC_SUCCESS;
  ------------------
  |  |   28|    662|#define SC_SUCCESS				0
  ------------------
 4573|    662|}
fuzz_pkcs15init.c:sc_pkcs15init_write_info:
 4676|     98|{
 4677|     98|	struct sc_file	*file = NULL, *df = profile->df_info->file;
 4678|     98|	unsigned char	buffer[128], *p, *end;
 4679|     98|	unsigned int	method;
 4680|     98|	unsigned long	key_ref;
 4681|     98|	int		n, r;
 4682|       |
 4683|     98|	if (profile->ops->emu_write_info)
  ------------------
  |  Branch (4683:6): [True: 0, False: 98]
  ------------------
 4684|      0|		return profile->ops->emu_write_info(profile, p15card, pin_obj);
 4685|       |
 4686|     98|	memset(buffer, 0, sizeof(buffer));
 4687|       |
 4688|     98|	file = sc_file_new();
 4689|     98|	file->path.type = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|     98|#define SC_PATH_TYPE_PATH		2
  ------------------
 4690|     98|	memcpy(file->path.value, df->path.value, df->path.len);
 4691|     98|	file->path.len = df->path.len;
 4692|     98|	sc_append_file_id(&file->path, OPENSC_INFO_FILEID);
  ------------------
  |  |   72|     98|#define OPENSC_INFO_FILEID		0x4946
  ------------------
 4693|     98|	file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|     98|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 4694|     98|	file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|     98|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
 4695|     98|	file->id = OPENSC_INFO_FILEID;
  ------------------
  |  |   72|     98|#define OPENSC_INFO_FILEID		0x4946
  ------------------
 4696|     98|	file->size = sizeof(buffer);
 4697|       |
 4698|     98|	if (pin_obj != NULL) {
  ------------------
  |  Branch (4698:6): [True: 98, False: 0]
  ------------------
 4699|     98|		method = SC_AC_CHV;
  ------------------
  |  |  151|     98|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 4700|     98|		key_ref = ((struct sc_pkcs15_auth_info *) pin_obj->data)->attrs.pin.reference;
 4701|     98|	}
 4702|      0|	else {
 4703|      0|		method = SC_AC_NONE; /* Unprotected */
  ------------------
  |  |  150|      0|#define SC_AC_NONE			0x00000000
  ------------------
 4704|      0|		key_ref = 0;
 4705|      0|	}
 4706|  3.13k|	for (n = 0; n < SC_MAX_AC_OPS; n++) {
  ------------------
  |  |  198|  3.13k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (4706:14): [True: 3.03k, False: 98]
  ------------------
 4707|  3.03k|		if (n == SC_AC_OP_READ)
  ------------------
  |  |  188|  3.03k|#define SC_AC_OP_READ			22
  ------------------
  |  Branch (4707:7): [True: 98, False: 2.94k]
  ------------------
 4708|     98|			sc_file_add_acl_entry(file, n, SC_AC_NONE, 0);
  ------------------
  |  |  150|     98|#define SC_AC_NONE			0x00000000
  ------------------
 4709|  2.94k|		else
 4710|  2.94k|			sc_file_add_acl_entry(file, n, method, key_ref);
 4711|  3.03k|	}
 4712|       |
 4713|     98|	p = buffer;
 4714|     98|	end = buffer + sizeof(buffer);
 4715|       |
 4716|     98|	r = do_encode_string(&p, end, OPENSC_INFO_TAG_PROFILE, profile->name);
  ------------------
  |  |   73|     98|#define OPENSC_INFO_TAG_PROFILE		0x01
  ------------------
 4717|     98|	for (n = 0; r >= 0 && profile->options[n]; n++)
  ------------------
  |  Branch (4717:14): [True: 98, False: 0]
  |  Branch (4717:24): [True: 0, False: 98]
  ------------------
 4718|      0|		r = do_encode_string(&p, end, OPENSC_INFO_TAG_OPTION, profile->options[n]);
  ------------------
  |  |   74|      0|#define OPENSC_INFO_TAG_OPTION		0x02
  ------------------
 4719|       |
 4720|     98|	if (r >= 0)
  ------------------
  |  Branch (4720:6): [True: 98, False: 0]
  ------------------
 4721|     98|		r = sc_pkcs15init_update_file(profile, p15card, file, buffer, (unsigned int)file->size);
 4722|       |
 4723|     98|	sc_file_free(file);
 4724|     98|	return r;
 4725|     98|}
fuzz_pkcs15init.c:do_encode_string:
 4655|     98|{
 4656|     98|	unsigned char	*p = *memp;
 4657|     98|	size_t	n;
 4658|       |
 4659|     98|	n = s ? strlen(s) : 0;
  ------------------
  |  Branch (4659:6): [True: 98, False: 0]
  ------------------
 4660|     98|	if (n > 255)
  ------------------
  |  Branch (4660:6): [True: 0, False: 98]
  ------------------
 4661|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 4662|     98|	if (p + 2 + n > end)
  ------------------
  |  Branch (4662:6): [True: 0, False: 98]
  ------------------
 4663|      0|		return SC_ERROR_BUFFER_TOO_SMALL;
  ------------------
  |  |   76|      0|#define SC_ERROR_BUFFER_TOO_SMALL		-1303
  ------------------
 4664|     98|	*p++ = tag;
 4665|     98|	*p++ = n;
 4666|     98|	memcpy(p, s, n);
 4667|     98|	*memp = p + n;
 4668|     98|	return 0;
 4669|     98|}

sc_pkcs15init_get_muscle_ops:
  322|    295|{
  323|    295|	return &sc_pkcs15init_muscle_operations;
  324|    295|}
pkcs15-muscle.c:muscle_erase_card:
   44|    113|{
   45|    113|	int r;
   46|    113|	struct sc_file *file;
   47|    113|	struct sc_path path;
   48|    113|	memset(&file, 0, sizeof(file));
   49|    113|	sc_format_path("3F00", &path);
   50|    113|	if ((r = sc_select_file(p15card->card, &path, &file)) < 0)
  ------------------
  |  Branch (50:6): [True: 4, False: 109]
  ------------------
   51|      4|		return r;
   52|    109|	if ((r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_ERASE)) < 0) {
  ------------------
  |  |  202|    109|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|    109|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  |  Branch (52:6): [True: 27, False: 82]
  ------------------
   53|     27|		sc_file_free(file);
   54|     27|		return r;
   55|     27|	}
   56|     82|	sc_file_free(file);
   57|     82|	if ((r = sc_delete_file(p15card->card, &path)) < 0)
  ------------------
  |  Branch (57:6): [True: 4, False: 78]
  ------------------
   58|      4|		return r;
   59|     78|	return 0;
   60|     82|}
pkcs15-muscle.c:muscle_init_card:
   64|     10|{
   65|     10|	return 0;
   66|     10|}
pkcs15-muscle.c:muscle_create_dir:
   70|     10|{
   71|     10|	int	r;
   72|     10|	struct sc_file *file;
   73|     10|	struct sc_path path;
   74|     10|	memset(&file, 0, sizeof(file));
   75|     10|	sc_format_path("3F00", &path);
   76|     10|	if ((r = sc_select_file(p15card->card, &path, &file)) < 0)
  ------------------
  |  Branch (76:6): [True: 1, False: 9]
  ------------------
   77|      1|		return r;
   78|      9|	if ((r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_CREATE)) < 0) {
  ------------------
  |  |  169|      9|#define SC_AC_OP_CREATE			3
  ------------------
  |  Branch (78:6): [True: 9, False: 0]
  ------------------
   79|      9|		sc_file_free(file);
   80|      9|		return r;
   81|      9|	}
   82|      0|	sc_file_free(file);
   83|       |
   84|       |	/* Create the application DF */
   85|      0|	if ((r = sc_pkcs15init_create_file(profile, p15card, df)) < 0)
  ------------------
  |  Branch (85:6): [True: 0, False: 0]
  ------------------
   86|      0|		return r;
   87|       |
   88|      0|	if ((r = sc_select_file(p15card->card, &df->path, NULL)) < 0)
  ------------------
  |  Branch (88:6): [True: 0, False: 0]
  ------------------
   89|      0|		return r;
   90|       |
   91|       |
   92|      0|	return 0;
   93|      0|}
pkcs15-muscle.c:muscle_select_pin_reference:
  120|    132|{
  121|    132|	int	preferred;
  122|       |
  123|    132|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    132|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (123:6): [True: 0, False: 132]
  ------------------
  124|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  125|       |
  126|    132|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|    132|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (126:6): [True: 2, False: 130]
  ------------------
  127|      2|		preferred = 0;
  128|    130|	} else {
  129|    130|		preferred = 1;
  130|    130|	}
  131|    132|	if (auth_info->attrs.pin.reference <= preferred) {
  ------------------
  |  Branch (131:6): [True: 128, False: 4]
  ------------------
  132|    128|		auth_info->attrs.pin.reference = preferred;
  133|    128|		return 0;
  134|    128|	}
  135|       |
  136|      4|	if (auth_info->attrs.pin.reference > 2)
  ------------------
  |  Branch (136:6): [True: 3, False: 1]
  ------------------
  137|      3|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      3|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  138|       |
  139|       |	/* Caller, please select a different PIN reference */
  140|      1|	return SC_ERROR_INVALID_PIN_REFERENCE;
  ------------------
  |  |  111|      1|#define SC_ERROR_INVALID_PIN_REFERENCE		-1509
  ------------------
  141|      4|}
pkcs15-muscle.c:muscle_create_pin:
  100|    113|{
  101|    113|	sc_file_t *file;
  102|    113|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  103|    113|	int r;
  104|       |
  105|    113|	if ((r = sc_select_file(p15card->card, &df->path, &file)) < 0)
  ------------------
  |  Branch (105:6): [True: 105, False: 8]
  ------------------
  106|    105|		return r;
  107|      8|	if ((r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_WRITE)) < 0) {
  ------------------
  |  |  190|      8|#define SC_AC_OP_WRITE			24
  ------------------
  |  Branch (107:6): [True: 0, False: 8]
  ------------------
  108|      0|		sc_file_free(file);
  109|      0|		return r;
  110|      0|	}
  111|       |
  112|      8|	auth_info->attrs.pin.flags &= ~SC_PKCS15_PIN_FLAG_LOCAL;
  ------------------
  |  |   55|      8|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  113|      8|	sc_file_free(file);
  114|      8|	return 0;
  115|      8|}
pkcs15-muscle.c:muscle_select_key_reference:
  149|    113|{
  150|    113|	if (key_info->key_reference < MUSCLE_KEY_ID_MIN)
  ------------------
  |  |   40|    113|#define MUSCLE_KEY_ID_MIN	0x00
  ------------------
  |  Branch (150:6): [True: 0, False: 113]
  ------------------
  151|      0|		key_info->key_reference = MUSCLE_KEY_ID_MIN;
  ------------------
  |  |   40|      0|#define MUSCLE_KEY_ID_MIN	0x00
  ------------------
  152|    113|	if (key_info->key_reference > MUSCLE_KEY_ID_MAX)
  ------------------
  |  |   41|    113|#define MUSCLE_KEY_ID_MAX	0x0F
  ------------------
  |  Branch (152:6): [True: 0, False: 113]
  ------------------
  153|      0|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  154|    113|	return 0;
  155|    113|}
pkcs15-muscle.c:muscle_create_key:
  164|    113|{
  165|    113|	return 0;
  166|    113|}
pkcs15-muscle.c:muscle_generate_key:
  233|    113|{
  234|    113|	sc_cardctl_muscle_gen_key_info_t args;
  235|    113|	sc_cardctl_muscle_key_info_t extArgs;
  236|    113|	sc_pkcs15_prkey_info_t *key_info = (sc_pkcs15_prkey_info_t *) obj->data;
  237|    113|	sc_card_t *card = p15card->card;
  238|    113|	sc_file_t* prkf;
  239|    113|	size_t	keybits;
  240|    113|	int		r;
  241|       |
  242|    113|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
  ------------------
  |  |  419|    113|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (242:6): [True: 0, False: 113]
  ------------------
  243|      0|		sc_log(card->ctx,  "Muscle supports only RSA keys (for now).");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  244|      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]
  |  |  ------------------
  ------------------
  245|      0|	}
  246|    113|	keybits = key_info->modulus_length & ~7UL;
  247|    113|	if (keybits > 2048) {
  ------------------
  |  Branch (247:6): [True: 0, False: 113]
  ------------------
  248|      0|		sc_log(card->ctx,  "Unable to generate key, max size is %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__
  |  |  ------------------
  ------------------
  249|      0|				2048);
  250|      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]
  |  |  ------------------
  ------------------
  251|      0|	}
  252|       |	/* Verification stuff */
  253|       |	/* Used for verification AND for obtaining private key acls */
  254|    113|	r = sc_profile_get_file_by_path(profile, &key_info->path, &prkf);
  255|    113|	if(r < 0 || !prkf)
  ------------------
  |  Branch (255:5): [True: 88, False: 25]
  |  Branch (255:14): [True: 0, False: 25]
  ------------------
  256|     88|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  257|     25|	r = sc_pkcs15init_authenticate(profile, p15card, prkf, SC_AC_OP_CRYPTO);
  ------------------
  |  |  173|     25|#define SC_AC_OP_CRYPTO			7
  ------------------
  258|     25|	if (r < 0) {
  ------------------
  |  Branch (258:6): [True: 0, False: 25]
  ------------------
  259|      0|		sc_file_free(prkf);
  260|      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]
  |  |  ------------------
  ------------------
  261|      0|	}
  262|     25|	sc_file_free(prkf);
  263|       |
  264|       |	/* END VERIFICATION STUFF */
  265|       |
  266|       |	/* Public key acls... get_file_by_path as well? */
  267|       |
  268|     25|	memset(&args, 0, sizeof(args));
  269|     25|	args.keyType = 0x01; /* RSA forced */
  270|     25|	args.privateKeyLocation = key_info->key_reference * 2;
  271|     25|	args.publicKeyLocation = key_info->key_reference * 2 + 1;
  272|       |
  273|     25|	args.keySize = keybits;
  274|       |
  275|     25|	r = sc_card_ctl(card, SC_CARDCTL_MUSCLE_GENERATE_KEY, &args);
  276|     25|	if (r < 0) {
  ------------------
  |  Branch (276:6): [True: 16, False: 9]
  ------------------
  277|     16|		sc_log(card->ctx,  "Unable to generate key");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  278|     16|		SC_FUNC_RETURN(card->ctx, SC_LOG_DEBUG_VERBOSE,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]
  |  |  ------------------
  ------------------
  279|     16|	}
  280|       |
  281|      9|	memset(&extArgs, 0, sizeof(extArgs));
  282|      9|	memset(pubkey, 0, sizeof(*pubkey));
  283|       |
  284|      9|	extArgs.keyType = 0x01;
  285|      9|	extArgs.keyLocation = args.publicKeyLocation;
  286|      9|	r = sc_card_ctl(card, SC_CARDCTL_MUSCLE_EXTRACT_KEY, &extArgs);
  287|      9|	if (r < 0) {
  ------------------
  |  Branch (287:6): [True: 7, False: 2]
  ------------------
  288|      7|		sc_log(card->ctx,  "Unable to extract the public key");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  289|      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|      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]
  |  |  ------------------
  ------------------
  290|      7|	}
  291|       |
  292|      2|	pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      2|#define SC_ALGORITHM_RSA		0
  ------------------
  293|      2|	pubkey->u.rsa.modulus.len   = extArgs.modLength;
  294|      2|	pubkey->u.rsa.modulus.data  = extArgs.modValue;
  295|      2|	pubkey->u.rsa.exponent.len  = extArgs.expLength;
  296|      2|	pubkey->u.rsa.exponent.data = extArgs.expValue;
  297|       |
  298|      2|	return r;
  299|      9|}

sc_pkcs15init_get_myeid_ops:
  978|    830|struct sc_pkcs15init_operations *sc_pkcs15init_get_myeid_ops(void) {
  979|    830|	return &sc_pkcs15init_myeid_operations;
  980|    830|}
pkcs15-myeid.c:myeid_erase_card:
  153|    684|myeid_erase_card(struct sc_profile *profile, struct sc_pkcs15_card *p15card) {
  154|    684|	struct sc_context *ctx = p15card->card->ctx;
  155|    684|	struct sc_cardctl_myeid_data_obj data_obj;
  156|    684|	struct sc_file *mf = NULL;
  157|    684|	unsigned char data[8];
  158|    684|	int r;
  159|       |
  160|    684|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    684|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    684|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    684|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    684|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 684]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|       |
  162|    684|	r = myeid_get_init_applet_data(profile, p15card, data, sizeof (data));
  163|    684|	LOG_TEST_RET(ctx, r, "Get init applet date error");
  ------------------
  |  |  174|    684|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    684|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    684|	int _ret = (r); \
  |  |  |  |  168|    684|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 681]
  |  |  |  |  ------------------
  |  |  |  |  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|    684|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 681]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  164|       |
  165|       |	/* Select parent DF and verify PINs/key as necessary */
  166|    681|	r = sc_select_file(p15card->card, sc_get_mf_path(), &mf);
  167|    681|	LOG_TEST_RET(ctx, r, "Cannot select MF");
  ------------------
  |  |  174|    681|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    681|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    681|	int _ret = (r); \
  |  |  |  |  168|    681|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 663, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  169|    663|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    663|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    663|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    663|		return _ret; \
  |  |  |  |  172|    663|	} \
  |  |  |  |  173|    681|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  168|       |
  169|       |	/* ACLs are not actives if file is not in the operational state */
  170|     18|	if (mf->status == SC_FILE_STATUS_ACTIVATED)
  ------------------
  |  |  236|     18|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  |  Branch (170:6): [True: 7, False: 11]
  ------------------
  171|      7|		r = sc_pkcs15init_authenticate(profile, p15card, mf, SC_AC_OP_DELETE);
  ------------------
  |  |  168|      7|#define SC_AC_OP_DELETE			2
  ------------------
  172|     18|	if (r < 0)
  ------------------
  |  Branch (172:6): [True: 2, False: 16]
  ------------------
  173|      2|		sc_file_free(mf);
  174|     18|	LOG_TEST_RET(ctx, r, "'DELETE' authentication failed on MF");
  ------------------
  |  |  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: 2, False: 16]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 16]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  175|       |
  176|     16|	data_obj.P1 = 0x01;
  177|     16|	data_obj.P2 = 0xE0;
  178|     16|	data_obj.Data = data;
  179|     16|	data_obj.DataLen = sizeof (data);
  180|       |
  181|     16|	r = sc_card_ctl(p15card->card, SC_CARDCTL_MYEID_PUTDATA, &data_obj);
  182|     16|	sc_file_free(mf);
  183|       |
  184|     16|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  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|      6|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 6, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|     16|}
pkcs15-myeid.c:myeid_get_init_applet_data:
   73|    684|		unsigned char *data, size_t data_len) {
   74|    684|	struct sc_context *ctx = p15card->card->ctx;
   75|    684|	struct sc_file *tmp_file = NULL;
   76|    684|	const struct sc_acl_entry *entry = NULL;
   77|    684|	int r;
   78|       |
   79|    684|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    684|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    684|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    684|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    684|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 684]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   80|       |
   81|    684|	if (data_len < 8)
  ------------------
  |  Branch (81:6): [True: 0, False: 684]
  ------------------
   82|    684|		LOG_TEST_RET(ctx, SC_ERROR_BUFFER_TOO_SMALL, "Cannot get init applet 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   83|       |
   84|    684|	*(data + 0) = 0xFF;
   85|    684|	*(data + 1) = 0xFF;
   86|       |
   87|       |	/* MF acls */
   88|    684|	sc_file_dup(&tmp_file, profile->mf_info->file);
   89|    684|	if (tmp_file == NULL)
  ------------------
  |  Branch (89:6): [True: 0, False: 684]
  ------------------
   90|    684|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|       |
   92|    684|	r = sc_pkcs15init_fixup_file(profile, p15card, tmp_file);
   93|    684|	if (r < 0)
  ------------------
  |  Branch (93:6): [True: 0, False: 684]
  ------------------
   94|      0|		sc_file_free(tmp_file);
   95|    684|	LOG_TEST_RET(ctx, r, "MF fixup failed");
  ------------------
  |  |  174|    684|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    684|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    684|	int _ret = (r); \
  |  |  |  |  168|    684|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 684]
  |  |  |  |  ------------------
  |  |  |  |  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|    684|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 684]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   96|       |
   97|       |	/* AC 'Create DF' and 'Create EF' */
   98|    684|	*(data + 2) = 0x00; /* 'NONE' */
   99|    684|	entry = sc_file_get_acl_entry(tmp_file, SC_AC_OP_CREATE);
  ------------------
  |  |  169|    684|#define SC_AC_OP_CREATE			3
  ------------------
  100|    684|	if (entry->method == SC_AC_CHV)
  ------------------
  |  |  151|    684|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (100:6): [True: 14, False: 670]
  ------------------
  101|     14|		*(data + 2) = entry->key_ref | (entry->key_ref << 4); /* 'CHVx'. */
  102|    670|	else if (entry->method == SC_AC_NEVER)
  ------------------
  |  |  163|    670|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (102:11): [True: 7, False: 663]
  ------------------
  103|      7|		*(data + 2) = 0xFF; /* 'NEVER'. */
  104|       |
  105|       |	/* AC 'INITIALISE APPLET'. */
  106|    684|	*(data + 3) = 0x0F; /* 'NONE' */
  107|    684|#ifndef KEEP_AC_NONE_FOR_INIT_APPLET
  108|    684|	entry = sc_file_get_acl_entry(tmp_file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    684|#define SC_AC_OP_DELETE			2
  ------------------
  109|    684|	if (entry->method == SC_AC_CHV)
  ------------------
  |  |  151|    684|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (109:6): [True: 55, False: 629]
  ------------------
  110|     55|		*(data + 3) = (entry->key_ref << 4) | 0xF;
  111|    629|	else if (entry->method == SC_AC_NEVER)
  ------------------
  |  |  163|    629|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (111:11): [True: 0, False: 629]
  ------------------
  112|      0|		*(data + 3) = 0xFF;
  113|    684|#endif
  114|    684|	*(data + 4) = 0xFF;
  115|       |
  116|    684|	sc_file_free(tmp_file);
  117|    684|	tmp_file = NULL;
  118|       |
  119|       |	/* Application DF (5015) acls */
  120|    684|	sc_file_dup(&tmp_file, profile->df_info->file);
  121|    684|	if (tmp_file == NULL)
  ------------------
  |  Branch (121:6): [True: 0, False: 684]
  ------------------
  122|    684|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "Cannot duplicate Application 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  123|    684|	r = sc_pkcs15init_fixup_file(profile, p15card, tmp_file);
  124|    684|	if (r < 0)
  ------------------
  |  Branch (124:6): [True: 3, False: 681]
  ------------------
  125|      3|		sc_file_free(tmp_file);
  126|    684|	LOG_TEST_RET(ctx, r, "Application DF fixup failed");
  ------------------
  |  |  174|    684|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    684|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    684|	int _ret = (r); \
  |  |  |  |  168|    684|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 3, False: 681]
  |  |  |  |  ------------------
  |  |  |  |  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|    684|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 681]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  127|       |
  128|       |	/* AC 'Create DF' and 'Create EF' */
  129|    681|	*(data + 5) = 0x00; /* 'NONE' */
  130|    681|	entry = sc_file_get_acl_entry(tmp_file, SC_AC_OP_CREATE);
  ------------------
  |  |  169|    681|#define SC_AC_OP_CREATE			3
  ------------------
  131|    681|	if (entry->method == SC_AC_CHV)
  ------------------
  |  |  151|    681|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (131:6): [True: 18, False: 663]
  ------------------
  132|     18|		*(data + 5) = entry->key_ref | (entry->key_ref << 4); /* 'CHVx' */
  133|    663|	else if (entry->method == SC_AC_NEVER)
  ------------------
  |  |  163|    663|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (133:11): [True: 5, False: 658]
  ------------------
  134|      5|		*(data + 5) = 0xFF; /* 'NEVER'. */
  135|       |
  136|       |	/* AC 'Self delete' */
  137|    681|	*(data + 6) = 0x0F; /* 'NONE' */
  138|    681|	entry = sc_file_get_acl_entry(tmp_file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    681|#define SC_AC_OP_DELETE			2
  ------------------
  139|    681|	if (entry->method == SC_AC_CHV)
  ------------------
  |  |  151|    681|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
  |  Branch (139:6): [True: 22, False: 659]
  ------------------
  140|     22|		*(data + 6) = (entry->key_ref << 4) | 0xF; /* 'CHVx' */
  141|    659|	else if (entry->method == SC_AC_NEVER)
  ------------------
  |  |  163|    659|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (141:11): [True: 0, False: 659]
  ------------------
  142|      0|		*(data + 6) = 0xFF; /* 'NEVER'. */
  143|    681|	*(data + 7) = 0xFF;
  144|       |
  145|    681|	sc_file_free(tmp_file);
  146|    681|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    681|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    681|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    681|	int _ret = r; \
  |  |  |  |  155|    681|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 681, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    681|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 681]
  |  |  |  |  ------------------
  |  |  |  |  157|    681|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    681|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    681|	return _ret; \
  |  |  |  |  163|    681|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  147|    681|}
pkcs15-myeid.c:myeid_init_card:
  191|    334|		sc_pkcs15_card_t *p15card) {
  192|    334|	struct sc_path path;
  193|    334|	struct sc_file *file = NULL;
  194|    334|	u8 rbuf[256];
  195|    334|	int r;
  196|       |
  197|    334|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    334|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    334|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    334|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    334|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 334]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  198|       |
  199|    334|	p15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  597|    334|#define SC_PKCS15_TOKEN_PRN_GENERATION			0x04
  ------------------
              	p15card->tokeninfo->flags = SC_PKCS15_TOKEN_PRN_GENERATION | SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  598|    334|#define SC_PKCS15_TOKEN_EID_COMPLIANT			0x08
  ------------------
  200|       |
  201|    334|	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes128_ecb);
  ------------------
  |  |  142|    334|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
              	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes128_ecb);
  ------------------
  |  |  141|    334|#define SC_PKCS15_ALGO_OP_ENCIPHER		0x10
  ------------------
              	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes128_ecb);
  ------------------
  |  |  882|    334|#define CKM_AES_ECB 0x00001081UL
  ------------------
  202|    334|	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes128_cbc);
  ------------------
  |  |  142|    334|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
              	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes128_cbc);
  ------------------
  |  |  141|    334|#define SC_PKCS15_ALGO_OP_ENCIPHER		0x10
  ------------------
              	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes128_cbc);
  ------------------
  |  |  883|    334|#define CKM_AES_CBC 0x00001082UL
  ------------------
  203|    334|	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes256_ecb);
  ------------------
  |  |  142|    334|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
              	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes256_ecb);
  ------------------
  |  |  141|    334|#define SC_PKCS15_ALGO_OP_ENCIPHER		0x10
  ------------------
              	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes256_ecb);
  ------------------
  |  |  882|    334|#define CKM_AES_ECB 0x00001081UL
  ------------------
  204|    334|	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes256_cbc);
  ------------------
  |  |  142|    334|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
              	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes256_cbc);
  ------------------
  |  |  141|    334|#define SC_PKCS15_ALGO_OP_ENCIPHER		0x10
  ------------------
              	_add_supported_algo(profile, p15card, NULL, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes256_cbc);
  ------------------
  |  |  883|    334|#define CKM_AES_CBC 0x00001082UL
  ------------------
  205|       |
  206|    334|	r = sc_card_ctl(p15card->card, SC_CARDCTL_GET_SERIALNR, &rbuf);
  207|    334|	LOG_TEST_RET(p15card->card->ctx, r,  "Get applet info failed");
  ------------------
  |  |  174|    334|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    334|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    334|	int _ret = (r); \
  |  |  |  |  168|    334|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 119, False: 215]
  |  |  |  |  ------------------
  |  |  |  |  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|    334|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 215]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  208|       |
  209|    215|	sc_format_path("3F00", &path);
  210|    215|	r = sc_select_file(p15card->card, &path, &file);
  211|       |
  212|    215|	sc_file_free(file);
  213|       |
  214|    215|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  164|    215|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    215|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    215|	int _ret = r; \
  |  |  |  |  155|    215|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 215, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    215|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 211]
  |  |  |  |  ------------------
  |  |  |  |  157|    215|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    215|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    215|	return _ret; \
  |  |  |  |  163|    215|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|    215|}
pkcs15-myeid.c:_add_supported_algo:
  465|  2.69k|{
  466|  2.69k|	struct sc_supported_algo_info *algo;
  467|  2.69k|	struct sc_context *ctx = p15card->card->ctx;
  468|  2.69k|	if (oid == NULL) {
  ------------------
  |  Branch (468:6): [True: 0, False: 2.69k]
  ------------------
  469|      0|		sc_log(ctx, "Failed to add algorithms refs - invalid arguments.");
  ------------------
  |  |   71|      0|#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|      0|		return;
  471|      0|	}
  472|  2.69k|	algo = sc_pkcs15_get_specific_supported_algo(p15card, operations, mechanism, oid);
  473|  2.69k|	int rv;
  474|       |
  475|  2.69k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.69k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.69k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.69k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.69k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.69k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  476|  2.69k|	if (!algo) {
  ------------------
  |  Branch (476:6): [True: 2.65k, False: 31]
  ------------------
  477|  2.65k|		unsigned ref = 1, ii;
  478|       |
  479|  5.65k|		for (ii=0;ii<SC_MAX_SUPPORTED_ALGORITHMS && p15card->tokeninfo->supported_algos[ii].reference; ii++)
  ------------------
  |  |   61|  11.3k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (479:13): [True: 5.65k, False: 0]
  |  Branch (479:47): [True: 2.99k, False: 2.65k]
  ------------------
  480|  2.99k|			if (p15card->tokeninfo->supported_algos[ii].reference >= ref)
  ------------------
  |  Branch (480:8): [True: 2.89k, False: 101]
  ------------------
  481|  2.89k|				ref = p15card->tokeninfo->supported_algos[ii].reference + 1;
  482|  2.65k|		if (ii < SC_MAX_SUPPORTED_ALGORITHMS) {
  ------------------
  |  |   61|  2.65k|#define SC_MAX_SUPPORTED_ALGORITHMS	16
  ------------------
  |  Branch (482:7): [True: 2.65k, False: 0]
  ------------------
  483|  2.65k|			algo = &p15card->tokeninfo->supported_algos[ii];
  484|  2.65k|			algo->reference = ref;
  485|  2.65k|			algo->mechanism = mechanism;
  486|  2.65k|			algo->operations = operations;
  487|  2.65k|			algo->algo_id = *oid;
  488|  2.65k|			profile->dirty = 1;
  489|  2.65k|			profile->pkcs15.do_last_update = 1;
  490|  2.65k|		}
  491|       |
  492|  2.65k|	}
  493|  2.69k|	if (object != NULL)
  ------------------
  |  Branch (493:6): [True: 1.35k, False: 1.33k]
  ------------------
  494|  1.35k|		rv = sc_pkcs15_add_supported_algo_ref(object, algo);
  495|  1.33k|	else
  496|  1.33k|		rv = SC_SUCCESS;
  ------------------
  |  |   28|  1.33k|#define SC_SUCCESS				0
  ------------------
  497|       |
  498|  2.69k|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|  2.69k|#define SC_SUCCESS				0
  ------------------
  |  Branch (498:6): [True: 0, False: 2.69k]
  ------------------
  499|      0|		sc_log(ctx, "Failed to add algorithms refs");
  ------------------
  |  |   71|      0|#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|      0|	}
  501|  2.69k|}
pkcs15-myeid.c:myeid_create_dir:
  221|    211|myeid_create_dir(sc_profile_t *profile, sc_pkcs15_card_t *p15card, sc_file_t *df) {
  222|    211|	struct sc_context *ctx = NULL;
  223|    211|	struct sc_file *file = NULL;
  224|    211|	int r = 0, ii;
  225|    211|	static const char *create_dfs[] = {
  226|    211|		"PKCS15-PrKDF",
  227|    211|		"PKCS15-PuKDF",
  228|    211|		"PKCS15-SKDF",
  229|    211|		"PKCS15-CDF",
  230|    211|		"PKCS15-CDF-TRUSTED",
  231|    211|		"PKCS15-DODF",
  232|    211|		NULL
  233|    211|	};
  234|       |
  235|    211|	static const int create_dfs_val[] = {
  236|    211|		SC_PKCS15_PRKDF,
  ------------------
  |  |  488|    211|#define SC_PKCS15_PRKDF			0
  ------------------
  237|    211|		SC_PKCS15_PUKDF,
  ------------------
  |  |  489|    211|#define SC_PKCS15_PUKDF			1
  ------------------
  238|    211|		SC_PKCS15_SKDF,
  ------------------
  |  |  491|    211|#define SC_PKCS15_SKDF			3
  ------------------
  239|    211|		SC_PKCS15_CDF,
  ------------------
  |  |  492|    211|#define SC_PKCS15_CDF			4
  ------------------
  240|    211|		SC_PKCS15_CDF_TRUSTED,
  ------------------
  |  |  493|    211|#define SC_PKCS15_CDF_TRUSTED		5
  ------------------
  241|    211|		SC_PKCS15_DODF
  ------------------
  |  |  495|    211|#define SC_PKCS15_DODF			7
  ------------------
  242|    211|	};
  243|       |
  244|    211|	if (!profile || !p15card || !p15card->card || !df)
  ------------------
  |  Branch (244:6): [True: 0, False: 211]
  |  Branch (244:18): [True: 0, False: 211]
  |  Branch (244:30): [True: 0, False: 211]
  |  Branch (244:48): [True: 0, False: 211]
  ------------------
  245|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  246|       |
  247|    211|	ctx = p15card->card->ctx;
  248|    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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  249|    211|	sc_log(ctx, "id (%x)", df->id);
  ------------------
  |  |   71|    211|#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|       |
  251|    211|	if (df->id == 0x5015) {
  ------------------
  |  Branch (251:6): [True: 204, False: 7]
  ------------------
  252|    204|		sc_log(ctx, "Select (%x)", df->id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  253|    204|		r = sc_select_file(p15card->card, &df->path, NULL);
  254|       |
  255|    941|		for (ii = 0; create_dfs[ii]; ii++) {
  ------------------
  |  Branch (255:16): [True: 836, False: 105]
  ------------------
  256|    836|			sc_log(ctx, "Create '%s'", create_dfs[ii]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  257|       |
  258|    836|			file = NULL;
  259|    836|			r = sc_profile_get_file(profile, create_dfs[ii], &file);
  260|    836|			sc_file_free(file);
  261|    836|			if (r) {
  ------------------
  |  Branch (261:8): [True: 6, False: 830]
  ------------------
  262|      6|				sc_log(ctx, "Inconsistent profile: cannot find %s", create_dfs[ii]);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  263|      6|				LOG_FUNC_RETURN(ctx, SC_ERROR_INCONSISTENT_PROFILE);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  264|      6|			}
  265|       |
  266|    830|			r = sc_pkcs15init_add_object(p15card, profile, create_dfs_val[ii], NULL);
  267|       |
  268|    830|			if (r != SC_ERROR_FILE_ALREADY_EXISTS)
  ------------------
  |  |   65|    830|#define SC_ERROR_FILE_ALREADY_EXISTS		-1215
  ------------------
  |  Branch (268:8): [True: 825, False: 5]
  ------------------
  269|    830|				LOG_TEST_RET(ctx, r, "Failed to create MyEID xDF file");
  ------------------
  |  |  174|    825|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    825|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    825|	int _ret = (r); \
  |  |  |  |  168|    825|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 93, False: 732]
  |  |  |  |  ------------------
  |  |  |  |  169|     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
  |  |  |  |  ------------------
  |  |  |  |  170|     93|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|     93|		return _ret; \
  |  |  |  |  172|     93|	} \
  |  |  |  |  173|    825|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 732]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  270|    830|		}
  271|    204|	}
  272|       |
  273|    112|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 112]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  274|    112|}
pkcs15-myeid.c:myeid_select_pin_reference:
  281|    984|		sc_pkcs15_auth_info_t *auth_info) {
  282|    984|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    984|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    984|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    984|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 984]
  |  |  ------------------
  ------------------
  283|       |
  284|    984|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    984|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (284:6): [True: 0, False: 984]
  ------------------
  285|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  286|       |
  287|    984|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) {
  ------------------
  |  |   61|    984|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (287:6): [True: 174, False: 810]
  ------------------
  288|    174|		sc_log(p15card->card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  289|    174|				"PIN_FLAG_SO_PIN, ref (%d), tries_left (%d)",
  290|    174|				auth_info->attrs.pin.reference, auth_info->tries_left);
  291|    810|	} else {
  292|    810|		sc_log(p15card->card->ctx,
  ------------------
  |  |   71|    810|#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|    810|				"PIN_FLAG_PIN, ref (%d), tries_left (%d)",
  294|    810|				auth_info->attrs.pin.reference, auth_info->tries_left);
  295|       |
  296|    810|	}
  297|       |
  298|    984|	if (auth_info->attrs.pin.reference <= 0 || auth_info->attrs.pin.reference > MYEID_MAX_PINS)
  ------------------
  |  |   39|    193|#define MYEID_MAX_PINS   14
  ------------------
  |  Branch (298:6): [True: 791, False: 193]
  |  Branch (298:45): [True: 15, False: 178]
  ------------------
  299|    806|		auth_info->attrs.pin.reference = 1;
  300|       |
  301|    984|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    984|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    984|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    984|	int _ret = r; \
  |  |  |  |  155|    984|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 984, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    984|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 984]
  |  |  |  |  ------------------
  |  |  |  |  157|    984|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    984|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    984|	return _ret; \
  |  |  |  |  163|    984|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  302|    984|}
pkcs15-myeid.c:myeid_create_pin:
  311|    644|		const unsigned char *puk, size_t puk_len) {
  312|    644|	struct sc_context *ctx = p15card->card->ctx;
  313|    644|	unsigned char data[20];
  314|    644|	struct sc_cardctl_myeid_data_obj data_obj;
  315|    644|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
  316|    644|	struct sc_pkcs15_auth_info puk_ainfo = {0};
  317|    644|	int r;
  318|       |
  319|    644|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    644|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    644|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    644|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    644|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 644]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  320|    644|	sc_log(ctx,
  ------------------
  |  |   71|    644|#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|    644|	       "PIN('%s',ref:%i,flags:0x%X,pin_len:%"SC_FORMAT_LEN_SIZE_T"u,puk_len:%"SC_FORMAT_LEN_SIZE_T"u)\n",
  322|    644|	       pin_obj->label, auth_info->attrs.pin.reference,
  323|    644|	       auth_info->attrs.pin.flags, pin_len, puk_len);
  324|       |
  325|    644|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    644|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (325:6): [True: 0, False: 644]
  ------------------
  326|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  327|    644|	if (auth_info->attrs.pin.reference >= MYEID_MAX_PINS)
  ------------------
  |  |   39|    644|#define MYEID_MAX_PINS   14
  ------------------
  |  Branch (327:6): [True: 0, False: 644]
  ------------------
  328|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  329|    644|	if (pin == NULL || puk == NULL || pin_len < 4 || puk_len < 4)
  ------------------
  |  Branch (329:6): [True: 0, False: 644]
  |  Branch (329:21): [True: 0, False: 644]
  |  Branch (329:36): [True: 0, False: 644]
  |  Branch (329:51): [True: 0, False: 644]
  ------------------
  330|      0|		return SC_ERROR_INVALID_PIN_LENGTH;
  ------------------
  |  |   77|      0|#define SC_ERROR_INVALID_PIN_LENGTH		-1304
  ------------------
  331|       |
  332|    644|	sc_profile_get_pin_info(profile, (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|    644|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (332:35): [True: 52, False: 592]
  ------------------
  333|    644|			? SC_PKCS15INIT_SO_PUK : SC_PKCS15INIT_USER_PUK,
  ------------------
  |  |  170|     52|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
              			? SC_PKCS15INIT_SO_PUK : SC_PKCS15INIT_USER_PUK,
  ------------------
  |  |  172|    592|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  334|    644|			&puk_ainfo);
  335|       |
  336|    644|	memset(data, 0, sizeof (data));
  337|       |	/* Make command to add a pin-record */
  338|    644|	data_obj.P1 = 0x01;
  339|    644|	data_obj.P2 = auth_info->attrs.pin.reference; /* myeid pin number */
  340|       |
  341|    644|	memset(data, auth_info->attrs.pin.pad_char, 8);
  342|    644|	memcpy(&data[0], (u8 *) pin, pin_len); /* copy pin */
  343|       |
  344|    644|	memset(&data[8], puk_ainfo.attrs.pin.pad_char, 8);
  345|    644|	memcpy(&data[8], (u8 *) puk, puk_len); /* copy puk */
  346|       |
  347|    644|	if (auth_info->tries_left > 0 && auth_info->tries_left < 15)
  ------------------
  |  Branch (347:6): [True: 629, False: 15]
  |  Branch (347:35): [True: 629, False: 0]
  ------------------
  348|    629|		data[16] = auth_info->tries_left;
  349|     15|	else
  350|     15|		data[16] = 5; /* default value */
  351|       |
  352|    644|	if (puk_ainfo.tries_left > 0 && puk_ainfo.tries_left < 15)
  ------------------
  |  Branch (352:6): [True: 642, False: 2]
  |  Branch (352:34): [True: 641, False: 1]
  ------------------
  353|    641|		data[17] = puk_ainfo.tries_left;
  354|      3|	else
  355|      3|		data[17] = 5; /* default value */
  356|       |
  357|    644|	data[18] = 0x00;
  358|       |
  359|    644|	data_obj.Data = data;
  360|    644|	data_obj.DataLen = 19;
  361|       |
  362|    644|	r = sc_card_ctl(p15card->card, SC_CARDCTL_MYEID_PUTDATA, &data_obj);
  363|    644|	LOG_TEST_RET(ctx, r, "Initialize PIN failed");
  ------------------
  |  |  174|    644|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    644|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    644|	int _ret = (r); \
  |  |  |  |  168|    644|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 368, False: 276]
  |  |  |  |  ------------------
  |  |  |  |  169|    368|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    368|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    368|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    368|		return _ret; \
  |  |  |  |  172|    368|	} \
  |  |  |  |  173|    644|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 276]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  364|       |
  365|    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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 276]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  366|    276|}
pkcs15-myeid.c:myeid_create_key:
  532|  2.81k|		struct sc_pkcs15_object *object) {
  533|  2.81k|	struct sc_context *ctx = p15card->card->ctx;
  534|  2.81k|	struct sc_card *card = p15card->card;
  535|  2.81k|	struct sc_pkcs15_prkey_info *prkey_info = (struct sc_pkcs15_prkey_info *) object->data;
  536|  2.81k|	struct sc_pkcs15_skey_info *skey_info = (struct sc_pkcs15_skey_info *) object->data;
  537|  2.81k|	struct sc_pkcs15_id *id;
  538|  2.81k|	struct sc_path *path;
  539|  2.81k|	int *key_reference;
  540|  2.81k|	struct sc_file *file = NULL;
  541|  2.81k|	struct sc_pkcs15_object *pin_object = NULL;
  542|  2.81k|	struct sc_pkcs15_auth_info *pkcs15_auth_info = NULL;
  543|  2.81k|	unsigned char sec_attrs[] = {0xFF, 0xFF, 0xFF};
  544|  2.81k|	int r, ef_structure = 0, pin_reference = -1;
  545|  2.81k|	size_t keybits = 0;
  546|  2.81k|	unsigned char prop_info[] = {0x00, 0x00};
  547|  2.81k|	int extractable = FALSE;
  ------------------
  |  |   48|  2.81k|#define FALSE 0
  ------------------
  548|       |
  549|  2.81k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.81k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.81k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.81k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.81k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  550|       |
  551|  2.81k|	switch (object->type) {
  ------------------
  |  Branch (551:10): [True: 2.81k, False: 0]
  ------------------
  552|    402|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    402|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (552:3): [True: 402, False: 2.41k]
  ------------------
  553|    402|			ef_structure = SC_CARDCTL_MYEID_KEY_RSA;
  554|    402|			keybits = prkey_info->modulus_length;
  555|    402|			break;
  556|    388|		case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|    388|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (556:3): [True: 388, False: 2.43k]
  ------------------
  557|    388|			ef_structure = SC_CARDCTL_MYEID_KEY_EC;
  558|    388|			keybits = prkey_info->field_length;
  559|    388|			break;
  560|    677|		case SC_PKCS15_TYPE_SKEY_DES:
  ------------------
  |  |  434|    677|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
  |  Branch (560:3): [True: 677, False: 2.14k]
  ------------------
  561|  1.35k|		case SC_PKCS15_TYPE_SKEY_3DES:
  ------------------
  |  |  436|  1.35k|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
  |  Branch (561:3): [True: 675, False: 2.14k]
  ------------------
  562|  1.35k|			ef_structure = SC_CARDCTL_MYEID_KEY_DES;
  563|  1.35k|			keybits = skey_info->value_len;
  564|  1.35k|			if ((skey_info->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) == SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE)
  ------------------
  |  |  317|  1.35k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
              			if ((skey_info->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) == SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE)
  ------------------
  |  |  317|  1.35k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  |  Branch (564:8): [True: 1.35k, False: 0]
  ------------------
  565|  1.35k|				extractable = TRUE;
  ------------------
  |  |   51|  1.35k|#define TRUE 1
  ------------------
  566|  1.35k|			break;
  567|    677|		case SC_PKCS15_TYPE_SKEY_GENERIC:
  ------------------
  |  |  433|    677|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  |  Branch (567:3): [True: 677, False: 2.14k]
  ------------------
  568|    677|			keybits = skey_info->value_len;
  569|    677|			if ((skey_info->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) == SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE)
  ------------------
  |  |  317|    677|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
              			if ((skey_info->access_flags & SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE) == SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE)
  ------------------
  |  |  317|    677|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
  |  Branch (569:8): [True: 677, False: 0]
  ------------------
  570|    677|				extractable = TRUE;
  ------------------
  |  |   51|    677|#define TRUE 1
  ------------------
  571|    677|			switch (skey_info->key_type) {
  572|    677|			case CKK_AES:
  ------------------
  |  |  485|    677|#define CKK_AES 0x0000001FUL
  ------------------
  |  Branch (572:4): [True: 677, False: 0]
  ------------------
  573|    677|				ef_structure = SC_CARDCTL_MYEID_KEY_AES;
  574|    677|				break;
  575|      0|			case CKK_DES:
  ------------------
  |  |  473|      0|#define CKK_DES 0x00000013UL
  ------------------
  |  Branch (575:4): [True: 0, False: 677]
  ------------------
  576|      0|				ef_structure = SC_CARDCTL_MYEID_KEY_DES;
  577|      0|				break;
  578|      0|			default:
  ------------------
  |  Branch (578:4): [True: 0, False: 677]
  ------------------
  579|      0|				if (object->type == SC_PKCS15_TYPE_SKEY_GENERIC)
  ------------------
  |  |  433|      0|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  |  Branch (579:9): [True: 0, False: 0]
  ------------------
  580|      0|					ef_structure = SC_CARDCTL_MYEID_KEY_GENERIC_SECRET;
  581|      0|				break;
  582|    677|			}
  583|    677|			break;
  584|  2.81k|	}
  585|  2.81k|	if (!ef_structure) {
  ------------------
  |  Branch (585:6): [True: 0, False: 2.81k]
  ------------------
  586|      0|		LOG_TEST_RET(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  587|      0|				"Unsupported key type");
  588|      0|	}
  589|       |
  590|  2.81k|	myeid_fixup_supported_algos(profile, p15card, object);
  591|       |
  592|  2.81k|	if ((object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY) {
  ------------------
  |  |  416|  2.81k|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              	if ((object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY) {
  ------------------
  |  |  418|  2.81k|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (592:6): [True: 790, False: 2.02k]
  ------------------
  593|    790|		id = &prkey_info->id;
  594|    790|		path = &prkey_info->path;
  595|    790|		key_reference = &prkey_info->key_reference;
  596|  2.02k|	} else {
  597|  2.02k|		id = &skey_info->id;
  598|  2.02k|		path = &skey_info->path;
  599|  2.02k|		key_reference = &skey_info->key_reference;
  600|  2.02k|	}
  601|       |
  602|  2.81k|	sc_log(ctx, "create MyEID key ID:%s", sc_pkcs15_print_id(id));
  ------------------
  |  |   71|  2.81k|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  603|       |
  604|       |	/* Get the private key file */
  605|  2.81k|	r = myeid_new_file(profile, card, object->type, *key_reference, &file);
  606|  2.81k|	LOG_TEST_RET(ctx, r, "Cannot get new MyEID key file");
  ------------------
  |  |  174|  2.81k|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|  2.81k|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|  2.81k|	int _ret = (r); \
  |  |  |  |  168|  2.81k|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 2.09k, False: 725]
  |  |  |  |  ------------------
  |  |  |  |  169|  2.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|  2.09k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|  2.09k|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|  2.09k|		return _ret; \
  |  |  |  |  172|  2.09k|	} \
  |  |  |  |  173|  2.81k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 725]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  607|       |
  608|    725|	if (!file || !file->path.len || file->path.len > SC_MAX_PATH_SIZE) {
  ------------------
  |  |   47|    725|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (608:6): [True: 0, False: 725]
  |  Branch (608:15): [True: 0, False: 725]
  |  Branch (608:34): [True: 0, False: 725]
  ------------------
  609|      0|		sc_file_free(file);
  610|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Cannot determine key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  611|      0|	}
  612|       |
  613|    725|	sc_log(ctx, "Key file size %zu", keybits);
  ------------------
  |  |   71|    725|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  614|    725|	file->size = keybits;
  615|    725|	file->ef_structure = ef_structure;
  616|       |
  617|    725|	memcpy(path->value, &file->path.value, file->path.len);
  618|    725|	*key_reference = file->path.value[file->path.len - 1] & 0xFF;
  619|       |
  620|    725|	sc_log(ctx, "Path of MyEID key file to create %s",
  ------------------
  |  |   71|    725|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  621|    725|			sc_print_path(&file->path));
  622|       |
  623|    725|	if (object->auth_id.len >= 1) {
  ------------------
  |  Branch (623:6): [True: 725, False: 0]
  ------------------
  624|    725|		r = sc_pkcs15_find_pin_by_auth_id(p15card, &object->auth_id, &pin_object);
  625|       |
  626|    725|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|    725|#define SC_SUCCESS				0
  ------------------
  |  Branch (626:7): [True: 115, False: 610]
  ------------------
  627|    115|			sc_file_free(file);
  628|    725|		LOG_TEST_RET(ctx, r, "Failed to get pin object by auth_id");
  ------------------
  |  |  174|    725|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    725|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    725|	int _ret = (r); \
  |  |  |  |  168|    725|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 115, False: 610]
  |  |  |  |  ------------------
  |  |  |  |  169|    115|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    115|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    115|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    115|		return _ret; \
  |  |  |  |  172|    115|	} \
  |  |  |  |  173|    725|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 610]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  629|       |
  630|    610|		if (pin_object->type != SC_PKCS15_TYPE_AUTH_PIN) {
  ------------------
  |  |  445|    610|#define SC_PKCS15_TYPE_AUTH_PIN			0x601
  ------------------
  |  Branch (630:7): [True: 0, False: 610]
  ------------------
  631|      0|			sc_file_free(file);
  632|      0|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_VALID, "Invalid object returned when locating pin 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  633|      0|		}
  634|       |
  635|    610|		pkcs15_auth_info =  (struct sc_pkcs15_auth_info*) pin_object->data;
  636|       |
  637|    610|		if (pkcs15_auth_info == NULL || pkcs15_auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN) {
  ------------------
  |  |   94|    610|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (637:7): [True: 0, False: 610]
  |  Branch (637:35): [True: 0, False: 610]
  ------------------
  638|      0|			sc_file_free(file);
  639|      0|			LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_VALID, "NULL or invalid sc_pkcs15_auth_info in pin 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  640|      0|		}
  641|       |
  642|    610|		pin_reference = pkcs15_auth_info->attrs.pin.reference;
  643|       |
  644|    610|		if (pin_reference >= 1 && pin_reference < MYEID_MAX_PINS) {
  ------------------
  |  |   39|    225|#define MYEID_MAX_PINS   14
  ------------------
  |  Branch (644:7): [True: 225, False: 385]
  |  Branch (644:29): [True: 180, False: 45]
  ------------------
  645|    180|			sec_attrs[0] = (pin_reference << 4 | (pin_reference & 0x0F));
  646|    180|			sec_attrs[1] = (pin_reference << 4 | (pin_reference & 0x0F));
  647|    180|			sc_file_set_sec_attr(file, sec_attrs, sizeof(sec_attrs));
  648|    180|		}
  649|    610|	}
  650|      0|	else {
  651|      0|		sc_file_free(file);
  652|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid AuthID value for a private 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|      0|	}
  654|       |
  655|       |	/* TODO: fill all proprietary attributes here based on the object */
  656|       |
  657|    610|	if (object->user_consent != 0 && pin_reference >= 1)
  ------------------
  |  Branch (657:6): [True: 0, False: 610]
  |  Branch (657:35): [True: 0, False: 0]
  ------------------
  658|      0|	    prop_info[0] |= (pin_reference << 4);
  659|       |
  660|    610|	if (extractable)
  ------------------
  |  Branch (660:6): [True: 433, False: 177]
  ------------------
  661|    433|	    prop_info[1] |= MYEID_PROP_INFO_2_EXCTRACTABLE;
  ------------------
  |  |   45|    433|#define MYEID_PROP_INFO_2_EXCTRACTABLE			0x08;
  ------------------
  662|       |
  663|    610|	if (object->session_object != 0) /* Object will be removed during next reset. */
  ------------------
  |  Branch (663:6): [True: 0, False: 610]
  ------------------
  664|      0|		prop_info[1] |= MYEID_PROP_INFO_2_SESSION_OBJECT;
  ------------------
  |  |   48|      0|#define MYEID_PROP_INFO_2_SESSION_OBJECT		0x01;
  ------------------
  665|       |
  666|       |	/* TODO: add other flags, like CKA_TRUSTED and CKA_WRAP_WITH_TRUSTED */
  667|       |
  668|    610|	r = sc_file_set_prop_attr(file, prop_info, 2);
  669|    610|	LOG_TEST_RET(ctx, r, "Cannot create MyEID key file");
  ------------------
  |  |  174|    610|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    610|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    610|	int _ret = (r); \
  |  |  |  |  168|    610|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 610]
  |  |  |  |  ------------------
  |  |  |  |  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|    610|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 610]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  670|       |
  671|       |	/* Now create the key file */
  672|    610|	r = sc_pkcs15init_create_file(profile, p15card, file);
  673|    610|	sc_file_free(file);
  674|    610|	LOG_TEST_RET(ctx, r, "Cannot create MyEID key file");
  ------------------
  |  |  174|    610|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    610|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    610|	int _ret = (r); \
  |  |  |  |  168|    610|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 409, False: 201]
  |  |  |  |  ------------------
  |  |  |  |  169|    409|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    409|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    409|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    409|		return _ret; \
  |  |  |  |  172|    409|	} \
  |  |  |  |  173|    610|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 201]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  675|       |
  676|    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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 201]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  677|    201|}
pkcs15-myeid.c:myeid_fixup_supported_algos:
  505|  2.81k|{
  506|  2.81k|	struct sc_context *ctx = p15card->card->ctx;
  507|  2.81k|	struct sc_pkcs15_skey_info *skey_info = (struct sc_pkcs15_skey_info *) object->data;
  508|       |
  509|  2.81k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  2.81k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.81k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.81k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.81k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  510|  2.81k|	switch (object->type) {
  ------------------
  |  Branch (510:10): [True: 677, False: 2.14k]
  ------------------
  511|    677|	case SC_PKCS15_TYPE_SKEY_GENERIC:
  ------------------
  |  |  433|    677|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  |  Branch (511:2): [True: 677, False: 2.14k]
  ------------------
  512|    677|		switch (skey_info->key_type | (skey_info->value_len << 16)) {
  ------------------
  |  Branch (512:11): [True: 677, False: 0]
  ------------------
  513|    677|		case CKK_AES | (128 << 16):
  ------------------
  |  |  485|    677|#define CKK_AES 0x0000001FUL
  ------------------
  |  Branch (513:3): [True: 677, False: 0]
  ------------------
  514|    677|			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes128_ecb);
  ------------------
  |  |  142|    677|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
              			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes128_ecb);
  ------------------
  |  |  141|    677|#define SC_PKCS15_ALGO_OP_ENCIPHER		0x10
  ------------------
              			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes128_ecb);
  ------------------
  |  |  882|    677|#define CKM_AES_ECB 0x00001081UL
  ------------------
  515|    677|			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes128_cbc);
  ------------------
  |  |  142|    677|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
              			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes128_cbc);
  ------------------
  |  |  141|    677|#define SC_PKCS15_ALGO_OP_ENCIPHER		0x10
  ------------------
              			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes128_cbc);
  ------------------
  |  |  883|    677|#define CKM_AES_CBC 0x00001082UL
  ------------------
  516|    677|			break;
  517|      0|		case CKK_AES | (256 << 16):
  ------------------
  |  |  485|      0|#define CKK_AES 0x0000001FUL
  ------------------
  |  Branch (517:3): [True: 0, False: 677]
  ------------------
  518|      0|			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes256_ecb);
  ------------------
  |  |  142|      0|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
              			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes256_ecb);
  ------------------
  |  |  141|      0|#define SC_PKCS15_ALGO_OP_ENCIPHER		0x10
  ------------------
              			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_ECB, &id_aes256_ecb);
  ------------------
  |  |  882|      0|#define CKM_AES_ECB 0x00001081UL
  ------------------
  519|      0|			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes256_cbc);
  ------------------
  |  |  142|      0|#define SC_PKCS15_ALGO_OP_DECIPHER		0x20
  ------------------
              			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes256_cbc);
  ------------------
  |  |  141|      0|#define SC_PKCS15_ALGO_OP_ENCIPHER		0x10
  ------------------
              			_add_supported_algo(profile, p15card, object, SC_PKCS15_ALGO_OP_DECIPHER|SC_PKCS15_ALGO_OP_ENCIPHER, CKM_AES_CBC, &id_aes256_cbc);
  ------------------
  |  |  883|      0|#define CKM_AES_CBC 0x00001082UL
  ------------------
  520|      0|			break;
  521|    677|		}
  522|    677|		break;
  523|  2.81k|	}
  524|  2.81k|}
pkcs15-myeid.c:myeid_new_file:
  375|  2.81k|		sc_file_t **out) {
  376|  2.81k|	sc_file_t *file;
  377|  2.81k|	sc_path_t *p;
  378|  2.81k|	char name[64];
  379|  2.81k|	const char *tag = NULL;
  380|  2.81k|	int r;
  381|       |
  382|  2.81k|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|  2.81k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  2.81k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  2.81k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  2.81k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 2.81k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  383|  2.81k|	switch (type) {
  384|    402|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    402|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (384:2): [True: 402, False: 2.41k]
  ------------------
  385|    790|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|    790|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (385:2): [True: 388, False: 2.43k]
  ------------------
  386|    790|		tag = "private-key";
  387|    790|		break;
  388|      0|	case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (388:2): [True: 0, False: 2.81k]
  ------------------
  389|      0|	case SC_PKCS15_TYPE_PUBKEY_EC:
  ------------------
  |  |  428|      0|#define SC_PKCS15_TYPE_PUBKEY_EC		0x204
  ------------------
  |  Branch (389:2): [True: 0, False: 2.81k]
  ------------------
  390|      0|		tag = "public-key";
  391|      0|		break;
  392|    677|	case SC_PKCS15_TYPE_SKEY_GENERIC:
  ------------------
  |  |  433|    677|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  |  Branch (392:2): [True: 677, False: 2.14k]
  ------------------
  393|  1.35k|	case SC_PKCS15_TYPE_SKEY_DES:
  ------------------
  |  |  434|  1.35k|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
  |  Branch (393:2): [True: 677, False: 2.14k]
  ------------------
  394|  2.02k|	case SC_PKCS15_TYPE_SKEY_3DES:
  ------------------
  |  |  436|  2.02k|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
  |  Branch (394:2): [True: 675, False: 2.14k]
  ------------------
  395|  2.02k|		tag = "secret-key";
  396|  2.02k|		break;
  397|      0|	default:
  ------------------
  |  Branch (397:2): [True: 0, False: 2.81k]
  ------------------
  398|      0|		if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_CERT)
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              		if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_CERT)
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (398:7): [True: 0, False: 0]
  ------------------
  399|      0|			tag = "certificate";
  400|      0|		else if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_DATA_OBJECT)
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              		else if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_DATA_OBJECT)
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (400:12): [True: 0, False: 0]
  ------------------
  401|      0|			tag = "data";
  402|      0|		break;
  403|  2.81k|	}
  404|       |
  405|  2.81k|	if (!tag) {
  ------------------
  |  Branch (405:6): [True: 0, False: 2.81k]
  ------------------
  406|      0|		sc_log(card->ctx, "Unsupported file 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__
  |  |  ------------------
  ------------------
  407|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  408|      0|	}
  409|       |
  410|       |	/* Get template from profile  */
  411|  2.81k|	snprintf(name, sizeof (name), "template-%s", tag);
  412|  2.81k|	if (sc_profile_get_file(profile, name, &file) < 0) {
  ------------------
  |  Branch (412:6): [True: 2.09k, False: 725]
  ------------------
  413|  2.09k|		sc_log(card->ctx, "Profile doesn't define %s", name);
  ------------------
  |  |   71|  2.09k|#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|  2.09k|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|  2.09k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  415|  2.09k|	}
  416|       |
  417|       |	/* Auto-increment FID for next object */
  418|    725|	file->id += num;
  419|    725|	p = &file->path;
  420|    725|	*p = profile->df_info->file->path;
  421|    725|	if (p->len >= SC_MAX_PATH_SIZE - 2) {
  ------------------
  |  |   47|    725|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (421:6): [True: 0, False: 725]
  ------------------
  422|      0|		sc_log(card->ctx, "Wrong path 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__
  |  |  ------------------
  ------------------
  423|      0|		sc_file_free(file);
  424|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  425|      0|	}
  426|    725|	p->value[p->len++] = (u8) (file->id / 256);
  427|    725|	p->value[p->len++] = (u8) (file->id % 256);
  428|       |
  429|       |	/* Increment FID until there's no file with such path */
  430|    725|	r = sc_select_file(card, p, NULL);
  431|  2.08k|	while (r == 0) {
  ------------------
  |  Branch (431:9): [True: 1.36k, False: 725]
  ------------------
  432|  1.36k|		file->id++;
  433|  1.36k|		p->value[p->len - 2] = (u8) (file->id / 256);
  434|  1.36k|		p->value[p->len - 1] = (u8) (file->id % 256);
  435|  1.36k|		r = sc_select_file(card, p, NULL);
  436|  1.36k|	}
  437|       |
  438|    725|	*out = file;
  439|    725|	LOG_FUNC_RETURN(card->ctx, 0);
  ------------------
  |  |  164|    725|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    725|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    725|	int _ret = r; \
  |  |  |  |  155|    725|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 725, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    725|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 725]
  |  |  |  |  ------------------
  |  |  |  |  157|    725|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    725|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    725|	return _ret; \
  |  |  |  |  163|    725|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  440|    725|}
pkcs15-myeid.c:myeid_store_key:
  685|    105|		struct sc_pkcs15_prkey *prkey) {
  686|    105|	struct sc_context *ctx = p15card->card->ctx;
  687|    105|	struct sc_card *card = p15card->card;
  688|    105|	struct sc_cardctl_myeid_gen_store_key_info args;
  689|    105|	struct sc_file *file = NULL;
  690|    105|	struct sc_pkcs15_id *id;
  691|    105|	struct sc_path *path;
  692|    105|	int r;
  693|       |
  694|    105|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  695|       |
  696|    105|	if ((object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY) {
  ------------------
  |  |  416|    105|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              	if ((object->type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_PRKEY) {
  ------------------
  |  |  418|    105|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (696:6): [True: 0, False: 105]
  ------------------
  697|      0|		struct sc_pkcs15_prkey_info *prkey_info = (struct sc_pkcs15_prkey_info *) object->data;
  698|      0|		id = &prkey_info->id;
  699|      0|		path = &prkey_info->path;
  700|    105|	} else {
  701|    105|		struct sc_pkcs15_skey_info *skey_info = (struct sc_pkcs15_skey_info *) object->data;
  702|    105|		id = &skey_info->id;
  703|    105|		path = &skey_info->path;
  704|    105|	}
  705|       |
  706|    105|	sc_log(ctx, "store MyEID key with ID:%s and path:%s",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  707|    105|			sc_pkcs15_print_id(id), sc_print_path(path));
  708|       |
  709|    105|	r = sc_select_file(card, path, &file);
  710|    105|	LOG_TEST_RET(ctx, r, "Cannot store MyEID key: select key file failed");
  ------------------
  |  |  174|    105|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    105|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    105|	int _ret = (r); \
  |  |  |  |  168|    105|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 36, False: 69]
  |  |  |  |  ------------------
  |  |  |  |  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|    105|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 69]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  711|       |
  712|     69|	r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     69|#define SC_AC_OP_UPDATE			23
  ------------------
  713|     69|	sc_file_free(file);
  714|     69|	LOG_TEST_RET(ctx, r, "No authorisation to store MyEID private key");
  ------------------
  |  |  174|     69|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     69|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     69|	int _ret = (r); \
  |  |  |  |  168|     69|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 6, False: 63]
  |  |  |  |  ------------------
  |  |  |  |  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|     69|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 63]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  715|       |
  716|       |	/* Fill in data structure */
  717|     63|	memset(&args, 0, sizeof (args));
  718|       |
  719|     63|	args.op_type = OP_TYPE_STORE;
  ------------------
  |  |  530|     63|#define OP_TYPE_STORE		1
  ------------------
  720|       |
  721|     63|	switch (object->type) {
  ------------------
  |  Branch (721:10): [True: 63, False: 0]
  ------------------
  722|      0|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (722:2): [True: 0, False: 63]
  ------------------
  723|      0|		args.key_type = SC_CARDCTL_MYEID_KEY_RSA;
  724|      0|		args.pubexp_len = prkey->u.rsa.exponent.len;
  725|      0|		args.pubexp = prkey->u.rsa.exponent.data;
  726|      0|		args.primep_len = prkey->u.rsa.p.len;
  727|      0|		args.primep = prkey->u.rsa.p.data;
  728|      0|		args.primeq_len = prkey->u.rsa.q.len;
  729|      0|		args.primeq = prkey->u.rsa.q.data;
  730|       |
  731|      0|		args.dp1_len = prkey->u.rsa.dmp1.len;
  732|      0|		args.dp1 = prkey->u.rsa.dmp1.data;
  733|      0|		args.dq1_len = prkey->u.rsa.dmq1.len;
  734|      0|		args.dq1 = prkey->u.rsa.dmq1.data;
  735|      0|		args.invq_len = prkey->u.rsa.iqmp.len;
  736|      0|		args.invq = prkey->u.rsa.iqmp.data;
  737|       |
  738|       |		//args.key_len_bits = keybits;
  739|      0|		args.key_len_bits = prkey->u.rsa.modulus.len;
  740|      0|		args.mod = prkey->u.rsa.modulus.data;
  741|      0|		break;
  742|      0|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|      0|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (742:2): [True: 0, False: 63]
  ------------------
  743|      0|		args.key_type = SC_CARDCTL_MYEID_KEY_EC;
  744|      0|		args.d = prkey->u.ec.privateD.data;
  745|      0|		args.d_len = prkey->u.ec.privateD.len;
  746|      0|		args.ecpublic_point = prkey->u.ec.ecpointQ.value;
  747|      0|		args.ecpublic_point_len = prkey->u.ec.ecpointQ.len;
  748|      0|		args.key_len_bits = prkey->u.ec.params.field_length;
  749|      0|		break;
  750|     27|	case SC_PKCS15_TYPE_SKEY_GENERIC:
  ------------------
  |  |  433|     27|#define SC_PKCS15_TYPE_SKEY_GENERIC		0x301
  ------------------
  |  Branch (750:2): [True: 27, False: 36]
  ------------------
  751|     49|	case SC_PKCS15_TYPE_SKEY_DES:
  ------------------
  |  |  434|     49|#define SC_PKCS15_TYPE_SKEY_DES			0x302
  ------------------
  |  Branch (751:2): [True: 22, False: 41]
  ------------------
  752|     49|	case SC_PKCS15_TYPE_SKEY_2DES:
  ------------------
  |  |  435|     49|#define SC_PKCS15_TYPE_SKEY_2DES		0x303
  ------------------
  |  Branch (752:2): [True: 0, False: 63]
  ------------------
  753|     63|	case SC_PKCS15_TYPE_SKEY_3DES:
  ------------------
  |  |  436|     63|#define SC_PKCS15_TYPE_SKEY_3DES		0x304
  ------------------
  |  Branch (753:2): [True: 14, False: 49]
  ------------------
  754|     63|		switch (prkey->algorithm) {
  ------------------
  |  Branch (754:11): [True: 49, False: 14]
  ------------------
  755|     27|		case SC_ALGORITHM_AES:
  ------------------
  |  |   88|     27|#define SC_ALGORITHM_AES		67
  ------------------
  |  Branch (755:3): [True: 27, False: 36]
  ------------------
  756|     27|			args.key_type = SC_CARDCTL_MYEID_KEY_AES;
  757|     27|			break;
  758|     22|		case SC_ALGORITHM_DES:
  ------------------
  |  |   85|     22|#define SC_ALGORITHM_DES		64
  ------------------
  |  Branch (758:3): [True: 22, False: 41]
  ------------------
  759|     22|			args.key_type = SC_CARDCTL_MYEID_KEY_DES;
  760|     22|			break;
  761|     63|		}
  762|     63|		args.d = prkey->u.secret.data;
  763|     63|		args.d_len = prkey->u.secret.data_len;
  764|     63|		break;
  765|     63|	}
  766|       |	/* Store RSA key  */
  767|     63|	r = sc_card_ctl(card, SC_CARDCTL_MYEID_GENERATE_STORE_KEY, &args);
  768|     63|	LOG_TEST_RET(ctx, r, "Card control 'MYEID_GENERATE_STORE_KEY' failed");
  ------------------
  |  |  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: 5, False: 58]
  |  |  |  |  ------------------
  |  |  |  |  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|     63|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 58]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  769|       |
  770|     58|	LOG_FUNC_RETURN(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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 58]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  771|     58|}
pkcs15-myeid.c:myeid_generate_key:
  776|     96|		struct sc_pkcs15_pubkey *pubkey) {
  777|     96|	struct sc_context *ctx = p15card->card->ctx;
  778|     96|	struct sc_card *card = p15card->card;
  779|     96|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *) object->data;
  780|     96|	struct sc_cardctl_myeid_gen_store_key_info args;
  781|     96|	struct sc_file *file = NULL;
  782|     96|	int r;
  783|     96|	unsigned int cla,tag;
  784|     96|	size_t taglen;
  785|     96|	unsigned int keybits = (unsigned int)key_info->modulus_length;
  786|     96|	u8 raw_pubkey[MYEID_MAX_RSA_KEY_LEN / 8];
  787|     96|	u8* dataptr;
  788|       |
  789|     96|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  790|     96|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA && object->type != SC_PKCS15_TYPE_PRKEY_EC)
  ------------------
  |  |  419|    192|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
              	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA && object->type != SC_PKCS15_TYPE_PRKEY_EC)
  ------------------
  |  |  421|     42|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (790:6): [True: 42, False: 54]
  |  Branch (790:50): [True: 0, False: 42]
  ------------------
  791|     96|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Generate key failed: only RSA and EC 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  792|       |
  793|       |	/* Check that the card supports the requested modulus length */
  794|     96|	switch (object->type) {
  795|     54|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|     54|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (795:3): [True: 54, False: 42]
  ------------------
  796|     54|			if (sc_card_find_rsa_alg(p15card->card, keybits) == NULL)
  ------------------
  |  Branch (796:8): [True: 0, False: 54]
  ------------------
  797|     54|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Unsupported RSA key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  798|     54|			break;
  799|     54|		case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     42|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (799:3): [True: 42, False: 54]
  ------------------
  800|       |			/* EC is supported in MyEID v > 3.5. TODO: set correct return value if older MyEID version. */
  801|       |			/* Here the information about curve is not available, that's why supported algorithm is checked
  802|       |			   without curve OID. */
  803|       |
  804|     42|			if(key_info->field_length != 0)
  ------------------
  |  Branch (804:7): [True: 42, False: 0]
  ------------------
  805|     42|				keybits = (unsigned int)key_info->field_length;
  806|      0|			else
  807|      0|				key_info->field_length = keybits;
  808|       |
  809|     42|			if (sc_card_find_ec_alg(p15card->card, keybits, NULL) == NULL)
  ------------------
  |  Branch (809:8): [True: 0, False: 42]
  ------------------
  810|     42|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Unsupported EC key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  811|       |
  812|     42|			break;
  813|     42|		default:
  ------------------
  |  Branch (813:3): [True: 0, False: 96]
  ------------------
  814|      0|			LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Unsupported 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  815|     96|	}
  816|       |
  817|     96|	sc_log(ctx, "Generate key with ID:%s and path:%s",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  818|     96|			sc_pkcs15_print_id(&key_info->id), sc_print_path(&key_info->path));
  819|       |
  820|     96|	r = sc_select_file(card, &key_info->path, &file);
  821|     96|	LOG_TEST_RET(ctx, r, "Cannot generate key: failed to select key file");
  ------------------
  |  |  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: 19, False: 77]
  |  |  |  |  ------------------
  |  |  |  |  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|     96|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 77]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  822|       |
  823|     77|	r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_GENERATE);
  ------------------
  |  |  192|     77|#define SC_AC_OP_GENERATE		26
  ------------------
  824|     77|	if (r < 0)
  ------------------
  |  Branch (824:6): [True: 8, False: 69]
  ------------------
  825|      8|		sc_file_free(file);
  826|     77|	LOG_TEST_RET(ctx, r, "No authorisation to generate private key");
  ------------------
  |  |  174|     77|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     77|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     77|	int _ret = (r); \
  |  |  |  |  168|     77|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 8, False: 69]
  |  |  |  |  ------------------
  |  |  |  |  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|     77|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 69]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  827|       |
  828|       |	/* Fill in data structure */
  829|     69|	memset(&args, 0, sizeof (args));
  830|     69|	args.key_len_bits = keybits;
  831|     69|	args.op_type = OP_TYPE_GENERATE;
  ------------------
  |  |  529|     69|#define OP_TYPE_GENERATE	0
  ------------------
  832|     69|	if (object->type == SC_PKCS15_TYPE_PRKEY_RSA) {
  ------------------
  |  |  419|     69|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (832:6): [True: 39, False: 30]
  ------------------
  833|     39|		args.key_type = SC_CARDCTL_MYEID_KEY_RSA;
  834|     39|		args.pubexp_len = MYEID_DEFAULT_PUBKEY_LEN;
  ------------------
  |  |   43|     39|#define MYEID_DEFAULT_PUBKEY_LEN       sizeof(MYEID_DEFAULT_PUBKEY)
  ------------------
  835|     39|		args.pubexp = MYEID_DEFAULT_PUBKEY;
  836|     39|	} else if (object->type == SC_PKCS15_TYPE_PRKEY_EC) {
  ------------------
  |  |  421|     30|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (836:13): [True: 30, False: 0]
  ------------------
  837|     30|		args.key_type = SC_CARDCTL_MYEID_KEY_EC;
  838|     30|	}
  839|       |
  840|       |	/* Generate the key  */
  841|     69|	r = sc_card_ctl(card, SC_CARDCTL_MYEID_GENERATE_STORE_KEY, &args);
  842|     69|	if (r < 0)
  ------------------
  |  Branch (842:6): [True: 4, False: 65]
  ------------------
  843|      4|		sc_file_free(file);
  844|     69|	LOG_TEST_RET(ctx, r, "Card control 'MYEID_GENERATE_STORE_KEY' failed");
  ------------------
  |  |  174|     69|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     69|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     69|	int _ret = (r); \
  |  |  |  |  168|     69|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 4, False: 65]
  |  |  |  |  ------------------
  |  |  |  |  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|     69|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 65]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  845|       |
  846|       |	/* Key pair generation -> collect public key info */
  847|     65|	if (pubkey != NULL) {
  ------------------
  |  Branch (847:6): [True: 65, False: 0]
  ------------------
  848|     65|		struct sc_cardctl_myeid_data_obj data_obj;
  849|       |
  850|     65|		if (object->type == SC_PKCS15_TYPE_PRKEY_RSA) {
  ------------------
  |  |  419|     65|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (850:7): [True: 35, False: 30]
  ------------------
  851|     35|			pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|     35|#define SC_ALGORITHM_RSA		0
  ------------------
  852|     35|			pubkey->u.rsa.modulus.len = BYTES4BITS(keybits);
  ------------------
  |  |  146|     35|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  853|     35|			pubkey->u.rsa.modulus.data = malloc(pubkey->u.rsa.modulus.len);
  854|     35|			if (pubkey->u.rsa.modulus.data == NULL)
  ------------------
  |  Branch (854:8): [True: 0, False: 35]
  ------------------
  855|     35|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  856|     35|			pubkey->u.rsa.exponent.len = MYEID_DEFAULT_PUBKEY_LEN;
  ------------------
  |  |   43|     35|#define MYEID_DEFAULT_PUBKEY_LEN       sizeof(MYEID_DEFAULT_PUBKEY)
  ------------------
  857|     35|			pubkey->u.rsa.exponent.data = malloc(MYEID_DEFAULT_PUBKEY_LEN);
  ------------------
  |  |   43|     35|#define MYEID_DEFAULT_PUBKEY_LEN       sizeof(MYEID_DEFAULT_PUBKEY)
  ------------------
  858|     35|			if (pubkey->u.rsa.exponent.data == NULL)
  ------------------
  |  Branch (858:8): [True: 0, False: 35]
  ------------------
  859|     35|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  860|     35|			memcpy(pubkey->u.rsa.exponent.data, MYEID_DEFAULT_PUBKEY, MYEID_DEFAULT_PUBKEY_LEN);
  ------------------
  |  |   43|     35|#define MYEID_DEFAULT_PUBKEY_LEN       sizeof(MYEID_DEFAULT_PUBKEY)
  ------------------
  861|       |
  862|       |			/* Get public key modulus */
  863|     35|			r = sc_select_file(card, &file->path, NULL);
  864|     35|			sc_file_free(file);
  865|     35|			file = NULL;
  866|     35|			LOG_TEST_RET(ctx, r, "Cannot get key modulus: select key file 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: 3, False: 32]
  |  |  |  |  ------------------
  |  |  |  |  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|     35|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 32]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  867|       |
  868|     32|			data_obj.P1 = 0x01;
  869|     32|			data_obj.P2 = 0x01;
  870|     32|			data_obj.Data = raw_pubkey;
  871|     32|			data_obj.DataLen = sizeof (raw_pubkey);
  872|       |
  873|     32|			r = sc_card_ctl(card, SC_CARDCTL_MYEID_GETDATA, &data_obj);
  874|     32|			LOG_TEST_RET(ctx, r, "Cannot get RSA key modulus: 'MYEID_GETDATA' failed");
  ------------------
  |  |  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: 2, False: 30]
  |  |  |  |  ------------------
  |  |  |  |  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|     32|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 30]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  875|       |
  876|     30|			if ((data_obj.DataLen * 8) != key_info->modulus_length)
  ------------------
  |  Branch (876:8): [True: 12, False: 18]
  ------------------
  877|     30|				LOG_TEST_RET(ctx, SC_ERROR_PKCS15INIT, "Cannot get RSA key modulus: invalid key-size");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  878|       |
  879|     18|			memcpy(pubkey->u.rsa.modulus.data, raw_pubkey, pubkey->u.rsa.modulus.len);
  880|     18|		}
  881|     30|		else if (object->type == SC_PKCS15_TYPE_PRKEY_EC) {
  ------------------
  |  |  421|     30|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (881:12): [True: 30, False: 0]
  ------------------
  882|     30|			struct sc_ec_parameters *ecparams = (struct sc_ec_parameters *)key_info->params.data;
  883|       |
  884|     30|			sc_log(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__
  |  |  ------------------
  ------------------
  885|     30|			       "curve '%s', len %"SC_FORMAT_LEN_SIZE_T"u, oid '%s'",
  886|     30|			       ecparams->named_curve, ecparams->field_length,
  887|     30|			       sc_dump_oid(&(ecparams->id)));
  888|     30|			pubkey->algorithm = SC_ALGORITHM_EC;
  ------------------
  |  |   79|     30|#define SC_ALGORITHM_EC		2
  ------------------
  889|       |
  890|     30|			r = sc_select_file(card, &file->path, NULL);
  891|     30|			sc_file_free(file);
  892|     30|			file = NULL;
  893|     30|			LOG_TEST_RET(ctx, r, "Cannot get public key: select key file 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: 4, False: 26]
  |  |  |  |  ------------------
  |  |  |  |  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|     30|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 26]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  894|       |
  895|     26|			data_obj.P1 = 0x01;
  896|     26|			data_obj.P2 = 0x86; /* Get public EC key (Q) */
  897|     26|			data_obj.Data = raw_pubkey;
  898|     26|			data_obj.DataLen = sizeof (raw_pubkey);
  899|       |
  900|     26|			r = sc_card_ctl(card, SC_CARDCTL_MYEID_GETDATA, &data_obj);
  901|     26|			LOG_TEST_RET(ctx, r, "Cannot get EC public key: 'MYEID_GETDATA' 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: 3, False: 23]
  |  |  |  |  ------------------
  |  |  |  |  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|     26|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 23]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  902|       |
  903|     23|			dataptr = data_obj.Data;
  904|     23|			r = sc_asn1_read_tag((const u8 **)&dataptr, data_obj.DataLen, &cla, &tag, &taglen);
  905|     23|			if (dataptr == NULL)
  ------------------
  |  Branch (905:8): [True: 4, False: 19]
  ------------------
  906|      4|				r = SC_ERROR_ASN1_OBJECT_NOT_FOUND;
  ------------------
  |  |   83|      4|#define SC_ERROR_ASN1_OBJECT_NOT_FOUND		-1402
  ------------------
  907|     23|			LOG_TEST_RET(ctx, r, "Invalid EC public key data. Cannot parse DER structure.");
  ------------------
  |  |  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: 4, False: 19]
  |  |  |  |  ------------------
  |  |  |  |  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|     23|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 19]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  908|       |
  909|     19|			if (taglen == 0)
  ------------------
  |  Branch (909:8): [True: 0, False: 19]
  ------------------
  910|     19|			    LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  911|       |
  912|     19|			if (pubkey->u.ec.ecpointQ.value)
  ------------------
  |  Branch (912:8): [True: 0, False: 19]
  ------------------
  913|      0|				free(pubkey->u.ec.ecpointQ.value);
  914|       |
  915|     19|			pubkey->u.ec.ecpointQ.value = malloc(taglen);
  916|       |
  917|     19|			if (pubkey->u.ec.ecpointQ.value == NULL)
  ------------------
  |  Branch (917:8): [True: 0, False: 19]
  ------------------
  918|     19|				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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  919|       |
  920|     19|			memcpy(pubkey->u.ec.ecpointQ.value, dataptr, taglen);
  921|     19|			pubkey->u.ec.ecpointQ.len = taglen;
  922|       |
  923|     19|			if (pubkey->u.ec.params.named_curve)
  ------------------
  |  Branch (923:8): [True: 19, False: 0]
  ------------------
  924|     19|				free(pubkey->u.ec.params.named_curve);
  925|     19|			pubkey->u.ec.params.named_curve = NULL;
  926|     19|			if (pubkey->u.ec.params.der.value)
  ------------------
  |  Branch (926:8): [True: 19, False: 0]
  ------------------
  927|     19|				free(pubkey->u.ec.params.der.value);
  928|     19|			pubkey->u.ec.params.der.value = NULL;
  929|     19|			pubkey->u.ec.params.der.len = 0;
  930|       |
  931|     19|			pubkey->u.ec.params.named_curve = strdup(ecparams->named_curve);
  932|     19|			if (!pubkey->u.ec.params.named_curve) {
  ------------------
  |  Branch (932:8): [True: 0, False: 19]
  ------------------
  933|      0|				free(pubkey->u.ec.ecpointQ.value);
  934|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  935|      0|			}
  936|       |
  937|     19|			r = sc_pkcs15_fix_ec_parameters(ctx, &pubkey->u.ec.params);
  938|     19|			if (r < 0)
  ------------------
  |  Branch (938:8): [True: 0, False: 19]
  ------------------
  939|      0|				free(pubkey->u.ec.ecpointQ.value);
  940|     19|			LOG_TEST_RET(ctx, r, "Cannot fix EC parameters");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  941|     19|		}
  942|     65|	}
  943|       |
  944|     37|	sc_file_free(file);
  945|       |
  946|     37|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 37]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  947|     37|}
pkcs15-myeid.c:myeid_finalize_card:
  950|    684|static int myeid_finalize_card(sc_card_t *card) {
  951|    684|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    684|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    684|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    684|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    684|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 684]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  952|    684|	LOG_FUNC_RETURN(card->ctx, sc_card_ctl(card, SC_CARDCTL_MYEID_ACTIVATE_CARD, NULL));
  ------------------
  |  |  164|    684|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    684|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    684|	int _ret = r; \
  |  |  |  |  155|    684|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 684, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    684|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    646|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 646, False: 38]
  |  |  |  |  ------------------
  |  |  |  |  157|    684|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    684|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    684|	return _ret; \
  |  |  |  |  163|    684|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  953|    684|}

cosm_delete_file:
  122|    347|{
  123|    347|	struct sc_context *ctx = p15card->card->ctx;
  124|    347|	struct sc_path  path;
  125|    347|	struct sc_file  *parent;
  126|    347|	int rv = 0;
  127|       |
  128|    347|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    347|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    347|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    347|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 347]
  |  |  ------------------
  ------------------
  129|    347|	sc_log(ctx,  "id %04X", df->id);
  ------------------
  |  |   71|    347|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  130|    347|	if (df->type==SC_FILE_TYPE_DF)   {
  ------------------
  |  |  214|    347|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (130:6): [True: 292, False: 55]
  ------------------
  131|    292|		rv = sc_pkcs15init_authenticate(profile, p15card, df, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    292|#define SC_AC_OP_DELETE			2
  ------------------
  132|    292|		LOG_TEST_RET(ctx, rv, "Cannot authenticate SC_AC_OP_DELETE");
  ------------------
  |  |  174|    292|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    292|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    292|	int _ret = (r); \
  |  |  |  |  168|    292|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 277, False: 15]
  |  |  |  |  ------------------
  |  |  |  |  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|    292|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 15]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  133|    292|	}
  134|       |
  135|       |	/* Select the parent DF */
  136|     70|	path = df->path;
  137|     70|	if (path.len < 2) {
  ------------------
  |  Branch (137:6): [True: 2, False: 68]
  ------------------
  138|      2|		LOG_FUNC_RETURN(ctx, SC_ERROR_INVALID_ARGUMENTS);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  139|      2|	}
  140|     68|	path.len -= 2;
  141|       |
  142|     68|	rv = sc_select_file(p15card->card, &path, &parent);
  143|     68|	LOG_TEST_RET(ctx, rv, "Cannot select parent");
  ------------------
  |  |  174|     68|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     68|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     68|	int _ret = (r); \
  |  |  |  |  168|     68|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 16, False: 52]
  |  |  |  |  ------------------
  |  |  |  |  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|     68|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  144|       |
  145|     52|	rv = sc_pkcs15init_authenticate(profile, p15card, parent, SC_AC_OP_DELETE);
  ------------------
  |  |  168|     52|#define SC_AC_OP_DELETE			2
  ------------------
  146|     52|	sc_file_free(parent);
  147|     52|	LOG_TEST_RET(ctx, rv, "Cannot authenticate SC_AC_OP_DELETE");
  ------------------
  |  |  174|     52|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|     52|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|     52|	int _ret = (r); \
  |  |  |  |  168|     52|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 52]
  |  |  |  |  ------------------
  |  |  |  |  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|     52|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 52]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  148|       |
  149|     52|	memset(&path, 0, sizeof(path));
  150|     52|	path.type = SC_PATH_TYPE_FILE_ID;
  ------------------
  |  |  117|     52|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  151|     52|	path.value[0] = df->id >> 8;
  152|     52|	path.value[1] = df->id & 0xFF;
  153|     52|	path.len = 2;
  154|       |
  155|     52|	rv = sc_delete_file(p15card->card, &path);
  156|       |
  157|     52|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|     47|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 47, False: 5]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  158|     52|}
sc_pkcs15init_get_oberthur_ops:
  939|    464|{
  940|    464|	return &sc_pkcs15init_oberthur_operations;
  941|    464|}
pkcs15-oberthur.c:cosm_erase_card:
  166|    297|{
  167|    297|	struct sc_context *ctx = p15card->card->ctx;
  168|    297|	struct sc_file  *df = profile->df_info->file, *dir;
  169|    297|	int rv;
  170|       |
  171|    297|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    297|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    297|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    297|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 297]
  |  |  ------------------
  ------------------
  172|       |	/* Delete EF(DIR). This may not be very nice
  173|       |	 * against other applications that use this file, but
  174|       |	 * extremely useful for testing :)
  175|       |	 * Note we need to delete if before the DF because we create
  176|       |	 * it *after* the DF.
  177|       |	 * */
  178|    297|	if (sc_profile_get_file(profile, "DIR", &dir) >= 0) {
  ------------------
  |  Branch (178:6): [True: 7, False: 290]
  ------------------
  179|      7|		sc_log(ctx,  "erase file dir %04X",dir->id);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  180|      7|		rv = cosm_delete_file(p15card, profile, dir);
  181|      7|		sc_file_free(dir);
  182|      7|		if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      4|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (182:7): [True: 4, False: 3]
  |  Branch (182:17): [True: 3, False: 1]
  ------------------
  183|      3|			goto done;
  184|      7|	}
  185|       |
  186|    294|	sc_log(ctx,  "erase file ddf %04X",df->id);
  ------------------
  |  |   71|    294|#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|    294|	rv = cosm_delete_file(p15card, profile, df);
  188|    294|	if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    294|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (188:6): [True: 294, False: 0]
  |  Branch (188:16): [True: 294, False: 0]
  ------------------
  189|    294|		goto done;
  190|       |
  191|      0|	if (sc_profile_get_file(profile, "private-DF", &dir) >= 0) {
  ------------------
  |  Branch (191:6): [True: 0, False: 0]
  ------------------
  192|      0|		sc_log(ctx,  "erase file dir %04X",dir->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__
  |  |  ------------------
  ------------------
  193|      0|		rv = cosm_delete_file(p15card, profile, dir);
  194|      0|		sc_file_free(dir);
  195|      0|		if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (195:7): [True: 0, False: 0]
  |  Branch (195:17): [True: 0, False: 0]
  ------------------
  196|      0|			goto done;
  197|      0|	}
  198|       |
  199|      0|	if (sc_profile_get_file(profile, "public-DF", &dir) >= 0) {
  ------------------
  |  Branch (199:6): [True: 0, False: 0]
  ------------------
  200|      0|		sc_log(ctx,  "erase file dir %04X",dir->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__
  |  |  ------------------
  ------------------
  201|      0|		rv = cosm_delete_file(p15card, profile, dir);
  202|      0|		sc_file_free(dir);
  203|      0|		if (rv < 0 && rv != SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (203:7): [True: 0, False: 0]
  |  Branch (203:17): [True: 0, False: 0]
  ------------------
  204|      0|			goto done;
  205|      0|	}
  206|       |
  207|      0|	rv = sc_profile_get_file(profile, COSM_TITLE"-AppDF", &dir);
  ------------------
  |  |   33|      0|#define COSM_TITLE "OberthurAWP"
  ------------------
  208|      0|	if (!rv) {
  ------------------
  |  Branch (208:6): [True: 0, False: 0]
  ------------------
  209|      0|		sc_log(ctx,  "delete %s; r %i", COSM_TITLE"-AppDF", 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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  209|      0|		sc_log(ctx,  "delete %s; r %i", COSM_TITLE"-AppDF", rv);
  |  |  |  |  ------------------
  |  |  |  |  |  |   33|      0|#define COSM_TITLE "OberthurAWP"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  210|      0|		rv = cosm_delete_file(p15card, profile, dir);
  211|      0|		sc_file_free(dir);
  212|      0|	}
  213|       |
  214|      0|	sc_free_apps(p15card->card);
  215|    297|done:
  216|    297|	if (rv == SC_ERROR_FILE_NOT_FOUND)
  ------------------
  |  |   51|    297|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (216:6): [True: 0, False: 297]
  ------------------
  217|      0|		rv = 0;
  218|       |
  219|    297|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  164|    297|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    297|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    297|	int _ret = r; \
  |  |  |  |  155|    297|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 297, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    297|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    297|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 297, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    297|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    297|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    297|	return _ret; \
  |  |  |  |  163|    297|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  220|    297|}
pkcs15-oberthur.c:cosm_select_pin_reference:
  379|    305|{
  380|    305|	struct sc_context *ctx = p15card->card->ctx;
  381|    305|	struct sc_pkcs15_pin_attributes *pin_attrs;
  382|    305|	struct sc_file *pinfile;
  383|       |
  384|    305|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    305|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    305|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    305|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 305]
  |  |  ------------------
  ------------------
  385|    305|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    305|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (385:6): [True: 0, False: 305]
  ------------------
  386|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  387|       |
  388|    305|	pin_attrs = &auth_info->attrs.pin;
  389|       |
  390|    305|	sc_log(ctx,  "ref %i; flags %X", pin_attrs->reference, pin_attrs->flags);
  ------------------
  |  |   71|    305|#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|    305|	if (sc_profile_get_file(profile, COSM_TITLE "-AppDF", &pinfile) < 0) {
  ------------------
  |  |   33|    305|#define COSM_TITLE "OberthurAWP"
  ------------------
  |  Branch (391:6): [True: 302, False: 3]
  ------------------
  392|    302|		sc_log(ctx,  "Profile doesn't define \"%s\"", COSM_TITLE "-AppDF");
  ------------------
  |  |   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__
  |  |  ------------------
  |  |               #define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |  392|    302|		sc_log(ctx,  "Profile doesn't define \"%s\"", COSM_TITLE "-AppDF");
  |  |  |  |  ------------------
  |  |  |  |  |  |   33|    302|#define COSM_TITLE "OberthurAWP"
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  393|    302|		return SC_ERROR_INCONSISTENT_PROFILE;
  ------------------
  |  |  104|    302|#define SC_ERROR_INCONSISTENT_PROFILE		-1502
  ------------------
  394|    302|	}
  395|       |
  396|      3|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|      3|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (396:6): [True: 0, False: 3]
  ------------------
  397|      0|		auth_info->path = pinfile->path;
  398|       |
  399|      3|	sc_file_free(pinfile);
  400|       |
  401|      3|	if (pin_attrs->reference <= 0)   {
  ------------------
  |  Branch (401:6): [True: 2, False: 1]
  ------------------
  402|      2|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|      2|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (402:7): [True: 0, False: 2]
  ------------------
  403|      0|			pin_attrs->reference = 4;
  404|      2|		else if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)
  ------------------
  |  |   60|      2|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (404:12): [True: 1, False: 1]
  ------------------
  405|      1|			pin_attrs->reference = 4;
  406|      1|		else
  407|      1|			pin_attrs->reference = 1;
  408|       |
  409|      2|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|      2|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (409:7): [True: 0, False: 2]
  ------------------
  410|      0|			pin_attrs->reference |= 0x80;
  411|      2|	}
  412|       |
  413|      3|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  414|      3|}
pkcs15-oberthur.c:cosm_create_pin:
  425|      1|{
  426|      1|	struct sc_context *ctx = p15card->card->ctx;
  427|      1|	struct sc_pkcs15_auth_info *auth_info = (struct sc_pkcs15_auth_info *) pin_obj->data;
  428|      1|	struct sc_pkcs15_pin_attributes *pin_attrs;
  429|      1|	struct sc_file *pin_file;
  430|      1|	int rv = 0;
  431|       |
  432|      1|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  433|      1|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      1|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (433:6): [True: 0, False: 1]
  ------------------
  434|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  435|       |
  436|      1|	pin_attrs = &auth_info->attrs.pin;
  437|       |
  438|      1|	sc_log(ctx,  "create '%.*s'; ref 0x%X; flags %X", (int) sizeof pin_obj->label, pin_obj->label, pin_attrs->reference, pin_attrs->flags);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  439|      1|	if (sc_profile_get_file(profile, COSM_TITLE "-AppDF", &pin_file) < 0)
  ------------------
  |  |   33|      1|#define COSM_TITLE "OberthurAWP"
  ------------------
  |  Branch (439:6): [True: 0, False: 1]
  ------------------
  440|      1|		LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "\""COSM_TITLE"-AppDF\" 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|      1|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|      1|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (442:6): [True: 0, False: 1]
  ------------------
  443|      0|		auth_info->path = pin_file->path;
  444|       |
  445|      1|	sc_file_free(pin_file);
  446|       |
  447|      1|	if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_SO_PIN)   {
  ------------------
  |  |   61|      1|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (447:6): [True: 0, False: 1]
  ------------------
  448|      0|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)   {
  ------------------
  |  |   60|      0|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (448:7): [True: 0, False: 0]
  ------------------
  449|      0|			LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "SOPIN unblocking 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  450|      0|		}
  451|      0|		else   {
  452|      0|			if (pin_attrs->reference != 4)
  ------------------
  |  Branch (452:8): [True: 0, False: 0]
  ------------------
  453|      0|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid SOPIN reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|      0|		}
  455|      0|	}
  456|      1|	else {
  457|      1|		if (pin_attrs->flags & SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN)   {
  ------------------
  |  |   60|      1|#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN		0x0040
  ------------------
  |  Branch (457:7): [True: 1, False: 0]
  ------------------
  458|      1|			if (pin_attrs->reference != 0x84)
  ------------------
  |  Branch (458:8): [True: 1, False: 0]
  ------------------
  459|      1|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid User PUK reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  460|      1|		}
  461|      0|		else   {
  462|      0|			if (pin_attrs->reference != 0x81)
  ------------------
  |  Branch (462:8): [True: 0, False: 0]
  ------------------
  463|      0|				LOG_TEST_RET(ctx, SC_ERROR_INVALID_PIN_REFERENCE, "Invalid User PIN reference");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|      0|		}
  465|      1|	}
  466|       |
  467|      0|	if (pin && pin_len)   {
  ------------------
  |  Branch (467:6): [True: 0, False: 0]
  |  Branch (467:13): [True: 0, False: 0]
  ------------------
  468|      0|		rv = cosm_update_pin(profile, p15card, auth_info, pin, pin_len,  puk, puk_len);
  469|      0|		LOG_TEST_RET(ctx, rv, "Update 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  470|      0|	}
  471|       |
  472|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|      0|}
pkcs15-oberthur.c:cosm_create_key:
  720|  1.18k|{
  721|  1.18k|	struct sc_context *ctx = p15card->card->ctx;
  722|  1.18k|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  723|  1.18k|	struct sc_file *file = NULL;
  724|  1.18k|	int rv = 0;
  725|       |
  726|  1.18k|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|  1.18k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|  1.18k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|  1.18k|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 1.18k]
  |  |  ------------------
  ------------------
  727|  1.18k|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|  1.18k|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (727:6): [True: 891, False: 296]
  ------------------
  728|  1.18k|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Create key failed: RSA only supported");
  ------------------
  |  |  174|    891|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    891|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    891|	int _ret = (r); \
  |  |  |  |  168|    891|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 891, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    891|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    891|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    891|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    891|		return _ret; \
  |  |  |  |  172|    891|	} \
  |  |  |  |  173|    891|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  729|       |
  730|    296|	if (key_info->path.len < 2) {
  ------------------
  |  Branch (730:6): [True: 200, False: 96]
  ------------------
  731|    200|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_VALID,
  ------------------
  |  |  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: 200, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|    200|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  732|    200|				"The path needs to be at least two bytes long");
  733|    200|	}
  734|       |
  735|     96|	sc_log(ctx,  "create private key ID:%s",  sc_pkcs15_print_id(&key_info->id));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  736|       |	/* Here, the path of private key file should be defined.
  737|       |	 * Nevertheless, we need to instantiate private key to get the ACLs. */
  738|     96|	rv = cosm_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
  ------------------
  |  |  419|     96|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  739|     96|	LOG_TEST_RET(ctx, rv, "Cannot create key: failed to allocate new key object");
  ------------------
  |  |  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: 40, False: 56]
  |  |  |  |  ------------------
  |  |  |  |  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|     96|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 56]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  740|       |
  741|     56|	file->size = key_info->modulus_length;
  742|     56|	memcpy(&file->path, &key_info->path, sizeof(file->path));
  743|     56|	file->id = file->path.value[file->path.len - 2] * 0x100
  744|     56|				+ file->path.value[file->path.len - 1];
  745|       |
  746|     56|	sc_log(ctx,  "Path of private key file to create %s", sc_print_path(&file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  747|       |
  748|     56|	rv = sc_select_file(p15card->card, &file->path, NULL);
  749|     56|	if (rv == 0)   {
  ------------------
  |  Branch (749:6): [True: 45, False: 11]
  ------------------
  750|     45|		rv = cosm_delete_file(p15card, profile, file);
  751|     45|		SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Failed to delete private key file");
  ------------------
  |  |  176|     45|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     45|	int _ret = (r); \
  |  |  178|     45|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 43, False: 2]
  |  |  ------------------
  |  |  179|     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
  |  |  ------------------
  |  |  180|     43|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  181|     43|		goto err; \
  |  |  182|     43|	} \
  |  |  183|     45|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 2]
  |  |  ------------------
  ------------------
  752|     45|	}
  753|     11|	else if (rv != SC_ERROR_FILE_NOT_FOUND)    {
  ------------------
  |  |   51|     11|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (753:11): [True: 0, False: 11]
  ------------------
  754|      0|		SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Select private key file error");
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  755|      0|	}
  756|       |
  757|     13|	rv = sc_pkcs15init_create_file(profile, p15card, file);
  758|     13|	SC_TEST_GOTO_ERR(ctx, SC_LOG_DEBUG_VERBOSE, rv, "Failed to create private key file");
  ------------------
  |  |  176|     13|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  177|     13|	int _ret = (r); \
  |  |  178|     13|	if (_ret < 0) { \
  |  |  ------------------
  |  |  |  Branch (178:6): [True: 3, False: 10]
  |  |  ------------------
  |  |  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|     13|} while(0)
  |  |  ------------------
  |  |  |  Branch (183:9): [Folded, False: 10]
  |  |  ------------------
  ------------------
  759|       |
  760|     10|	key_info->key_reference = file->path.value[file->path.len - 1];
  761|       |
  762|     56|err:
  763|     56|	sc_file_free(file);
  764|       |
  765|     56|	LOG_FUNC_RETURN(ctx, rv);
  ------------------
  |  |  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|     46|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 46, False: 10]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  766|     56|}
pkcs15-oberthur.c:cosm_new_file:
  482|     96|{
  483|     96|	struct sc_file	*file;
  484|     96|	const char *_template = NULL, *desc = NULL;
  485|     96|	unsigned int structure = 0xFFFFFFFF;
  486|       |
  487|     96|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  488|     96|	sc_log(card->ctx,  "cosm_new_file() type %X; num %i",type, num);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  489|     96|	while (1) {
  ------------------
  |  Branch (489:9): [True: 96, Folded]
  ------------------
  490|     96|		switch (type) {
  ------------------
  |  Branch (490:11): [True: 96, False: 0]
  ------------------
  491|     96|		case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|     96|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (491:3): [True: 96, False: 0]
  ------------------
  492|     96|		case COSM_TYPE_PRKEY_RSA:
  ------------------
  |  |   42|     96|#define COSM_TYPE_PRKEY_RSA (SC_DEVICE_SPECIFIC_TYPE | SC_PKCS15_TYPE_PRKEY_RSA)
  |  |  ------------------
  |  |  |  |   40|     96|#define SC_DEVICE_SPECIFIC_TYPE	 0x1000
  |  |  ------------------
  |  |               #define COSM_TYPE_PRKEY_RSA (SC_DEVICE_SPECIFIC_TYPE | SC_PKCS15_TYPE_PRKEY_RSA)
  |  |  ------------------
  |  |  |  |  419|     96|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  |  |  ------------------
  ------------------
  |  Branch (492:3): [True: 0, False: 96]
  ------------------
  493|     96|			desc = "RSA private key";
  494|     96|			_template = "template-private-key";
  495|     96|			structure = SC_CARDCTL_OBERTHUR_KEY_RSA_CRT;
  496|     96|			break;
  497|      0|		case SC_PKCS15_TYPE_PUBKEY_RSA:
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (497:3): [True: 0, False: 96]
  ------------------
  498|      0|		case COSM_TYPE_PUBKEY_RSA:
  ------------------
  |  |   43|      0|#define COSM_TYPE_PUBKEY_RSA (SC_DEVICE_SPECIFIC_TYPE | SC_PKCS15_TYPE_PUBKEY_RSA)
  |  |  ------------------
  |  |  |  |   40|      0|#define SC_DEVICE_SPECIFIC_TYPE	 0x1000
  |  |  ------------------
  |  |               #define COSM_TYPE_PUBKEY_RSA (SC_DEVICE_SPECIFIC_TYPE | SC_PKCS15_TYPE_PUBKEY_RSA)
  |  |  ------------------
  |  |  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  |  |  ------------------
  ------------------
  |  Branch (498:3): [True: 0, False: 96]
  ------------------
  499|      0|			desc = "RSA public key";
  500|      0|			_template = "template-public-key";
  501|      0|			structure = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
  502|      0|			break;
  503|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (503:3): [True: 0, False: 96]
  ------------------
  504|      0|			desc = "certificate";
  505|      0|			_template = "template-certificate";
  506|      0|			break;
  507|      0|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (507:3): [True: 0, False: 96]
  ------------------
  508|      0|			desc = "data object";
  509|      0|			_template = "template-public-data";
  510|      0|			break;
  511|     96|		}
  512|     96|		if (_template)
  ------------------
  |  Branch (512:7): [True: 96, False: 0]
  ------------------
  513|     96|			break;
  514|       |		/* If this is a specific type such as
  515|       |		 * SC_PKCS15_TYPE_CERT_FOOBAR, fall back to
  516|       |		 * the generic class (SC_PKCS15_TYPE_CERT)
  517|       |		 */
  518|      0|		if (!(type & ~SC_PKCS15_TYPE_CLASS_MASK)) {
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (518:7): [True: 0, False: 0]
  ------------------
  519|      0|			sc_log(card->ctx,  "File type %X 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__
  |  |  ------------------
  ------------------
  520|      0|				type);
  521|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  522|      0|		}
  523|      0|		type &= SC_PKCS15_TYPE_CLASS_MASK;
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  524|      0|	}
  525|       |
  526|     96|	sc_log(card->ctx,  "cosm_new_file() template %s; num %i",_template, num);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  527|     96|	if (sc_profile_get_file(profile, _template, &file) < 0) {
  ------------------
  |  Branch (527:6): [True: 40, False: 56]
  ------------------
  528|     40|		sc_log(card->ctx,  "Profile doesn't define %s template '%s'",
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  529|     40|				desc, _template);
  530|     40|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  531|     40|	}
  532|       |
  533|     56|	file->id |= (num & 0xFF);
  534|     56|	if (file->path.len) {
  ------------------
  |  Branch (534:6): [True: 56, False: 0]
  ------------------
  535|     56|		file->path.value[file->path.len - 1] |= (num & 0xFF);
  536|     56|	}
  537|     56|	if (file->type == SC_FILE_TYPE_INTERNAL_EF)   {
  ------------------
  |  |  215|     56|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (537:6): [True: 1, False: 55]
  ------------------
  538|      1|		file->ef_structure = structure;
  539|      1|	}
  540|       |
  541|     56|	sc_log(card->ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  542|     56|		 "cosm_new_file() file size %"SC_FORMAT_LEN_SIZE_T"u; ef type %i/%i; id %04X",
  543|     56|		 file->size, file->type, file->ef_structure, file->id);
  544|     56|	*out = file;
  545|       |
  546|     56|	LOG_FUNC_RETURN(card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  547|     56|}
pkcs15-oberthur.c:cosm_generate_key:
  602|     10|{
  603|     10|	struct sc_context *ctx = p15card->card->ctx;
  604|     10|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  605|     10|	struct sc_cardctl_oberthur_genkey_info args;
  606|     10|	struct sc_file *prkf = NULL, *tmpf = NULL;
  607|     10|	struct sc_path path;
  608|     10|	int rv = 0;
  609|       |
  610|     10|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  611|       |
  612|     10|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|     10|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (612:6): [True: 0, False: 10]
  ------------------
  613|     10|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Generate key failed: RSA only 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  614|       |
  615|     10|	if (key_info->path.len < 4) {
  ------------------
  |  Branch (615:6): [True: 0, False: 10]
  ------------------
  616|      0|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_VALID,
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|      0|				"The path needs to be at least four bytes long");
  618|      0|	}
  619|       |
  620|     10|	path = key_info->path;
  621|     10|	path.len -= 2;
  622|       |
  623|     10|	rv = sc_select_file(p15card->card, &path, &tmpf);
  624|     10|	LOG_TEST_RET(ctx, rv, "Cannot generate key: failed to select private object DF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  625|       |
  626|      9|	rv = sc_pkcs15init_authenticate(profile, p15card, tmpf, SC_AC_OP_CRYPTO);
  ------------------
  |  |  173|      9|#define SC_AC_OP_CRYPTO			7
  ------------------
  627|      9|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      9|#define SC_SUCCESS				0
  ------------------
  |  Branch (627:6): [True: 1, False: 8]
  ------------------
  628|      1|		sc_file_free(tmpf);
  629|      1|		LOG_TEST_RET(ctx, rv, "Cannot generate key: 'CRYPTO' authentication 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  630|      1|	}
  631|       |
  632|      8|	rv = sc_pkcs15init_authenticate(profile, p15card, tmpf, SC_AC_OP_CREATE);
  ------------------
  |  |  169|      8|#define SC_AC_OP_CREATE			3
  ------------------
  633|      8|	sc_file_free(tmpf);
  634|      8|	tmpf = NULL;
  635|      8|	LOG_TEST_RET(ctx, rv, "Cannot generate key: 'CREATE' authentication 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  636|       |
  637|      7|	rv = sc_select_file(p15card->card, &key_info->path, &prkf);
  638|      7|	LOG_TEST_RET(ctx, rv, "Failed to generate key: cannot select private key file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  639|       |
  640|       |	/* In the private key DF create the temporary public RSA file. */
  641|      5|	rv = cosm_get_temporary_public_key_file(p15card->card, prkf, &tmpf);
  642|      5|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      5|#define SC_SUCCESS				0
  ------------------
  |  Branch (642:6): [True: 1, False: 4]
  ------------------
  643|      1|		sc_file_free(prkf);
  644|      1|		LOG_TEST_RET(ctx, rv, "Error while getting temporary public key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  645|      1|	}
  646|       |
  647|      4|	rv = sc_pkcs15init_create_file(profile, p15card, tmpf);
  648|      4|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  |  Branch (648:6): [True: 2, False: 2]
  ------------------
  649|      2|		sc_file_free(prkf);
  650|      2|		sc_file_free(tmpf);
  651|      2|		LOG_TEST_RET(ctx, rv, "cosm_generate_key() failed to create temporary public key EF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  652|      2|	}
  653|       |
  654|      2|	memset(&args, 0, sizeof(args));
  655|      2|	args.id_prv = prkf->id;
  656|      2|	args.id_pub = tmpf->id;
  657|      2|	args.exponent = 0x10001;
  658|      2|	args.key_bits = key_info->modulus_length;
  659|      2|	args.pubkey_len = key_info->modulus_length / 8;
  660|      2|	args.pubkey = malloc(key_info->modulus_length / 8);
  661|      2|	if (!args.pubkey) {
  ------------------
  |  Branch (661:6): [True: 0, False: 2]
  ------------------
  662|      0|		sc_file_free(prkf);
  663|      0|		sc_file_free(tmpf);
  664|      0|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "cosm_generate_key() cannot allocate pubkey");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  665|      0|	}
  666|       |
  667|      2|	rv = sc_card_ctl(p15card->card, SC_CARDCTL_OBERTHUR_GENERATE_KEY, &args);
  668|      2|	if (rv != SC_SUCCESS) {
  ------------------
  |  |   28|      2|#define SC_SUCCESS				0
  ------------------
  |  Branch (668:6): [True: 1, False: 1]
  ------------------
  669|      1|		sc_file_free(prkf);
  670|      1|		sc_file_free(tmpf);
  671|      1|		free(args.pubkey);
  672|      1|	}
  673|      2|	LOG_TEST_RET(ctx, rv, "cosm_generate_key() CARDCTL_OBERTHUR_GENERATE_KEY 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  674|       |
  675|       |	/* extract public key */
  676|      1|	pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      1|#define SC_ALGORITHM_RSA		0
  ------------------
  677|      1|	pubkey->u.rsa.modulus.len   = key_info->modulus_length / 8;
  678|      1|	pubkey->u.rsa.modulus.data  = malloc(key_info->modulus_length / 8);
  679|      1|	if (!pubkey->u.rsa.modulus.data) {
  ------------------
  |  Branch (679:6): [True: 0, False: 1]
  ------------------
  680|      0|		sc_file_free(prkf);
  681|      0|		sc_file_free(tmpf);
  682|      0|		free(args.pubkey);
  683|      0|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "cosm_generate_key() cannot allocate modulus buf");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  684|      0|	}
  685|       |
  686|       |	/* FIXME and if the exponent length is not 3? */
  687|      1|	pubkey->u.rsa.exponent.len  = 3;
  688|      1|	pubkey->u.rsa.exponent.data = malloc(3);
  689|      1|	if (!pubkey->u.rsa.exponent.data) {
  ------------------
  |  Branch (689:6): [True: 0, False: 1]
  ------------------
  690|      0|		sc_file_free(prkf);
  691|      0|		sc_file_free(tmpf);
  692|      0|		free(args.pubkey);
  693|      0|		free(pubkey->u.rsa.modulus.data);
  694|      0|		LOG_TEST_RET(ctx, SC_ERROR_OUT_OF_MEMORY, "cosm_generate_key() cannot allocate exponent buf");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  695|      0|	}
  696|      1|	memcpy(pubkey->u.rsa.exponent.data, "\x01\x00\x01", 3);
  697|      1|	memcpy(pubkey->u.rsa.modulus.data, args.pubkey, args.pubkey_len);
  698|      1|	pubkey->u.rsa.modulus.len = args.pubkey_len;
  699|       |
  700|      1|	key_info->key_reference = prkf->path.value[prkf->path.len - 1] & 0xFF;
  701|      1|	key_info->path = prkf->path;
  702|       |
  703|      1|	sc_log(ctx,  "cosm_generate_key() now delete temporary public 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__
  |  |  ------------------
  ------------------
  704|      1|	rv =  cosm_delete_file(p15card, profile, tmpf);
  705|       |
  706|      1|	sc_file_free(tmpf);
  707|      1|	sc_file_free(prkf);
  708|      1|	free(args.pubkey);
  709|       |
  710|      1|	LOG_FUNC_RETURN(ctx, 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  711|      1|}
pkcs15-oberthur.c:cosm_get_temporary_public_key_file:
  553|      5|{
  554|      5|	struct sc_context *ctx = card->ctx;
  555|      5|	const struct sc_acl_entry *entry = NULL;
  556|      5|	struct sc_file *file = NULL;
  557|      5|	int rv;
  558|       |
  559|      5|	SC_FUNC_CALLED(card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  560|      5|	if (!pubkey_file || !prvkey_file)
  ------------------
  |  Branch (560:6): [True: 0, False: 5]
  |  Branch (560:22): [True: 0, False: 5]
  ------------------
  561|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  562|       |
  563|      5|	file = sc_file_new();
  564|      5|	if (!file)
  ------------------
  |  Branch (564:6): [True: 0, False: 5]
  ------------------
  565|      5|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  566|       |
  567|      5|	file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      5|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  568|      5|        file->type = SC_FILE_TYPE_INTERNAL_EF;
  ------------------
  |  |  215|      5|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  569|      5|	file->ef_structure = SC_CARDCTL_OBERTHUR_KEY_RSA_PUBLIC;
  570|      5|	file->id = 0x1012;
  571|      5|	memcpy(&file->path, &prvkey_file->path, sizeof(file->path));
  572|      5|        file->path.value[file->path.len - 2] = 0x10;
  573|      5|	file->path.value[file->path.len - 1] = 0x12;
  574|      5|	file->size = prvkey_file->size;
  575|       |
  576|      5|	entry = sc_file_get_acl_entry(prvkey_file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      5|#define SC_AC_OP_UPDATE			23
  ------------------
  577|      5|	if (!entry) {
  ------------------
  |  Branch (577:6): [True: 1, False: 4]
  ------------------
  578|      1|		sc_file_free(file);
  579|      1|		LOG_TEST_RET(ctx, SC_ERROR_OBJECT_NOT_FOUND, "Failed to find ACL entry");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  580|      1|	}
  581|      4|	rv = sc_file_add_acl_entry(file, SC_AC_OP_UPDATE, entry->method, entry->key_ref);
  ------------------
  |  |  189|      4|#define SC_AC_OP_UPDATE			23
  ------------------
  582|      4|	if (!rv)
  ------------------
  |  Branch (582:6): [True: 4, False: 0]
  ------------------
  583|      4|		rv = sc_file_add_acl_entry(file, SC_AC_OP_PSO_ENCRYPT, SC_AC_NONE, 0);
  ------------------
  |  |  176|      4|#define SC_AC_OP_PSO_ENCRYPT		10
  ------------------
              		rv = sc_file_add_acl_entry(file, SC_AC_OP_PSO_ENCRYPT, SC_AC_NONE, 0);
  ------------------
  |  |  150|      4|#define SC_AC_NONE			0x00000000
  ------------------
  584|      4|	if (!rv)
  ------------------
  |  Branch (584:6): [True: 4, False: 0]
  ------------------
  585|      4|		rv = sc_file_add_acl_entry(file, SC_AC_OP_PSO_VERIFY_SIGNATURE, SC_AC_NONE, 0);
  ------------------
  |  |  178|      4|#define SC_AC_OP_PSO_VERIFY_SIGNATURE	12
  ------------------
              		rv = sc_file_add_acl_entry(file, SC_AC_OP_PSO_VERIFY_SIGNATURE, SC_AC_NONE, 0);
  ------------------
  |  |  150|      4|#define SC_AC_NONE			0x00000000
  ------------------
  586|      4|	if (!rv)
  ------------------
  |  Branch (586:6): [True: 4, False: 0]
  ------------------
  587|      4|		rv = sc_file_add_acl_entry(file, SC_AC_OP_EXTERNAL_AUTHENTICATE, SC_AC_NONE, 0);
  ------------------
  |  |  182|      4|#define SC_AC_OP_EXTERNAL_AUTHENTICATE	16
  ------------------
              		rv = sc_file_add_acl_entry(file, SC_AC_OP_EXTERNAL_AUTHENTICATE, SC_AC_NONE, 0);
  ------------------
  |  |  150|      4|#define SC_AC_NONE			0x00000000
  ------------------
  588|      4|	if (rv < 0)
  ------------------
  |  Branch (588:6): [True: 0, False: 4]
  ------------------
  589|      0|		sc_file_free(file);
  590|      4|	LOG_TEST_RET(ctx, rv, "Failed to add ACL entry to the temporary public key file");
  ------------------
  |  |  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: 0, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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|      4|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  591|       |
  592|      4|	*pubkey_file = file;
  593|       |
  594|      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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  595|      4|}

sc_pkcs15init_get_openpgp_ops:
  622|    329|{
  623|    329|	return &sc_pkcs15init_openpgp_operations;
  624|    329|}
pkcs15-openpgp.c:openpgp_erase:
   46|    169|{
   47|    169|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    169|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
   48|    169|}
pkcs15-openpgp.c:openpgp_select_pin_reference:
   71|    179|{
   72|    179|	return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    179|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
   73|    179|}
pkcs15-openpgp.c:openpgp_create_key:
   98|    653|{
   99|       |	/* For OpenPGP card, the number of keys is fixed,
  100|       |	 * so this function does not really do anything.
  101|       |	 * It just present here to avoid pkcs15init's default routine,
  102|       |	 * which tries to do impossible things. */
  103|    653|	LOG_FUNC_CALLED(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  104|    653|	LOG_FUNC_RETURN(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  105|    653|}
pkcs15-openpgp.c:openpgp_store_key:
  173|    495|{
  174|    495|	sc_card_t *card = p15card->card;
  175|    495|	sc_pkcs15_prkey_info_t *kinfo = (sc_pkcs15_prkey_info_t *) obj->data;
  176|    495|	sc_cardctl_openpgp_key_gen_store_info_t key_info = {0};
  177|    495|	int r;
  178|       |
  179|    495|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    495|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    495|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    495|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    495|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 495]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  180|       |
  181|    495|	switch(obj->type)
  182|    495|	{
  183|      0|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|      0|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (183:2): [True: 0, False: 495]
  ------------------
  184|      0|		memset(&key_info, 0, sizeof(sc_cardctl_openpgp_key_gen_store_info_t));
  185|      0|		key_info.algorithm = SC_OPENPGP_KEYALGO_RSA;
  ------------------
  |  |  869|      0|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  186|      0|		key_info.key_id = kinfo->id.value[0];
  187|      0|		key_info.u.rsa.exponent = key->u.rsa.exponent.data;
  188|      0|		key_info.u.rsa.exponent_len = key->u.rsa.exponent.len * 8; /* use bits instead of bytes */
  189|      0|		key_info.u.rsa.p = key->u.rsa.p.data;
  190|      0|		key_info.u.rsa.p_len = key->u.rsa.p.len;
  191|      0|		key_info.u.rsa.q = key->u.rsa.q.data;
  192|      0|		key_info.u.rsa.q_len = key->u.rsa.q.len;
  193|      0|		key_info.u.rsa.modulus = key->u.rsa.modulus.data;
  194|      0|		key_info.u.rsa.modulus_len = key->u.rsa.modulus.len * 8; /* use bits instead of bytes */
  195|      0|		r = sc_card_ctl(card, SC_CARDCTL_OPENPGP_STORE_KEY, &key_info);
  196|       |
  197|       |		/* nothing to free in key_info for RSA */
  198|      0|		break;
  199|       |
  200|      0|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|      0|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (200:2): [True: 0, False: 495]
  ------------------
  201|      0|	case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (201:2): [True: 0, False: 495]
  ------------------
  202|      0|	case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (202:2): [True: 0, False: 495]
  ------------------
  203|      0|		memset(&key_info, 0, sizeof(sc_cardctl_openpgp_key_gen_store_info_t));
  204|       |
  205|      0|		r = openpgp_set_algorithm(p15card, kinfo->id.value[0], obj->type, &key_info.algorithm);
  206|      0|		LOG_TEST_GOTO_ERR(card->ctx, r, "Key type not valid for key id");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  207|       |
  208|      0|		key_info.key_id = kinfo->id.value[0];
  209|      0|		key_info.u.ec.privateD = key->u.ec.privateD.data;
  210|      0|		key_info.u.ec.privateD_len = key->u.ec.privateD.len;
  211|       |		/*
  212|       |		 * key->u.ec.ecpointQ.len is optional with private key
  213|       |		 * PKCS11 does not pass it when creting private key object.
  214|       |		 * pkcs15init/pkcs15-lib.c will attempt to derive it from private key
  215|       |		 */
  216|      0|		if (key->u.ec.ecpointQ.len) {
  ------------------
  |  Branch (216:7): [True: 0, False: 0]
  ------------------
  217|      0|			key_info.u.ec.ecpointQ = malloc(key->u.ec.ecpointQ.len);
  218|      0|			if (!key_info.u.ec.ecpointQ)
  ------------------
  |  Branch (218:8): [True: 0, False: 0]
  ------------------
  219|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  220|      0|			memcpy(key_info.u.ec.ecpointQ, key->u.ec.ecpointQ.value, key->u.ec.ecpointQ.len);
  221|      0|		}
  222|      0|		key_info.u.ec.ecpointQ_len = key->u.ec.ecpointQ.len;
  223|      0|		key_info.u.ec.oid = key->u.ec.params.id;
  224|      0|		key_info.key_type = key->algorithm; /* SC_SC_ALGORITHM_* */
  225|      0|		r = sc_card_ctl(card, SC_CARDCTL_OPENPGP_STORE_KEY, &key_info);
  226|       |
  227|      0|		free(key_info.u.ec.ecpointQ);
  228|      0|		break;
  229|       |
  230|    495|	default:
  ------------------
  |  Branch (230:2): [True: 495, False: 0]
  ------------------
  231|    495|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    495|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  232|    495|		sc_log(card->ctx, "%s: Key generation failed: Unknown/unsupported key type.", strerror(r));
  ------------------
  |  |   71|    495|#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|    495|	}
  234|       |
  235|    495|err:
  236|    495|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    495|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    495|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    495|	int _ret = r; \
  |  |  |  |  155|    495|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 495, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    495|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    495|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 495, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    495|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    495|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    495|	return _ret; \
  |  |  |  |  163|    495|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  237|    495|}
pkcs15-openpgp.c:openpgp_generate_key:
  438|    158|{
  439|    158|	sc_card_t *card = p15card->card;
  440|    158|	sc_context_t *ctx = card->ctx;
  441|    158|	int r;
  442|       |
  443|    158|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    158|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    158|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    158|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    158|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 158]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  444|       |
  445|    158|	switch(obj->type)
  446|    158|	{
  447|    137|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    137|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (447:2): [True: 137, False: 21]
  ------------------
  448|    137|		r = openpgp_generate_key_rsa(card, obj, pubkey);
  449|    137|		break;
  450|     21|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|     21|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (450:2): [True: 21, False: 137]
  ------------------
  451|     21|		if (card->type < SC_CARD_TYPE_OPENPGP_V3) {
  ------------------
  |  Branch (451:7): [True: 7, False: 14]
  ------------------
  452|      7|			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "only RSA is supported on this card");
  ------------------
  |  |   70|      7|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  453|      7|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      7|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  454|      7|		}
  455|     14|		r = openpgp_generate_key_ec(card, obj, pubkey);
  456|     14|		break;
  457|      0|	case SC_PKCS15_TYPE_PRKEY_EDDSA:
  ------------------
  |  |  422|      0|#define SC_PKCS15_TYPE_PRKEY_EDDSA		0x105
  ------------------
  |  Branch (457:2): [True: 0, False: 158]
  ------------------
  458|      0|	case SC_PKCS15_TYPE_PRKEY_XEDDSA:
  ------------------
  |  |  423|      0|#define SC_PKCS15_TYPE_PRKEY_XEDDSA		0x106
  ------------------
  |  Branch (458:2): [True: 0, False: 158]
  ------------------
  459|      0|		if (card->type != SC_CARD_TYPE_OPENPGP_GNUK && card->type < SC_CARD_TYPE_OPENPGP_V3) {
  ------------------
  |  Branch (459:7): [True: 0, False: 0]
  |  Branch (459:50): [True: 0, False: 0]
  ------------------
  460|      0|			sc_debug(card->ctx, SC_LOG_DEBUG_NORMAL, "EdDSA or XEDDSA are not supported on this card");
  ------------------
  |  |   70|      0|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  461|      0|			return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  462|      0|		}
  463|      0|		r = openpgp_generate_key_ec(card, obj, pubkey);
  464|      0|		break;
  465|      0|	default:
  ------------------
  |  Branch (465:2): [True: 0, False: 158]
  ------------------
  466|      0|		r = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  467|      0|		sc_log(card->ctx, "%s: Key generation failed: Unknown/unsupported key type.", 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__
  |  |  ------------------
  ------------------
  468|    158|	}
  469|       |
  470|    151|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  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|    147|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 147, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  471|    151|}
pkcs15-openpgp.c:openpgp_generate_key_rsa:
  248|    137|{
  249|    137|	sc_context_t *ctx = card->ctx;
  250|    137|	sc_cardctl_openpgp_key_gen_store_info_t key_info;
  251|    137|	sc_pkcs15_prkey_info_t *required = (sc_pkcs15_prkey_info_t *)obj->data;
  252|    137|	sc_pkcs15_id_t *kid = &(required->id);
  253|    137|	int r;
  254|       |
  255|    137|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    137|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    137|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    137|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    137|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 137]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  256|    137|	memset(&key_info, 0, sizeof(key_info));
  257|    137|	sc_log(ctx, "Key ID to be generated: %s", sc_dump_hex(kid->value, kid->len));
  ------------------
  |  |   71|    137|#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|       |
  259|       |	/* Accept KeyID = 45, which is default value set by pkcs15init */
  260|    137|	if (kid->len == 1 && kid->value[0] == 0x45) {
  ------------------
  |  Branch (260:6): [True: 137, False: 0]
  |  Branch (260:23): [True: 137, False: 0]
  ------------------
  261|       |		/* Default key is authentication key. We choose this because the common use
  262|       |		 * is to generate from PKCS#11 (Firefox/Thunderbird) */
  263|    137|		sc_log(ctx, "Authentication key is to be generated.");
  ------------------
  |  |   71|    137|#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|    137|		key_info.key_id = 3;
  265|    137|	}
  266|    137|	if (!key_info.key_id && (kid->len > 1 || kid->value[0] > 3)) {
  ------------------
  |  Branch (266:6): [True: 0, False: 137]
  |  Branch (266:27): [True: 0, False: 0]
  |  Branch (266:43): [True: 0, False: 0]
  ------------------
  267|      0|		sc_log(ctx, "Key ID must be 1, 2 or 3!");
  ------------------
  |  |   71|      0|#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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  269|      0|	}
  270|       |
  271|    137|	if (!key_info.key_id)
  ------------------
  |  Branch (271:6): [True: 0, False: 137]
  ------------------
  272|      0|		key_info.key_id = kid->value[0];
  273|       |
  274|    137|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA) {
  ------------------
  |  |  419|    137|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (274:6): [True: 0, False: 137]
  ------------------
  275|      0|		sc_log(card->ctx,  "only RSA is currently supported");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  276|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  277|      0|	}
  278|       |
  279|       |
  280|    137|	key_info.algorithm = SC_OPENPGP_KEYALGO_RSA;
  ------------------
  |  |  869|    137|#define	SC_OPENPGP_KEYALGO_RSA		0x01
  ------------------
  281|       |
  282|       |	/* Prepare buffer */
  283|    137|	key_info.u.rsa.modulus_len = required->modulus_length;
  284|    137|	key_info.u.rsa.modulus = calloc(1, BYTES4BITS(required->modulus_length));
  ------------------
  |  |  146|    137|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  285|    137|	if (key_info.u.rsa.modulus == NULL)
  ------------------
  |  Branch (285:6): [True: 0, False: 137]
  ------------------
  286|    137|		LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  287|       |
  288|       |	/* The OpenPGP supports only 32-bit exponent. */
  289|    137|	key_info.u.rsa.exponent_len = 32;
  290|    137|	key_info.u.rsa.exponent = calloc(1, BYTES4BITS(key_info.u.rsa.exponent_len));
  ------------------
  |  |  146|    137|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  291|    137|	if (key_info.u.rsa.exponent == NULL) {
  ------------------
  |  Branch (291:6): [True: 0, False: 137]
  ------------------
  292|      0|		free(key_info.u.rsa.modulus);
  293|      0|		LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  294|      0|	}
  295|       |
  296|    137|	r = sc_card_ctl(card, SC_CARDCTL_OPENPGP_GENERATE_KEY, &key_info);
  297|    137|	LOG_TEST_GOTO_ERR(card->ctx, r, "on-card EC key generation failed");
  ------------------
  |  |  184|    137|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|    137|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|    137|	int _ret = (r); \
  |  |  |  |  178|    137|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 133, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  179|    133|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    133|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  180|    133|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|    133|		goto err; \
  |  |  |  |  182|    133|	} \
  |  |  |  |  183|    137|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 4]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  298|       |
  299|      4|	pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      4|#define SC_ALGORITHM_RSA		0
  ------------------
  300|      4|	sc_log(ctx, "Set output modulus info");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  301|      4|	pubkey->u.rsa.modulus.len = BYTES4BITS(key_info.u.rsa.modulus_len);
  ------------------
  |  |  146|      4|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  302|      4|	pubkey->u.rsa.modulus.data = calloc(1, pubkey->u.rsa.modulus.len);
  303|      4|	if (pubkey->u.rsa.modulus.data == NULL)
  ------------------
  |  Branch (303:6): [True: 0, False: 4]
  ------------------
  304|      0|		goto err;
  305|      4|	memcpy(pubkey->u.rsa.modulus.data, key_info.u.rsa.modulus, BYTES4BITS(key_info.u.rsa.modulus_len));
  ------------------
  |  |  146|      4|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  306|       |
  307|      4|	sc_log(ctx, "Set output exponent info");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  308|      4|	pubkey->u.rsa.exponent.len = BYTES4BITS(key_info.u.rsa.exponent_len);
  ------------------
  |  |  146|      4|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  309|      4|	pubkey->u.rsa.exponent.data = calloc(1, pubkey->u.rsa.exponent.len);
  310|      4|	if (pubkey->u.rsa.exponent.data == NULL)
  ------------------
  |  Branch (310:6): [True: 0, False: 4]
  ------------------
  311|      0|		goto err;
  312|      4|	memcpy(pubkey->u.rsa.exponent.data, key_info.u.rsa.exponent, pubkey->u.rsa.exponent.len);
  313|       |
  314|    137|err:
  315|    137|	free(key_info.u.rsa.modulus);
  316|    137|	key_info.u.rsa.modulus = NULL;
  317|    137|	free(key_info.u.rsa.exponent);
  318|    137|	key_info.u.rsa.exponent = NULL;
  319|    137|	free(key_info.data);
  320|    137|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    137|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    137|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    137|	int _ret = r; \
  |  |  |  |  155|    137|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 137, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    137|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    133|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 133, False: 4]
  |  |  |  |  ------------------
  |  |  |  |  157|    137|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    137|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    137|	return _ret; \
  |  |  |  |  163|    137|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  321|    137|}
pkcs15-openpgp.c:openpgp_generate_key_ec:
  333|     14|{
  334|     14|	sc_context_t *ctx = card->ctx;
  335|     14|	sc_cardctl_openpgp_key_gen_store_info_t key_info;
  336|     14|	sc_pkcs15_prkey_info_t *required = (sc_pkcs15_prkey_info_t *)obj->data;
  337|     14|	sc_pkcs15_id_t *kid = &(required->id);
  338|     14|	struct sc_ec_parameters *info_ec =
  339|     14|			(struct sc_ec_parameters *)required->params.data;
  340|     14|	int r;
  341|       |
  342|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  343|     14|	memset(&key_info, 0, sizeof(key_info));
  344|       |
  345|     14|	sc_log(ctx, "Key ID to be generated: %s", sc_dump_hex(kid->value, kid->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__
  |  |  ------------------
  ------------------
  346|       |
  347|       |	/* Accept KeyID = 45, which is default value set by pkcs15init */
  348|     14|	if (kid->len == 1 && kid->value[0] == 0x45) {
  ------------------
  |  Branch (348:6): [True: 14, False: 0]
  |  Branch (348:23): [True: 14, False: 0]
  ------------------
  349|       |		/* Default key is authentication key. We choose this because the common use
  350|       |		 * is to generate from PKCS#11 (Firefox/Thunderbird) */
  351|     14|		sc_log(ctx, "Authentication key is to be generated.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  352|     14|		key_info.key_id = 3;
  353|     14|	}
  354|     14|	if (!key_info.key_id && (kid->len > 1 || kid->value[0] > 3)) {
  ------------------
  |  Branch (354:6): [True: 0, False: 14]
  |  Branch (354:27): [True: 0, False: 0]
  |  Branch (354:43): [True: 0, False: 0]
  ------------------
  355|      0|		sc_log(ctx, "Key ID must be 1, 2 or 3!");
  ------------------
  |  |   71|      0|#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|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  357|      0|	}
  358|       |
  359|     14|	if (!key_info.key_id)
  ------------------
  |  Branch (359:6): [True: 0, False: 14]
  ------------------
  360|      0|		key_info.key_id = kid->value[0];
  361|     14|	key_info.key_type = pubkey->algorithm;
  362|       |	/* set algorithm id based on key reference and key type */
  363|     14|	switch (pubkey->algorithm) {
  ------------------
  |  Branch (363:10): [True: 14, False: 0]
  ------------------
  364|       |		/* EC is in 04||x||y format
  365|       |		 * (field_length + 7)/8 * 2 + 1 in bytes
  366|       |		 * len is ecpoint length + format byte
  367|       |		 * see section 7.2.14 of 3.3.1 specs
  368|       |		 * EDDSA and XEDDSA have no format byte and one number
  369|       |		 * (field_length + 7)/8 in bytes
  370|       |		 */
  371|       |
  372|     14|	case SC_ALGORITHM_EC:
  ------------------
  |  |   79|     14|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (372:2): [True: 14, False: 0]
  ------------------
  373|     14|		key_info.algorithm = (key_info.key_id == SC_OPENPGP_KEY_ENCR)
  ------------------
  |  |  866|     14|#define SC_OPENPGP_KEY_ENCR		2
  ------------------
  |  Branch (373:24): [True: 0, False: 14]
  ------------------
  374|     14|						     ? SC_OPENPGP_KEYALGO_ECDH	 /* ECDH for slot 2 only */
  ------------------
  |  |  870|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  375|     14|						     : SC_OPENPGP_KEYALGO_ECDSA; /* ECDSA for slot 1 and 3 */
  ------------------
  |  |  871|     28|#define	SC_OPENPGP_KEYALGO_ECDSA	0x13
  ------------------
  376|     14|		key_info.u.ec.ecpointQ_len = 1 + 2 * BYTES4BITS(required->field_length);
  ------------------
  |  |  146|     14|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  377|     14|		break;
  378|      0|	case SC_ALGORITHM_EDDSA:
  ------------------
  |  |   81|      0|#define SC_ALGORITHM_EDDSA		4
  ------------------
  |  Branch (378:2): [True: 0, False: 14]
  ------------------
  379|      0|		key_info.algorithm = SC_OPENPGP_KEYALGO_EDDSA; /* only sign */
  ------------------
  |  |  872|      0|#define	SC_OPENPGP_KEYALGO_EDDSA	0x16
  ------------------
  380|      0|		key_info.u.ec.ecpointQ_len = BYTES4BITS(required->field_length);
  ------------------
  |  |  146|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  381|      0|		break;
  382|      0|	case SC_ALGORITHM_XEDDSA:
  ------------------
  |  |   82|      0|#define SC_ALGORITHM_XEDDSA		5
  ------------------
  |  Branch (382:2): [True: 0, False: 14]
  ------------------
  383|       |		/* TODO  may need to look at MSE, and how sign XEDDSA certificate */
  384|      0|		key_info.algorithm = SC_OPENPGP_KEYALGO_ECDH; /* but could be used to sign too */
  ------------------
  |  |  870|      0|#define	SC_OPENPGP_KEYALGO_ECDH		0x12
  ------------------
  385|      0|		key_info.u.ec.ecpointQ_len = BYTES4BITS(required->field_length);
  ------------------
  |  |  146|      0|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  386|      0|		break;
  387|     14|	}
  388|       |
  389|       |	/* copying info_ec.id works for any EC ECDH EdDSA keys */
  390|     14|	if (info_ec->der.len > 2 && info_ec->der.len == (size_t)(info_ec->der.value[1] + 2))
  ------------------
  |  Branch (390:6): [True: 14, False: 0]
  |  Branch (390:30): [True: 14, False: 0]
  ------------------
  391|     14|		key_info.u.ec.oidv_len = info_ec->der.value[1];
  392|      0|	else
  393|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  394|       |
  395|    126|	for (size_t i = 0; (i < key_info.u.ec.oidv_len) && (i + 2 < info_ec->der.len); i++) {
  ------------------
  |  Branch (395:21): [True: 112, False: 14]
  |  Branch (395:53): [True: 112, False: 0]
  ------------------
  396|    112|		key_info.u.ec.oidv.value[i] = info_ec->der.value[i + 2];
  397|    112|	}
  398|     14|	key_info.u.ec.oidv.value[key_info.data_len] = -1;
  399|       |
  400|       |	/* copy  id also */
  401|     14|	key_info.u.ec.oid = info_ec->id;
  402|       |
  403|       |	/* generate key on card */
  404|     14|	r = sc_card_ctl(card, SC_CARDCTL_OPENPGP_GENERATE_KEY, &key_info);
  405|     14|	LOG_TEST_GOTO_ERR(card->ctx, r, "on-card EC key generation failed");
  ------------------
  |  |  184|     14|#define LOG_TEST_GOTO_ERR(ctx, r, text) SC_TEST_GOTO_ERR((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  176|     14|#define SC_TEST_GOTO_ERR(ctx, level, r, text) do { \
  |  |  |  |  177|     14|	int _ret = (r); \
  |  |  |  |  178|     14|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (178:6): [True: 14, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  179|     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
  |  |  |  |  ------------------
  |  |  |  |  180|     14|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  181|     14|		goto err; \
  |  |  |  |  182|     14|	} \
  |  |  |  |  183|     14|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (183:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  406|       |
  407|       |	/* set pubkey according to response of card */
  408|      0|	sc_log(ctx, "Set output ecpoint info");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  409|       |
  410|      0|	pubkey->algorithm = key_info.key_type;
  411|      0|	pubkey->u.ec.ecpointQ.len = key_info.u.ec.ecpointQ_len;
  412|      0|	pubkey->u.ec.ecpointQ.value = malloc(key_info.u.ec.ecpointQ_len);
  413|      0|	if (pubkey->u.ec.ecpointQ.value == NULL) {
  ------------------
  |  Branch (413:6): [True: 0, False: 0]
  ------------------
  414|      0|		r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|      0|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  415|      0|		goto err;
  416|      0|	}
  417|       |
  418|      0|	memcpy(pubkey->u.ec.ecpointQ.value, key_info.u.ec.ecpointQ, key_info.u.ec.ecpointQ_len);
  419|       |
  420|     14|err:
  421|     14|	free(key_info.u.ec.ecpointQ);
  422|     14|	free(key_info.data);
  423|       |
  424|     14|	LOG_FUNC_RETURN(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|     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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  425|     14|}
pkcs15-openpgp.c:openpgp_emu_update_any_df:
  475|      5|{
  476|      5|	LOG_FUNC_CALLED(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  477|       |	/* After storing object, pkcs15init will call this function to update DF.
  478|       |	 * But OpenPGP has no other DF than OpenPGP-Application, so we do nothing. */
  479|      5|	LOG_FUNC_RETURN(p15card->card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  480|      5|}
pkcs15-openpgp.c:openpgp_emu_update_tokeninfo:
  484|      2|{
  485|      2|	LOG_FUNC_CALLED(p15card->card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  486|       |	/* When unbinding pkcs15init, this function will be called.
  487|       |	 * But for OpenPGP, token info does not need to change, we do nothing. */
  488|      2|	LOG_FUNC_RETURN(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  489|      2|}
pkcs15-openpgp.c:openpgp_store_data:
  494|    175|{
  495|    175|	sc_card_t *card = p15card->card;
  496|    175|	sc_context_t *ctx = card->ctx;
  497|    175|	sc_file_t *file = NULL;
  498|    175|	sc_pkcs15_cert_info_t *cinfo;
  499|    175|	sc_pkcs15_id_t *cid;
  500|    175|	sc_pkcs15_data_info_t *dinfo;
  501|    175|	u8 buf[254];
  502|    175|	int r;
  503|       |
  504|    175|	LOG_FUNC_CALLED(card->ctx);
  ------------------
  |  |  151|    175|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    175|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    175|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    175|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 175]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  505|       |
  506|    175|	switch (obj->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    175|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  507|      3|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      3|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (507:2): [True: 3, False: 172]
  ------------------
  508|      6|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      6|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (508:2): [True: 3, False: 172]
  ------------------
  509|       |		/* For these two type, store_data just don't need to do anything.
  510|       |		 * All have been done already before this function is called */
  511|      6|		r = SC_SUCCESS;
  ------------------
  |  |   28|      6|#define SC_SUCCESS				0
  ------------------
  512|      6|		break;
  513|       |
  514|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (514:2): [True: 0, False: 175]
  ------------------
  515|      0|		cinfo = (sc_pkcs15_cert_info_t *) obj->data;
  516|      0|		cid = &(cinfo->id);
  517|      0|		unsigned int tag = 0x7F21;
  518|       |
  519|      0|		if (cid->len != 1) {
  ------------------
  |  Branch (519:7): [True: 0, False: 0]
  ------------------
  520|      0|			sc_log(card->ctx, "ID=%s is not valid.", sc_dump_hex(cid->value, cid->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__
  |  |  ------------------
  ------------------
  521|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  522|      0|		}
  523|       |
  524|       |		/* OpenPGP card v.2 contains only 1 certificate */
  525|      0|		if (cid->value[0] != 3 && p15card->card->type < SC_CARD_TYPE_OPENPGP_V3) {
  ------------------
  |  Branch (525:7): [True: 0, False: 0]
  |  Branch (525:29): [True: 0, False: 0]
  ------------------
  526|      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__
  |  |  ------------------
  ------------------
  527|      0|			       "This version does not support certificate ID = %d (only ID=3 is supported).",
  528|      0|			       cid->value[0]);
  529|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  530|      0|		}
  531|       |
  532|       |		/* OpenPGP card < v.3 does not support SELECT DATA calls */
  533|      0|		if (p15card->card->type >= SC_CARD_TYPE_OPENPGP_V3) {
  ------------------
  |  Branch (533:7): [True: 0, False: 0]
  ------------------
  534|       |			/* Mapping [3..1] passed --id to [0..2] for param */
  535|      0|			u8 param = (u8) (2 - (cid->value[0] - 1));
  536|       |			/* check for unsigned underflow */
  537|      0|			if (param > 2) {
  ------------------
  |  Branch (537:8): [True: 0, False: 0]
  ------------------
  538|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  539|      0|			}
  540|       |
  541|       |			/* Just update the certificate DO */
  542|      0|			r = sc_card_ctl(card, SC_CARDCTL_OPENPGP_SELECT_DATA, &param);
  543|      0|			LOG_TEST_RET(card->ctx, r, "Failed OpenPGP - select 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  544|      0|		}
  545|       |
  546|      0|		sc_format_path("7F21", path);
  547|      0|		r = sc_select_file(card, path, &file);
  548|       |
  549|      0|		LOG_TEST_RET(card->ctx, r, "Cannot select cert 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  550|      0|		r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  551|      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__
  |  |  ------------------
  ------------------
  552|      0|		       "Data to write is %"SC_FORMAT_LEN_SIZE_T"u long",
  553|      0|		       content->len);
  554|      0|		if (r >= 0 && content->len)
  ------------------
  |  Branch (554:7): [True: 0, False: 0]
  |  Branch (554:17): [True: 0, False: 0]
  ------------------
  555|      0|			r = sc_put_data(p15card->card, tag, (const unsigned char *) content->value, content->len);
  556|      0|		break;
  557|       |
  558|    169|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|    169|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (558:2): [True: 169, False: 6]
  ------------------
  559|    169|		dinfo = (sc_pkcs15_data_info_t *) obj->data;
  560|       |		/* dinfo->app_label contains filename */
  561|    169|		sc_log(ctx, "===== App label %s", dinfo->app_label);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  562|       |		/* Currently, we only support DO 0101. The reason is that when initializing this
  563|       |		 * pkcs15 emulation, PIN authentication is not applied and we can expose only this DO,
  564|       |		 * which is "read always".
  565|       |		 * If we support other DOs, they will not be exposed, and not helpful to user.
  566|       |		 * I haven't found a way to refresh the list of exposed DOs after verifying PIN yet.
  567|       |		 * http://sourceforge.net/mailarchive/message.php?msg_id=30646373
  568|       |		 **/
  569|    169|		sc_log(ctx, "About to write to DO 0101");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  570|    169|		sc_format_path("0101", path);
  571|    169|		r = sc_select_file(card, path, &file);
  572|    169|		LOG_TEST_RET(card->ctx, r, "Cannot select private DO");
  ------------------
  |  |  174|    169|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    169|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    169|	int _ret = (r); \
  |  |  |  |  168|    169|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 169]
  |  |  |  |  ------------------
  |  |  |  |  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|    169|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 169]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  573|    169|		r = sc_read_binary(card, 0, buf, sizeof(buf), 0);
  574|    169|		if (r < 0) {
  ------------------
  |  Branch (574:7): [True: 134, False: 35]
  ------------------
  575|    134|			sc_log(ctx, "Cannot read DO 0101");
  ------------------
  |  |   71|    134|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  576|    134|			break;
  577|    134|		}
  578|     35|		if (r > 0) {
  ------------------
  |  Branch (578:7): [True: 14, False: 21]
  ------------------
  579|     14|			sc_log(ctx, "DO 0101 is full.");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  580|     14|			r = SC_ERROR_NOT_ENOUGH_MEMORY;
  ------------------
  |  |   67|     14|#define SC_ERROR_NOT_ENOUGH_MEMORY		-1217
  ------------------
  581|     14|			break;
  582|     14|		}
  583|     21|		r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     21|#define SC_AC_OP_UPDATE			23
  ------------------
  584|     21|		if (r >= 0 && content->len) {
  ------------------
  |  Branch (584:7): [True: 13, False: 8]
  |  Branch (584:17): [True: 13, False: 0]
  ------------------
  585|     13|			r = sc_update_binary(p15card->card, 0,
  586|     13|			                     (const unsigned char *) content->value,
  587|     13|			                     content->len, 0);
  588|     13|		}
  589|     21|		break;
  590|       |
  591|      0|	default:
  ------------------
  |  Branch (591:2): [True: 0, False: 175]
  ------------------
  592|      0|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  593|    175|	}
  594|       |
  595|    175|	sc_file_free(file);
  596|    175|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    175|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    175|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    175|	int _ret = r; \
  |  |  |  |  155|    175|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 172, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  156|    172|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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: 6]
  |  |  |  |  ------------------
  |  |  |  |  157|    172|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    172|	} 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|    175|	return _ret; \
  |  |  |  |  163|    175|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  597|    175|}

sc_pkcs15init_get_rtecp_ops:
  714|     12|{
  715|     12|	return &sc_pkcs15init_rtecp_operations;
  716|     12|}
pkcs15-rtecp.c:rtecp_erase:
   41|     10|{
   42|     10|	int r;
   43|       |
   44|     10|	if (!profile || !p15card || !p15card->card)
  ------------------
  |  Branch (44:6): [True: 0, False: 10]
  |  Branch (44:18): [True: 0, False: 10]
  |  Branch (44:30): [True: 0, False: 10]
  ------------------
   45|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   46|     10|	r = sc_card_ctl(p15card->card, SC_CARDCTL_RTECP_INIT, NULL);
   47|     10|	if (r == SC_SUCCESS)
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
  |  Branch (47:6): [True: 3, False: 7]
  ------------------
   48|      3|		sc_free_apps(p15card->card);
   49|     10|	return r;
   50|     10|}
pkcs15-rtecp.c:rtecp_select_pin_reference:
  150|     10|{
  151|     10|	int pin_ref;
  152|       |
  153|     10|	if (!profile || !p15card || !p15card->card || !p15card->card->ctx || !auth_info)
  ------------------
  |  Branch (153:6): [True: 0, False: 10]
  |  Branch (153:18): [True: 0, False: 10]
  |  Branch (153:30): [True: 0, False: 10]
  |  Branch (153:48): [True: 0, False: 10]
  |  Branch (153:71): [True: 0, False: 10]
  ------------------
  154|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  155|       |
  156|     10|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     10|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (156:6): [True: 0, False: 10]
  ------------------
  157|      0|	                return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  158|       |
  159|     10|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|     10|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (159:6): [True: 0, False: 10]
  ------------------
  160|      0|		pin_ref = RTECP_SO_PIN_REF;
  ------------------
  |  |   34|      0|#define RTECP_SO_PIN_REF        1
  ------------------
  161|     10|	else
  162|     10|		pin_ref = RTECP_USER_PIN_REF;
  ------------------
  |  |   35|     10|#define RTECP_USER_PIN_REF      2
  ------------------
  163|     10|	if (auth_info->attrs.pin.reference != pin_ref)
  ------------------
  |  Branch (163:6): [True: 10, False: 0]
  ------------------
  164|     10|		LOG_FUNC_RETURN(p15card->card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  165|       |
  166|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  167|     10|}
pkcs15-rtecp.c:rtecp_select_key_reference:
  267|     10|{
  268|     10|	sc_file_t *df;
  269|     10|	int r;
  270|       |
  271|     10|	if (!profile || !p15card || !p15card->card || !p15card->card->ctx || !key_info)
  ------------------
  |  Branch (271:6): [True: 0, False: 10]
  |  Branch (271:18): [True: 0, False: 10]
  |  Branch (271:30): [True: 0, False: 10]
  |  Branch (271:48): [True: 0, False: 10]
  |  Branch (271:71): [True: 0, False: 10]
  ------------------
  272|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  273|       |
  274|     10|	if (key_info->key_reference <= 0)
  ------------------
  |  Branch (274:6): [True: 10, False: 0]
  ------------------
  275|     10|		key_info->key_reference = 1;
  276|      0|	else if (key_info->key_reference > 0xFF)
  ------------------
  |  Branch (276:11): [True: 0, False: 0]
  ------------------
  277|      0|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  278|       |
  279|     10|	r = sc_profile_get_file(profile, "PrKey-DF", &df);
  280|     10|	LOG_TEST_RET(p15card->card->ctx, r, "Get PrKey-DF info 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  281|      0|	if (!df)
  ------------------
  |  Branch (281:6): [True: 0, False: 0]
  ------------------
  282|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  283|      0|	key_info->path = df->path;
  284|      0|	sc_file_free(df);
  285|      0|	r = sc_append_file_id(&key_info->path, key_info->key_reference);
  286|      0|	return r;
  287|      0|}
pkcs15-rtecp.c:rtecp_finalize:
  644|     10|{
  645|     10|	if (!card)
  ------------------
  |  Branch (645:6): [True: 0, False: 10]
  ------------------
  646|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  647|     10|	return sc_card_ctl(card, SC_CARDCTL_RTECP_INIT_END, NULL);
  648|     10|}

sc_pkcs15init_get_rutoken_ops:
  324|     12|{
  325|     12|	return &sc_pkcs15init_rutoken_operations;
  326|     12|}
pkcs15-rutoken.c:rutoken_create_dir:
   74|      4|{
   75|      4|	if (!profile || !p15card || !p15card->card || !p15card->card->ctx || !df)
  ------------------
  |  Branch (75:6): [True: 0, False: 4]
  |  Branch (75:18): [True: 0, False: 4]
  |  Branch (75:30): [True: 0, False: 4]
  |  Branch (75:48): [True: 0, False: 4]
  |  Branch (75:71): [True: 0, False: 4]
  ------------------
   76|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   77|      4|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   78|      4|	return sc_pkcs15init_create_file(profile, p15card, df);
   79|      4|}
pkcs15-rutoken.c:rutoken_select_pin_reference:
   87|      4|{
   88|      4|	int pin_ref;
   89|      4|	unsigned int so_pin_flag;
   90|       |
   91|      4|	if (!profile || !p15card || !p15card->card || !p15card->card->ctx || !auth_info)
  ------------------
  |  Branch (91:6): [True: 0, False: 4]
  |  Branch (91:18): [True: 0, False: 4]
  |  Branch (91:30): [True: 0, False: 4]
  |  Branch (91:48): [True: 0, False: 4]
  |  Branch (91:71): [True: 0, False: 4]
  ------------------
   92|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
   93|       |
   94|      4|	SC_FUNC_CALLED(p15card->card->ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
   95|       |
   96|      4|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      4|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (96:6): [True: 0, False: 4]
  ------------------
   97|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
   98|       |
   99|      4|	pin_ref = auth_info->attrs.pin.reference;
  100|      4|	so_pin_flag = auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN;
  ------------------
  |  |   61|      4|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  101|       |
  102|      4|	sc_log(p15card->card->ctx,  "PIN reference %i%s\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__
  |  |  ------------------
  |  |  |  Branch (71:122): [True: 0, False: 4]
  |  |  ------------------
  ------------------
  103|      4|			pin_ref, so_pin_flag ? " SO PIN flag" : "");
  104|       |
  105|      4|	if ((pin_ref == SC_RUTOKEN_DEF_ID_GCHV_ADMIN && so_pin_flag)
  ------------------
  |  |  580|      8|#define SC_RUTOKEN_DEF_ID_GCHV_ADMIN       0x01      /*  ID DO ADMIN  */
  ------------------
  |  Branch (105:7): [True: 0, False: 4]
  |  Branch (105:50): [True: 0, False: 0]
  ------------------
  106|      4|			|| (pin_ref == SC_RUTOKEN_DEF_ID_GCHV_USER && !so_pin_flag)
  ------------------
  |  |  581|      8|#define SC_RUTOKEN_DEF_ID_GCHV_USER        0x02      /*  ID DO USER  */
  ------------------
  |  Branch (106:8): [True: 4, False: 0]
  |  Branch (106:50): [True: 4, False: 0]
  ------------------
  107|      4|	)
  108|      4|		return SC_SUCCESS;
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  109|      0|	else
  110|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  111|      4|}

sc_pkcs15init_get_sc_hsm_ops:
  644|    195|{
  645|    195|	return &sc_pkcs15init_sc_hsm_operations;
  646|    195|}
pkcs15-sc-hsm.c:sc_hsm_create_key:
  114|    683|{
  115|       |	// Keys are automatically generated in GENERATE ASYMMETRIC KEY PAIR command
  116|    683|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    683|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  117|    683|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    683|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    683|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    683|	int _ret = r; \
  |  |  |  |  155|    683|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 683, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    683|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 683]
  |  |  |  |  ------------------
  |  |  |  |  157|    683|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    683|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    683|	return _ret; \
  |  |  |  |  163|    683|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  118|    683|}
pkcs15-sc-hsm.c:sc_hsm_store_key:
  124|    411|{
  125|    411|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    411|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    411|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    411|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    411|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 411]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  126|    411|	LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_SUPPORTED);
  ------------------
  |  |  164|    411|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    411|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    411|	int _ret = r; \
  |  |  |  |  155|    411|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 411, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    411|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    411|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 411, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    411|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    411|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    411|	return _ret; \
  |  |  |  |  163|    411|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  127|    411|}
pkcs15-sc-hsm.c:sc_hsm_generate_key:
  249|    272|{
  250|    272|	struct sc_card *card = p15card->card;
  251|    272|	sc_hsm_private_data_t *priv = (sc_hsm_private_data_t *) card->drv_data;
  252|    272|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  253|    272|	sc_cardctl_sc_hsm_keygen_info_t sc_hsm_keyinfo;
  254|    272|	sc_cvc_t cvc;
  255|    272|	u8 *cvcbin, *cvcpo;
  256|    272|	unsigned int cla,tag;
  257|    272|	size_t taglen, cvclen;
  258|    272|	int r;
  259|       |
  260|    272|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    272|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    272|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    272|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    272|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 272]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  261|       |
  262|    272|	key_info->key_reference = sc_hsm_determine_free_id(p15card, KEY_PREFIX);
  ------------------
  |  |   33|    272|#define KEY_PREFIX				0xCC		/* Hi byte in file identifier for key objects */
  ------------------
  263|    272|	LOG_TEST_RET(card->ctx, key_info->key_reference, "Could not determine key reference");
  ------------------
  |  |  174|    272|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    272|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    272|	int _ret = (r); \
  |  |  |  |  168|    272|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 14, False: 258]
  |  |  |  |  ------------------
  |  |  |  |  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|    272|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  264|       |
  265|    258|	memset(&cvc, 0, sizeof(cvc));
  266|       |
  267|    258|	strlcpy(cvc.car, "UTCA00001", sizeof cvc.car);
  ------------------
  |  |   43|    258|#define strlcpy _strlcpy
  ------------------
  268|    258|	cvc.carLen = strlen(cvc.car);
  269|    258|	if (priv->serialno)
  ------------------
  |  Branch (269:6): [True: 0, False: 258]
  ------------------
  270|      0|		strlcpy(cvc.chr, priv->serialno, sizeof cvc.chr);
  ------------------
  |  |   43|      0|#define strlcpy _strlcpy
  ------------------
  271|    258|	strlcat(cvc.chr, "00001", sizeof cvc.chr);
  272|    258|	cvc.chrLen = strlen(cvc.chr);
  273|       |
  274|    258|	switch(object->type) {
  275|    128|	case SC_PKCS15_TYPE_PRKEY_RSA:
  ------------------
  |  |  419|    128|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (275:2): [True: 128, False: 130]
  ------------------
  276|    128|		r = sc_hsm_encode_gakp_rsa(p15card, &cvc, key_info->modulus_length);
  277|    128|		break;
  278|    130|	case SC_PKCS15_TYPE_PRKEY_EC:
  ------------------
  |  |  421|    130|#define SC_PKCS15_TYPE_PRKEY_EC		0x104
  ------------------
  |  Branch (278:2): [True: 130, False: 128]
  ------------------
  279|    130|		r = sc_hsm_encode_gakp_ec(p15card, &cvc, key_info);
  280|    130|		break;
  281|      0|	default:
  ------------------
  |  Branch (281:2): [True: 0, False: 258]
  ------------------
  282|      0|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  283|      0|		break;
  284|    258|	}
  285|    258|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|    258|#define SC_SUCCESS				0
  ------------------
  |  Branch (285:6): [True: 0, False: 258]
  ------------------
  286|      0|		sc_pkcs15emu_sc_hsm_free_cvc(&cvc);
  287|      0|		LOG_TEST_RET(p15card->card->ctx, r, "Could not encode GAKP cdata");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  288|      0|	}
  289|       |
  290|    258|	r = sc_pkcs15emu_sc_hsm_encode_cvc(p15card, &cvc, &cvcbin, &cvclen);
  291|    258|	sc_pkcs15emu_sc_hsm_free_cvc(&cvc);
  292|    258|	LOG_TEST_RET(p15card->card->ctx, r, "Could not encode GAKP cdata");
  ------------------
  |  |  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: 0, False: 258]
  |  |  |  |  ------------------
  |  |  |  |  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|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 258]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  293|       |
  294|       |
  295|    258|	cvcpo = cvcbin;
  296|    258|	sc_asn1_read_tag((const u8 **)&cvcpo, cvclen, &cla, &tag, &taglen);
  297|    258|	sc_asn1_read_tag((const u8 **)&cvcpo, cvclen, &cla, &tag, &taglen);
  298|       |
  299|    258|	sc_hsm_keyinfo.key_id = key_info->key_reference;
  300|    258|	sc_hsm_keyinfo.auth_key_id = 0;
  301|    258|	sc_hsm_keyinfo.gakprequest = cvcpo;
  302|    258|	sc_hsm_keyinfo.gakprequest_len = taglen;
  303|    258|	sc_hsm_keyinfo.gakpresponse = NULL;
  304|    258|	sc_hsm_keyinfo.gakpresponse_len = 0;
  305|       |
  306|    258|	r = sc_card_ctl(card, SC_CARDCTL_SC_HSM_GENERATE_KEY, &sc_hsm_keyinfo);
  307|    258|	if (r < 0)
  ------------------
  |  Branch (307:6): [True: 245, False: 13]
  ------------------
  308|    245|		goto out;
  309|       |
  310|       |
  311|     13|	cvcpo = sc_hsm_keyinfo.gakpresponse;
  312|     13|	cvclen = sc_hsm_keyinfo.gakpresponse_len;
  313|       |
  314|     13|	r = sc_pkcs15emu_sc_hsm_decode_cvc(p15card, (const u8 **)&cvcpo, &cvclen, &cvc);
  315|     13|	if (r < 0) {
  ------------------
  |  Branch (315:6): [True: 13, False: 0]
  ------------------
  316|     13|		sc_log(p15card->card->ctx, "Could not decode GAKP rdata");
  ------------------
  |  |   71|     13|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  317|     13|		r = SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|     13|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  318|     13|		goto out;
  319|     13|	}
  320|       |
  321|      0|	r = sc_hsm_update_ef(p15card, EE_CERTIFICATE_PREFIX, key_info->key_reference, 1, sc_hsm_keyinfo.gakpresponse, sc_hsm_keyinfo.gakpresponse_len);
  ------------------
  |  |   35|      0|#define EE_CERTIFICATE_PREFIX	0xCE		/* Hi byte in file identifier for EE certificates */
  ------------------
  322|      0|	if (r < 0) {
  ------------------
  |  Branch (322:6): [True: 0, False: 0]
  ------------------
  323|      0|		sc_log(p15card->card->ctx, "Could not save certificate signing request");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  324|      0|		goto out;
  325|      0|	}
  326|       |
  327|      0|	if (pubkey != NULL) {
  ------------------
  |  Branch (327:6): [True: 0, False: 0]
  ------------------
  328|      0|		r = sc_pkcs15emu_sc_hsm_get_public_key(p15card->card->ctx, &cvc, pubkey);
  329|      0|	}
  330|       |
  331|    258|	out:
  332|       |
  333|    258|	sc_pkcs15emu_sc_hsm_free_cvc(&cvc);
  334|       |
  335|    258|	if (cvcbin) {
  ------------------
  |  Branch (335:6): [True: 258, False: 0]
  ------------------
  336|    258|		free(cvcbin);
  337|    258|	}
  338|    258|	if (sc_hsm_keyinfo.gakpresponse) {
  ------------------
  |  Branch (338:6): [True: 13, False: 245]
  ------------------
  339|     13|		free(sc_hsm_keyinfo.gakpresponse);
  340|     13|	}
  341|    258|	LOG_FUNC_RETURN(p15card->card->ctx, r);
  ------------------
  |  |  164|    258|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    258|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    258|	int _ret = r; \
  |  |  |  |  155|    258|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 258, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    258|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    258|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 258, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|    258|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    258|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    258|	return _ret; \
  |  |  |  |  163|    258|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  342|    258|}
pkcs15-sc-hsm.c:sc_hsm_determine_free_id:
  132|    409|{
  133|    409|	struct sc_card *card = p15card->card;
  134|    409|	u8 filelist[MAX_EXT_APDU_LENGTH];
  135|    409|	int filelistlength, i, j;
  136|       |
  137|    409|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    409|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    409|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    409|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    409|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 409]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  138|       |
  139|    409|	filelistlength = sc_list_files(card, filelist, sizeof(filelist));
  140|    409|	LOG_TEST_RET(card->ctx, filelistlength, "Could not enumerate file and key identifier");
  ------------------
  |  |  174|    409|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    409|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    409|	int _ret = (r); \
  |  |  |  |  168|    409|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 0, False: 409]
  |  |  |  |  ------------------
  |  |  |  |  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|    409|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 409]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|       |
  142|  7.06k|	for (j = 0; j < 256; j++) {
  ------------------
  |  Branch (142:14): [True: 7.03k, False: 26]
  ------------------
  143|   406k|		for (i = 0; i + 1 < filelistlength; i += 2) {
  ------------------
  |  Branch (143:15): [True: 399k, False: 7.02k]
  ------------------
  144|   399k|			if ((filelist[i] == range) && (filelist[i + 1] == j)) {
  ------------------
  |  Branch (144:8): [True: 9.99k, False: 389k]
  |  Branch (144:34): [True: 16, False: 9.97k]
  ------------------
  145|     16|				break;
  146|     16|			}
  147|   399k|		}
  148|  7.03k|		if (i >= filelistlength) {
  ------------------
  |  Branch (148:7): [True: 383, False: 6.65k]
  ------------------
  149|    383|			LOG_FUNC_RETURN(p15card->card->ctx, j);
  ------------------
  |  |  164|    383|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    383|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    383|	int _ret = r; \
  |  |  |  |  155|    383|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 383, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    383|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 383]
  |  |  |  |  ------------------
  |  |  |  |  157|    383|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    383|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    383|	return _ret; \
  |  |  |  |  163|    383|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  150|    383|		}
  151|  7.03k|	}
  152|     26|	LOG_FUNC_RETURN(p15card->card->ctx, SC_ERROR_NOT_ENOUGH_MEMORY);
  ------------------
  |  |  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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  153|     26|}
pkcs15-sc-hsm.c:sc_hsm_encode_gakp_rsa:
  157|    128|static int sc_hsm_encode_gakp_rsa(struct sc_pkcs15_card *p15card, sc_cvc_t *cvc, size_t keysize) {
  158|    128|	struct sc_object_id rsa15withSHA256 = { { 0,4,0,127,0,7,2,2,2,1,2,-1 } };
  159|       |
  160|    128|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    128|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    128|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    128|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    128|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 128]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  161|       |
  162|    128|	cvc->coefficientAorExponentlen = sizeof(pubexp);
  163|    128|	cvc->coefficientAorExponent = malloc(sizeof(pubexp));
  164|    128|	if (!cvc->coefficientAorExponent) {
  ------------------
  |  Branch (164:6): [True: 0, False: 128]
  ------------------
  165|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  166|      0|	}
  167|    128|	memcpy(cvc->coefficientAorExponent, pubexp, sizeof(pubexp));
  168|       |
  169|    128|	cvc->pukoid = rsa15withSHA256;
  170|    128|	cvc->modulusSize = (int)keysize;
  171|       |
  172|    128|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  164|    128|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    128|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    128|	int _ret = r; \
  |  |  |  |  155|    128|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 128, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    128|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 128]
  |  |  |  |  ------------------
  |  |  |  |  157|    128|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    128|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    128|	return _ret; \
  |  |  |  |  163|    128|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  173|    128|}
pkcs15-sc-hsm.c:sc_hsm_encode_gakp_ec:
  177|    130|static int sc_hsm_encode_gakp_ec(struct sc_pkcs15_card *p15card, sc_cvc_t *cvc, struct sc_pkcs15_prkey_info *key_info) {
  178|    130|	struct sc_object_id ecdsaWithSHA256 = { { 0,4,0,127,0,7,2,2,2,2,3,-1 } };
  179|    130|	struct sc_ec_parameters *ecparams = (struct sc_ec_parameters *)key_info->params.data;
  180|    130|	struct ec_curve *curve = NULL;
  181|    130|	u8 *curveoid;
  182|    130|	int curveoidlen,r;
  183|       |
  184|    130|	LOG_FUNC_CALLED(p15card->card->ctx);
  ------------------
  |  |  151|    130|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    130|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    130|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    130|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 130]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  185|       |
  186|    130|	curveoid = ecparams->der.value;
  187|    130|	if ((ecparams->der.len < 3) || (*curveoid++ != 0x06)) {
  ------------------
  |  Branch (187:6): [True: 0, False: 130]
  |  Branch (187:33): [True: 0, False: 130]
  ------------------
  188|      0|		sc_log(p15card->card->ctx, "EC_PARAMS does not contain curve object identifier");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  189|      0|		LOG_FUNC_RETURN(p15card->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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  190|      0|	}
  191|       |
  192|    130|	curveoidlen = *curveoid++;
  193|       |
  194|    130|	r = sc_pkcs15emu_sc_hsm_get_curve(&curve, curveoid, curveoidlen);
  195|    130|	LOG_TEST_RET(p15card->card->ctx, r, "Unsupported named curve");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  196|       |
  197|    130|	cvc->primeOrModuluslen = curve->prime.len;
  198|    130|	cvc->primeOrModulus = malloc(cvc->primeOrModuluslen);
  199|    130|	if (!cvc->primeOrModulus) {
  ------------------
  |  Branch (199:6): [True: 0, False: 130]
  ------------------
  200|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  201|      0|	}
  202|    130|	memcpy(cvc->primeOrModulus, curve->prime.value, cvc->primeOrModuluslen);
  203|       |
  204|    130|	cvc->coefficientAorExponentlen = curve->coefficientA.len;
  205|    130|	cvc->coefficientAorExponent = malloc(cvc->coefficientAorExponentlen);
  206|    130|	if (!cvc->coefficientAorExponent) {
  ------------------
  |  Branch (206:6): [True: 0, False: 130]
  ------------------
  207|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  208|      0|	}
  209|    130|	memcpy(cvc->coefficientAorExponent, curve->coefficientA.value, cvc->coefficientAorExponentlen);
  210|       |
  211|    130|	cvc->coefficientBlen = curve->coefficientB.len;
  212|    130|	cvc->coefficientB = malloc(cvc->coefficientBlen);
  213|    130|	if (!cvc->coefficientB) {
  ------------------
  |  Branch (213:6): [True: 0, False: 130]
  ------------------
  214|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  215|      0|	}
  216|    130|	memcpy(cvc->coefficientB, curve->coefficientB.value, cvc->coefficientBlen);
  217|       |
  218|    130|	cvc->basePointGlen = curve->basePointG.len;
  219|    130|	cvc->basePointG = malloc(cvc->basePointGlen);
  220|    130|	if (!cvc->basePointG) {
  ------------------
  |  Branch (220:6): [True: 0, False: 130]
  ------------------
  221|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  222|      0|	}
  223|    130|	memcpy(cvc->basePointG, curve->basePointG.value, cvc->basePointGlen);
  224|       |
  225|    130|	cvc->orderlen = curve->order.len;
  226|    130|	cvc->order = malloc(cvc->orderlen);
  227|    130|	if (!cvc->order) {
  ------------------
  |  Branch (227:6): [True: 0, False: 130]
  ------------------
  228|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  229|      0|	}
  230|    130|	memcpy(cvc->order, curve->order.value, cvc->orderlen);
  231|       |
  232|    130|	cvc->cofactorlen = curve->coFactor.len;
  233|    130|	cvc->cofactor = malloc(cvc->cofactorlen);
  234|    130|	if (!cvc->cofactor) {
  ------------------
  |  Branch (234:6): [True: 0, False: 130]
  ------------------
  235|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  236|      0|	}
  237|    130|	memcpy(cvc->cofactor, curve->coFactor.value, cvc->cofactorlen);
  238|       |
  239|    130|	cvc->pukoid = ecdsaWithSHA256;
  240|       |
  241|    130|	LOG_FUNC_RETURN(p15card->card->ctx, SC_SUCCESS);
  ------------------
  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 130]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  242|    130|}
pkcs15-sc-hsm.c:sc_hsm_update_ef:
   74|    175|{
   75|    175|	sc_card_t *card = p15card->card;
   76|    175|	sc_file_t *file = NULL;
   77|    175|	sc_path_t path;
   78|    175|	u8 fid[2];
   79|    175|	int r;
   80|       |
   81|    175|	fid[0] = prefix;
   82|    175|	fid[1] = id;
   83|       |
   84|    175|	sc_path_set(&path, SC_PATH_TYPE_FILE_ID, fid, 2, 0, -1);
  ------------------
  |  |  117|    175|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
   85|       |
   86|    175|	r = sc_select_file(card, &path, NULL);
   87|       |
   88|    175|	if ((r == SC_SUCCESS) && erase) {
  ------------------
  |  |   28|    175|#define SC_SUCCESS				0
  ------------------
  |  Branch (88:6): [True: 2, False: 173]
  |  Branch (88:27): [True: 2, False: 0]
  ------------------
   89|      2|		r = sc_delete_file(card, &path);
   90|      2|		LOG_TEST_RET(card->ctx, r, "Could not delete file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
   91|      2|		r = SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      2|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
   92|      2|	}
   93|       |
   94|    175|	if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|    175|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (94:6): [True: 3, False: 172]
  ------------------
   95|      3|		file = sc_file_new();
   96|      3|		file->id = (path.value[0] << 8) | path.value[1];
   97|      3|		file->type = SC_FILE_TYPE_WORKING_EF;
  ------------------
  |  |  216|      3|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
   98|      3|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|      3|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
   99|      3|		file->size = (size_t) 0;
  100|      3|		file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|      3|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  101|      3|		r = sc_create_file(card, file);
  102|      3|		sc_file_free(file);
  103|      3|		LOG_TEST_RET(card->ctx, r, "Could not create file");
  ------------------
  |  |  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: 0, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  104|      3|	}
  105|       |
  106|    175|	r = sc_update_binary(card, 0, buf, buflen, 0);
  107|    175|	LOG_FUNC_RETURN(card->ctx, r);
  ------------------
  |  |  164|    175|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    175|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    175|	int _ret = r; \
  |  |  |  |  155|    175|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 175]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    175|	} else { \
  |  |  |  |  159|    175|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    175|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    175|	} \
  |  |  |  |  162|    175|	return _ret; \
  |  |  |  |  163|    175|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  108|    175|}
pkcs15-sc-hsm.c:sc_hsm_emu_update_any_df:
  570|     61|{
  571|     61|	struct sc_context *ctx = p15card->card->ctx;
  572|     61|	int rv = SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|     61|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  573|       |
  574|     61|	SC_FUNC_CALLED(ctx, 1);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  575|     61|	switch(op)   {
  ------------------
  |  Branch (575:9): [True: 61, False: 0]
  ------------------
  576|      0|	case SC_AC_OP_ERASE:
  ------------------
  |  |  202|      0|#define SC_AC_OP_ERASE			SC_AC_OP_DELETE
  |  |  ------------------
  |  |  |  |  168|      0|#define SC_AC_OP_DELETE			2
  |  |  ------------------
  ------------------
  |  Branch (576:2): [True: 0, False: 61]
  ------------------
  577|      0|		sc_log(ctx, "Update DF; erase object('%s',type:%X)", object->label, object->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__
  |  |  ------------------
  ------------------
  578|      0|		switch(object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (578:10): [True: 0, False: 0]
  ------------------
  579|      0|		case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (579:3): [True: 0, False: 0]
  ------------------
  580|      0|			rv = sc_hsm_delete_ef(p15card, PRKD_PREFIX, ((struct sc_pkcs15_prkey_info *)object->data)->key_reference);
  ------------------
  |  |   29|      0|#define PRKD_PREFIX				0xC4		/* Hi byte in file identifier for PKCS#15 PRKD objects */
  ------------------
  581|      0|			break;
  582|      0|		case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (582:3): [True: 0, False: 0]
  ------------------
  583|      0|			rv = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  584|      0|			break;
  585|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (585:3): [True: 0, False: 0]
  ------------------
  586|      0|			rv = sc_hsm_emu_delete_cd(profile, p15card, object);
  587|      0|			break;
  588|      0|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (588:3): [True: 0, False: 0]
  ------------------
  589|      0|			rv = sc_hsm_delete_ef(p15card, DCOD_PREFIX, ((struct sc_pkcs15_data_info *)object->data)->path.value[1]);
  ------------------
  |  |   31|      0|#define DCOD_PREFIX				0xC9		/* Hi byte in file identifier for PKCS#15 DCOD objects */
  ------------------
  590|      0|			break;
  591|      0|		}
  592|      0|		break;
  593|      0|	case SC_AC_OP_UPDATE:
  ------------------
  |  |  189|      0|#define SC_AC_OP_UPDATE			23
  ------------------
  |  Branch (593:2): [True: 0, False: 61]
  ------------------
  594|     61|	case SC_AC_OP_CREATE:
  ------------------
  |  |  169|     61|#define SC_AC_OP_CREATE			3
  ------------------
  |  Branch (594:2): [True: 61, False: 0]
  ------------------
  595|     61|		sc_log(ctx, "Update DF; create object('%s',type:%X)", object->label, object->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__
  |  |  ------------------
  ------------------
  596|     61|		switch(object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|     61|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  |  Branch (596:10): [True: 60, False: 1]
  ------------------
  597|      0|		case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (597:3): [True: 0, False: 61]
  ------------------
  598|      0|			rv = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  599|      0|			break;
  600|      0|		case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (600:3): [True: 0, False: 61]
  ------------------
  601|      0|			rv = sc_hsm_emu_update_prkd(profile, p15card, object);
  602|      0|			break;
  603|      0|		case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (603:3): [True: 0, False: 61]
  ------------------
  604|      0|			rv = sc_hsm_emu_update_cd(profile, p15card, object);
  605|      0|			break;
  606|     60|		case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|     60|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (606:3): [True: 60, False: 1]
  ------------------
  607|     60|			rv = sc_hsm_emu_update_dcod(profile, p15card, object);
  608|     60|			break;
  609|     61|		}
  610|     61|		break;
  611|     61|	}
  612|     61|	SC_FUNC_RETURN(ctx, 1, rv);
  ------------------
  |  |  153|     61|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  154|     61|	int _ret = r; \
  |  |  155|     61|	if (_ret <= 0) { \
  |  |  ------------------
  |  |  |  Branch (155:6): [True: 11, False: 50]
  |  |  ------------------
  |  |  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|     50|	} 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|     61|	return _ret; \
  |  |  163|     61|} while(0)
  |  |  ------------------
  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  ------------------
  ------------------
  613|     61|}
pkcs15-sc-hsm.c:sc_hsm_emu_update_dcod:
  512|     60|{
  513|     60|	struct sc_pkcs15_data_info *data_info = (struct sc_pkcs15_data_info *) object->data;
  514|     60|	u8 *buf;
  515|     60|	size_t buflen;
  516|     60|	int r;
  517|       |
  518|     60|	r = sc_pkcs15_encode_dodf_entry(p15card->card->ctx, object, &buf, &buflen);
  519|     60|	LOG_TEST_RET(p15card->card->ctx, r, "Error encoding DCOD entry");
  ------------------
  |  |  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: 10, False: 50]
  |  |  |  |  ------------------
  |  |  |  |  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|     60|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 50]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  520|       |
  521|     50|	r = sc_hsm_update_ef(p15card, DCOD_PREFIX, data_info->path.value[data_info->path.len - 1], 0, buf, buflen);
  ------------------
  |  |   31|     50|#define DCOD_PREFIX				0xC9		/* Hi byte in file identifier for PKCS#15 DCOD objects */
  ------------------
  522|     50|	free(buf);
  523|     50|	return r;
  524|     60|}
pkcs15-sc-hsm.c:sc_hsm_emu_store_data:
  431|    137|{
  432|    137|	struct sc_context *ctx = p15card->card->ctx;
  433|    137|	int r;
  434|       |
  435|    137|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|    137|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|    137|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|    137|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|    137|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 137]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  436|       |
  437|    137|	switch (object->type & SC_PKCS15_TYPE_CLASS_MASK) {
  ------------------
  |  |  416|    137|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
  438|      0|	case SC_PKCS15_TYPE_PRKEY:
  ------------------
  |  |  418|      0|#define SC_PKCS15_TYPE_PRKEY			0x100
  ------------------
  |  Branch (438:2): [True: 0, False: 137]
  ------------------
  439|      0|	case SC_PKCS15_TYPE_PUBKEY:
  ------------------
  |  |  425|      0|#define SC_PKCS15_TYPE_PUBKEY			0x200
  ------------------
  |  Branch (439:2): [True: 0, False: 137]
  ------------------
  440|      0|		r = SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  441|      0|		break;
  442|      0|	case SC_PKCS15_TYPE_CERT:
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (442:2): [True: 0, False: 137]
  ------------------
  443|      0|		r = sc_hsm_emu_store_cert(p15card, profile, object, data);
  444|      0|		break;
  445|    137|	case SC_PKCS15_TYPE_DATA_OBJECT:
  ------------------
  |  |  442|    137|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (445:2): [True: 137, False: 0]
  ------------------
  446|    137|		r = sc_hsm_emu_store_binary(p15card, profile, object, data);
  447|    137|		break;
  448|      0|	default:
  ------------------
  |  Branch (448:2): [True: 0, False: 137]
  ------------------
  449|      0|		r = SC_ERROR_NOT_IMPLEMENTED;
  ------------------
  |  |   97|      0|#define SC_ERROR_NOT_IMPLEMENTED		-1416
  ------------------
  450|      0|		break;
  451|    137|	}
  452|       |
  453|    137|	LOG_FUNC_RETURN(ctx, r);
  ------------------
  |  |  164|    137|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    137|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    137|	int _ret = r; \
  |  |  |  |  155|    137|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 12, False: 125]
  |  |  |  |  ------------------
  |  |  |  |  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|    125|	} else { \
  |  |  |  |  159|    125|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|    125|			"returning with: %d\n", _ret); \
  |  |  |  |  161|    125|	} \
  |  |  |  |  162|    137|	return _ret; \
  |  |  |  |  163|    137|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  454|    137|}
pkcs15-sc-hsm.c:sc_hsm_emu_store_binary:
  402|    137|{
  403|    137|	struct sc_pkcs15_data_info *data_info = (struct sc_pkcs15_data_info *) object->data;
  404|    137|	sc_path_t path;
  405|    137|	u8 id[2];
  406|    137|	int r;
  407|       |
  408|    137|	r = sc_hsm_determine_free_id(p15card, DCOD_PREFIX);
  ------------------
  |  |   31|    137|#define DCOD_PREFIX				0xC9		/* Hi byte in file identifier for PKCS#15 DCOD objects */
  ------------------
  409|    137|	LOG_TEST_RET(p15card->card->ctx, r, "Out of identifier to store data description");
  ------------------
  |  |  174|    137|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    137|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    137|	int _ret = (r); \
  |  |  |  |  168|    137|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 12, False: 125]
  |  |  |  |  ------------------
  |  |  |  |  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|    137|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 125]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  410|       |
  411|    125|	if (object->flags & SC_PKCS15_CO_FLAG_PRIVATE) {
  ------------------
  |  |   50|    125|#define SC_PKCS15_CO_FLAG_PRIVATE	0x00000001
  ------------------
  |  Branch (411:6): [True: 0, False: 125]
  ------------------
  412|      0|		id[0] = PROT_DATA_PREFIX;
  ------------------
  |  |   34|      0|#define PROT_DATA_PREFIX		0xCD		/* Hi byte in file identifier for PIN protected data objects */
  ------------------
  413|    125|	} else {
  414|    125|		id[0] = DATA_PREFIX;
  ------------------
  |  |   36|    125|#define DATA_PREFIX				0xCF		/* Hi byte in file identifier for readable data objects */
  ------------------
  415|    125|	}
  416|    125|	id[1] = r;
  417|       |
  418|    125|	sc_path_set(&path, SC_PATH_TYPE_FILE_ID, id, 2, 0, -1);
  ------------------
  |  |  117|    125|#define SC_PATH_TYPE_FILE_ID		0
  ------------------
  419|    125|	data_info->path = path;
  420|       |
  421|    125|	r = sc_hsm_update_ef(p15card, id[0], id[1], 1, data->value, data->len);
  422|    125|	return r;
  423|    137|}

sc_pkcs15init_get_setcos_ops:
  634|    155|{
  635|    155|	return &sc_pkcs15init_setcos_operations;
  636|    155|}
pkcs15-setcos.c:setcos_erase_card:
   67|    130|{
   68|    130|	sc_path_t path;
   69|    130|	int r;
   70|       |
   71|       |	/* Just delete the entire MF */
   72|       |
   73|       |	/* Select parent DF and verify PINs/key as necessary */
   74|    130|	r = sc_pkcs15init_authenticate(profile, p15card, profile->mf_info->file, SC_AC_OP_DELETE);
  ------------------
  |  |  168|    130|#define SC_AC_OP_DELETE			2
  ------------------
   75|    130|	if (r < 0)
  ------------------
  |  Branch (75:6): [True: 121, False: 9]
  ------------------
   76|    121|		return r == SC_ERROR_FILE_NOT_FOUND ? 0 : r;
  ------------------
  |  |   51|    121|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (76:10): [True: 0, False: 121]
  ------------------
   77|       |
   78|       |	/* Empty path -> we have to to delete the current DF (= the MF) */
   79|      9|	memset(&path, 0, sizeof(sc_path_t));
   80|      9|	r = sc_delete_file(p15card->card, &path) ;
   81|      9|	if (r)
  ------------------
  |  Branch (81:6): [True: 8, False: 1]
  ------------------
   82|      8|		return r;
   83|       |
   84|      1|	sc_free_apps(p15card->card);
   85|      1|	return 0;
   86|      9|}
pkcs15-setcos.c:setcos_init_card:
   94|     20|{
   95|     20|	struct sc_context *ctx = p15card->card->ctx;
   96|     20|	sc_file_t *mf = profile->mf_info->file;
   97|     20|	sc_file_t *pinfile;
   98|     20|	int r;
   99|       |
  100|     20|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  101|       |
  102|       |	/* Create the MF if it doesn't exist yet */
  103|     20|	r = sc_select_file(p15card->card, &mf->path, NULL);
  104|     20|	if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|     20|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (104:6): [True: 18, False: 2]
  ------------------
  105|     18|		sc_log(ctx,  "MF doesn't exist, creating now");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  106|       |
  107|       |		/* Fix up the file's ACLs */
  108|     18|		r = sc_pkcs15init_fixup_file(profile, p15card, mf);
  109|     18|		LOG_TEST_RET(ctx, r, "MF fixup 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: 0, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  110|       |
  111|     18|		mf->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|     18|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  112|     18|		r = sc_create_file(p15card->card, mf);
  113|     18|		LOG_TEST_RET(ctx, r, "MF creation 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: 15, False: 3]
  |  |  |  |  ------------------
  |  |  |  |  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|     18|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 3]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  114|     18|	}
  115|      5|	LOG_TEST_RET(ctx, r, "Cannot select MF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  116|       |
  117|       |	/* Create the global pin file if it doesn't exist yet */
  118|      3|	r = sc_profile_get_file(profile, "pinfile", &pinfile);
  119|      3|	LOG_TEST_RET(ctx, r, "Cannot get 'pinfile' from profile");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  120|       |
  121|      0|	r = sc_select_file(p15card->card, &pinfile->path, NULL);
  122|      0|	if (r == SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (122:6): [True: 0, False: 0]
  ------------------
  123|      0|		sc_log(ctx,  "Global pin file doesn't exist, creating now");
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  124|       |
  125|       |		/* Fix up the file's ACLs */
  126|      0|		r = sc_pkcs15init_fixup_file(profile, p15card, pinfile);
  127|      0|		if (r < 0)
  ------------------
  |  Branch (127:7): [True: 0, False: 0]
  ------------------
  128|      0|			sc_file_free(pinfile);
  129|      0|		LOG_TEST_RET(ctx, r, "Pinfile fixup 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  130|       |
  131|       |		/* Set life cycle state to SC_FILE_STATUS_CREATION,
  132|       |		 * which means that all ACs are ignored. */
  133|      0|		pinfile->status = SC_FILE_STATUS_CREATION;
  ------------------
  |  |  240|      0|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  134|      0|		r = sc_create_file(p15card->card, pinfile);
  135|      0|		if (r < 0)
  ------------------
  |  Branch (135:7): [True: 0, False: 0]
  ------------------
  136|      0|			sc_file_free(pinfile);
  137|      0|		LOG_TEST_RET(ctx, r, "Pinfile creation 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  138|      0|	}
  139|      0|	sc_file_free(pinfile);
  140|      0|	LOG_TEST_RET(ctx, r, "Select pinfile 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  141|       |
  142|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  143|      0|}
pkcs15-setcos.c:setcos_select_pin_reference:
  172|    188|{
  173|    188|	sc_pkcs15_auth_info_t auth_info_prof = {0};
  174|       |
  175|    188|	auth_info_prof.attrs.pin.reference = 1; /* Default SO PIN ref. */
  176|    188|	auth_info_prof.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|    188|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  177|    188|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &auth_info_prof);
  ------------------
  |  |  169|    188|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  178|       |
  179|       |	/* For the SO pin, we take the first available pin reference = 1 */
  180|    188|	if (auth_info != NULL && auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|    188|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (180:6): [True: 188, False: 0]
  |  Branch (180:27): [True: 7, False: 181]
  ------------------
  181|      7|		auth_info->attrs.pin.reference = auth_info_prof.attrs.pin.reference;
  182|       |	/* sc_pkcs15init_create_pin() starts checking if -1 is an acceptable
  183|       |	 * pin reference, which isn't for the SetCOS cards. And since the
  184|       |	 * value 1 has been assigned to the SO pin, we'll jump to 2. */
  185|    181|	else if (auth_info != NULL && auth_info->attrs.pin.reference <= 0) {
  ------------------
  |  Branch (185:11): [True: 181, False: 0]
  |  Branch (185:32): [True: 162, False: 19]
  ------------------
  186|    162|		if (auth_info_prof.attrs.pin.reference != 1)
  ------------------
  |  Branch (186:7): [True: 162, False: 0]
  ------------------
  187|    162|			return SC_ERROR_INVALID_PIN_REFERENCE;
  ------------------
  |  |  111|    162|#define SC_ERROR_INVALID_PIN_REFERENCE		-1509
  ------------------
  188|      0|		auth_info->attrs.pin.reference = auth_info_prof.attrs.pin.reference + 1;
  189|      0|	}
  190|       |
  191|     26|	return SC_SUCCESS;
  ------------------
  |  |   28|     26|#define SC_SUCCESS				0
  ------------------
  192|    188|}
pkcs15-setcos.c:setcos_create_pin:
  203|      5|{
  204|      5|	struct sc_context *ctx = p15card->card->ctx;
  205|      5|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  206|      5|	sc_file_t *pinfile = NULL, *tmp_pinfile = NULL;
  207|      5|	int r, ignore_ac = 0;
  208|       |
  209|      5|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  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]
  |  |  ------------------
  ------------------
  210|       |
  211|      5|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      5|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (211:6): [True: 0, False: 5]
  ------------------
  212|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  213|       |
  214|       |	/* Create the global pin file if it doesn't exist yet */
  215|      5|	r = sc_profile_get_file(profile, "pinfile", &tmp_pinfile);
  216|      5|	LOG_TEST_RET(ctx, r, "No 'pinfile' template in profile");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  217|       |
  218|      0|	r = sc_select_file(p15card->card, &tmp_pinfile->path, &pinfile);
  219|      0|	sc_file_free(tmp_pinfile);
  220|      0|	LOG_TEST_RET(ctx, r, "Cannot select 'pinfile'");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  221|       |
  222|      0|	sc_log(ctx,  "pinfile->status:%X", pinfile->status);
  ------------------
  |  |   71|      0|#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|      0|	sc_log(ctx,  "create PIN with reference:%X, flags:%X, path:%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__
  |  |  ------------------
  ------------------
  224|      0|			auth_info->attrs.pin.reference, auth_info->attrs.pin.flags, sc_print_path(&auth_info->path));
  225|       |
  226|      0|	if (pinfile->status == SC_FILE_STATUS_CREATION)
  ------------------
  |  |  240|      0|#define SC_FILE_STATUS_CREATION		0x02 /* ISO7816-4: Creation state, (1) */
  ------------------
  |  Branch (226:6): [True: 0, False: 0]
  ------------------
  227|      0|		ignore_ac = 1;
  228|       |
  229|      0|	r = setcos_create_pin_internal(profile, p15card, ignore_ac, auth_info,
  230|      0|			pin, pin_len, puk, puk_len);
  231|       |
  232|       |	/* If pinfile is in 'Creation' state and SOPIN has been created,
  233|       |	 * change status of MF and 'pinfile' to 'Operational:Activated'
  234|       |	 */
  235|      0|	sc_file_free(pinfile);
  236|      0|	if (ignore_ac && (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN))   {
  ------------------
  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (236:6): [True: 0, False: 0]
  |  Branch (236:19): [True: 0, False: 0]
  ------------------
  237|      0|		sc_file_t *mf = profile->mf_info->file;
  238|       |
  239|      0|		r = sc_card_ctl(p15card->card, SC_CARDCTL_SETCOS_ACTIVATE_FILE, NULL);
  240|      0|		LOG_TEST_RET(ctx, r, "Cannot set 'pinfile' into the activated state");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  241|       |
  242|      0|		r = sc_select_file(p15card->card, &mf->path, NULL);
  243|      0|		LOG_TEST_RET(ctx, r, "Cannot select MF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  244|       |
  245|      0|		r = sc_card_ctl(p15card->card, SC_CARDCTL_SETCOS_ACTIVATE_FILE, NULL);
  246|      0|		LOG_TEST_RET(ctx, r, "Cannot set MF into the activated state");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  247|      0|	}
  248|       |
  249|      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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  250|      0|}
pkcs15-setcos.c:setcos_create_key:
  331|    513|{
  332|    513|	struct sc_context *ctx = p15card->card->ctx;
  333|    513|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  334|    513|	struct sc_file *file = NULL;
  335|    513|	size_t keybits = key_info->modulus_length;
  336|    513|	int r;
  337|       |
  338|    513|	SC_FUNC_CALLED(ctx, SC_LOG_DEBUG_VERBOSE);
  ------------------
  |  |  148|    513|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  149|    513|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  |  |  150|    513|} while (0)
  |  |  ------------------
  |  |  |  Branch (150:10): [Folded, False: 513]
  |  |  ------------------
  ------------------
  339|    513|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|    513|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (339:6): [True: 390, False: 123]
  ------------------
  340|    513|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Create key failed: RSA only supported");
  ------------------
  |  |  174|    390|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    390|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    390|	int _ret = (r); \
  |  |  |  |  168|    390|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 390, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    390|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    390|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    390|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    390|		return _ret; \
  |  |  |  |  172|    390|	} \
  |  |  |  |  173|    390|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  341|       |
  342|       |	/* Parameter check */
  343|    123|	if ((keybits < 512) || (keybits > 1024) || (keybits & 0x7))
  ------------------
  |  Branch (343:6): [True: 0, False: 123]
  |  Branch (343:25): [True: 0, False: 123]
  |  Branch (343:45): [True: 0, False: 123]
  ------------------
  344|    123|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  345|       |
  346|    123|	sc_log(ctx,  "create private key ID:%s\n",  sc_pkcs15_print_id(&key_info->id));
  ------------------
  |  |   71|    123|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  347|       |
  348|       |	/* Get the private key file */
  349|    123|	r = setcos_new_file(profile, p15card->card, SC_PKCS15_TYPE_PRKEY_RSA, key_info->key_reference, &file);
  ------------------
  |  |  419|    123|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  350|    123|	LOG_TEST_RET(ctx, r, "Cannot get new private key file");
  ------------------
  |  |  174|    123|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    123|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    123|	int _ret = (r); \
  |  |  |  |  168|    123|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 105, False: 18]
  |  |  |  |  ------------------
  |  |  |  |  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|    123|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 18]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  351|       |
  352|       |	/* Take enough room for a 1024 bit key */
  353|     18|	if (file->size < 512)
  ------------------
  |  Branch (353:6): [True: 18, False: 0]
  ------------------
  354|     18|		file->size = 512;
  355|       |
  356|       |	/* Replace the path of instantiated key template by the path from the object data. */
  357|     18|	memcpy(&file->path, &key_info->path, sizeof(file->path));
  358|     18|	if (file->path.len < 2) {
  ------------------
  |  Branch (358:6): [True: 0, False: 18]
  ------------------
  359|      0|		sc_file_free(file);
  360|      0|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_DATA, "Invalid 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  361|      0|	}
  362|     18|	file->id = file->path.value[file->path.len - 2] * 0x100
  363|     18|			+ file->path.value[file->path.len - 1];
  364|       |
  365|     18|	key_info->key_reference = file->path.value[file->path.len - 1] & 0xFF;
  366|       |
  367|     18|	sc_log(ctx,  "Path of private key file to create %s\n", sc_print_path(&file->path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  368|       |
  369|     18|	r = sc_select_file(p15card->card, &file->path, NULL);
  370|     18|	if (!r) {
  ------------------
  |  Branch (370:6): [True: 12, False: 6]
  ------------------
  371|     12|		r = sc_pkcs15init_delete_by_path(profile, p15card, &file->path);
  372|     12|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|     12|#define SC_SUCCESS				0
  ------------------
  |  Branch (372:7): [True: 1, False: 11]
  ------------------
  373|      1|			sc_file_free(file);
  374|     12|		LOG_TEST_RET(ctx, r, "Failed to delete private key file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  375|     12|	} else if (r != SC_ERROR_FILE_NOT_FOUND) {
  ------------------
  |  |   51|      6|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  |  Branch (375:13): [True: 1, False: 5]
  ------------------
  376|      1|		sc_file_free(file);
  377|      1|		file = NULL;
  378|      1|		LOG_TEST_RET(ctx, r, "Select private key file 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  379|      1|	}
  380|       |
  381|       |	/* Now create the key file */
  382|     16|	r = sc_pkcs15init_create_file(profile, p15card, file);
  383|     16|	sc_file_free(file);
  384|     16|	LOG_TEST_RET(ctx, r, "Cannot create private key file");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  385|       |
  386|     10|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  387|     10|}
pkcs15-setcos.c:setcos_new_file:
  260|    123|{
  261|    123|	sc_file_t *file = NULL;
  262|    123|	sc_path_t *p;
  263|    123|	char name[64];
  264|    123|	const char *tag;
  265|    123|	int r;
  266|       |
  267|    123|	if (type == SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|    123|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (267:6): [True: 123, False: 0]
  ------------------
  268|    123|		tag = "private-key";
  269|      0|	else if (type  == SC_PKCS15_TYPE_PUBKEY_RSA)
  ------------------
  |  |  426|      0|#define SC_PKCS15_TYPE_PUBKEY_RSA		0x201
  ------------------
  |  Branch (269:11): [True: 0, False: 0]
  ------------------
  270|      0|		tag = "public-key";
  271|      0|	else if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_CERT)
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              	else if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_CERT)
  ------------------
  |  |  438|      0|#define SC_PKCS15_TYPE_CERT			0x400
  ------------------
  |  Branch (271:11): [True: 0, False: 0]
  ------------------
  272|      0|		tag = "certificate";
  273|      0|	else if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_DATA_OBJECT)
  ------------------
  |  |  416|      0|#define SC_PKCS15_TYPE_CLASS_MASK		0xF00
  ------------------
              	else if ((type & SC_PKCS15_TYPE_CLASS_MASK) == SC_PKCS15_TYPE_DATA_OBJECT)
  ------------------
  |  |  442|      0|#define SC_PKCS15_TYPE_DATA_OBJECT		0x500
  ------------------
  |  Branch (273:11): [True: 0, False: 0]
  ------------------
  274|      0|		tag = "data";
  275|      0|	else {
  276|      0|		sc_log(card->ctx,  "Unsupported file 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__
  |  |  ------------------
  ------------------
  277|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  278|      0|	}
  279|       |
  280|       |	/* Get template from profile  */
  281|    123|	snprintf(name, sizeof(name), "template-%s", tag);
  282|    123|	if (sc_profile_get_file(profile, name, &file) < 0) {
  ------------------
  |  Branch (282:6): [True: 105, False: 18]
  ------------------
  283|    105|		sc_log(card->ctx,  "Profile doesn't define %s", 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__
  |  |  ------------------
  ------------------
  284|    105|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|    105|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  285|    105|	}
  286|       |
  287|       |	/* Auto-increment FID for next object */
  288|     18|	file->id += num;
  289|     18|	p = &file->path;
  290|     18|	*p = profile->df_info->file->path;
  291|     18|	if (p->len + 2 > SC_MAX_PATH_SIZE) {
  ------------------
  |  |   47|     18|#define SC_MAX_PATH_SIZE		16
  ------------------
  |  Branch (291:6): [True: 0, False: 18]
  ------------------
  292|      0|		sc_file_free(file);
  293|      0|		return SC_ERROR_INVALID_DATA;
  ------------------
  |  |   78|      0|#define SC_ERROR_INVALID_DATA			-1305
  ------------------
  294|      0|	}
  295|     18|	p->value[p->len++] = (u8) (file->id / 256);
  296|     18|	p->value[p->len++] = (u8) (file->id % 256);
  297|       |
  298|       |	/* Increment FID until there's no file with such path */
  299|     18|	r = sc_select_file(card, p, NULL);
  300|    169|	while(r == 0) {
  ------------------
  |  Branch (300:8): [True: 151, False: 18]
  ------------------
  301|    151|		file->id++;
  302|    151|		p->value[p->len - 2] = (u8) (file->id / 256);
  303|    151|		p->value[p->len - 1] = (u8) (file->id % 256);
  304|    151|		r = sc_select_file(card, p, NULL);
  305|    151|	}
  306|       |
  307|     18|	*out = file;
  308|     18|	return 0;
  309|     18|}
pkcs15-setcos.c:setcos_generate_key:
  447|     10|{
  448|     10|	struct sc_context *ctx = p15card->card->ctx;
  449|     10|	struct sc_cardctl_setcos_gen_store_key_info args;
  450|     10|	struct sc_cardctl_setcos_data_obj data_obj;
  451|     10|	struct sc_pkcs15_prkey_info *key_info = (struct sc_pkcs15_prkey_info *)object->data;
  452|     10|	int r;
  453|     10|	size_t keybits = key_info->modulus_length;
  454|     10|	unsigned char raw_pubkey[256];
  455|     10|	struct sc_file *file = NULL;
  456|       |
  457|     10|	SC_FUNC_CALLED(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]
  |  |  ------------------
  ------------------
  458|     10|	if (object->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|     10|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (458:6): [True: 0, False: 10]
  ------------------
  459|     10|		LOG_TEST_RET(ctx, SC_ERROR_NOT_SUPPORTED, "Generate key failed: RSA only 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  460|       |
  461|       |	/* Parameter check */
  462|     10|	if ( (keybits < 512) || (keybits > 1024) || (keybits & 0x7))
  ------------------
  |  Branch (462:7): [True: 0, False: 10]
  |  Branch (462:26): [True: 0, False: 10]
  |  Branch (462:46): [True: 0, False: 10]
  ------------------
  463|     10|		LOG_TEST_RET(ctx, SC_ERROR_INVALID_ARGUMENTS, "Invalid key 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  464|       |
  465|     10|	r = sc_select_file(p15card->card, &key_info->path, &file);
  466|     10|	LOG_TEST_RET(ctx, r, "Cannot store key: select key file 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: 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  467|       |
  468|       |	/* Authenticate */
  469|     10|	r = sc_pkcs15init_authenticate(profile, p15card, file, SC_AC_OP_UPDATE);
  ------------------
  |  |  189|     10|#define SC_AC_OP_UPDATE			23
  ------------------
  470|     10|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
  |  Branch (470:6): [True: 0, False: 10]
  ------------------
  471|      0|		sc_file_free(file);
  472|      0|		LOG_TEST_RET(ctx, r, "No authorisation to store private 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  473|      0|	}
  474|       |
  475|       |	/* Fill in data structure */
  476|     10|	memset(&args, 0, sizeof(args));
  477|     10|	args.mod_len = keybits;
  478|     10|	args.op_type = OP_TYPE_GENERATE;
  ------------------
  |  |  529|     10|#define OP_TYPE_GENERATE	0
  ------------------
  479|     10|	args.pubexp_len = SETCOS_DEFAULT_PUBKEY_LEN * 8;
  ------------------
  |  |   37|     10|#define SETCOS_DEFAULT_PUBKEY_LEN       sizeof(SETCOS_DEFAULT_PUBKEY)
  ------------------
  480|     10|	args.pubexp = SETCOS_DEFAULT_PUBKEY;
  481|       |
  482|       |	/* Generate/store rsa key  */
  483|     10|	r = sc_card_ctl(p15card->card, SC_CARDCTL_SETCOS_GENERATE_STORE_KEY, &args);
  484|     10|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|     10|#define SC_SUCCESS				0
  ------------------
  |  Branch (484:6): [True: 0, False: 10]
  ------------------
  485|      0|		sc_file_free(file);
  486|      0|		LOG_TEST_RET(ctx, r, "Card control 'GENERATE_STORE_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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  487|      0|	}
  488|       |
  489|       |	/* Key pair generation -> collect public key info */
  490|     10|	if (pubkey != NULL) {
  ------------------
  |  Branch (490:6): [True: 10, False: 0]
  ------------------
  491|     10|		pubkey->algorithm		= SC_ALGORITHM_RSA;
  ------------------
  |  |   78|     10|#define SC_ALGORITHM_RSA		0
  ------------------
  492|     10|		pubkey->u.rsa.modulus.len	= BYTES4BITS(keybits);
  ------------------
  |  |  146|     10|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  493|     10|		pubkey->u.rsa.modulus.data	= malloc(pubkey->u.rsa.modulus.len);
  494|     10|		if (pubkey->u.rsa.modulus.data == NULL)
  ------------------
  |  Branch (494:7): [True: 0, False: 10]
  ------------------
  495|     10|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  496|     10|		pubkey->u.rsa.exponent.len	= SETCOS_DEFAULT_PUBKEY_LEN;
  ------------------
  |  |   37|     10|#define SETCOS_DEFAULT_PUBKEY_LEN       sizeof(SETCOS_DEFAULT_PUBKEY)
  ------------------
  497|     10|		pubkey->u.rsa.exponent.data	= malloc(SETCOS_DEFAULT_PUBKEY_LEN);
  ------------------
  |  |   37|     10|#define SETCOS_DEFAULT_PUBKEY_LEN       sizeof(SETCOS_DEFAULT_PUBKEY)
  ------------------
  498|     10|		if (pubkey->u.rsa.exponent.data == NULL)
  ------------------
  |  Branch (498:7): [True: 0, False: 10]
  ------------------
  499|     10|			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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  500|     10|		memcpy(pubkey->u.rsa.exponent.data, SETCOS_DEFAULT_PUBKEY, SETCOS_DEFAULT_PUBKEY_LEN);
  ------------------
  |  |   37|     10|#define SETCOS_DEFAULT_PUBKEY_LEN       sizeof(SETCOS_DEFAULT_PUBKEY)
  ------------------
  501|       |
  502|       |		/* Get public key modulus */
  503|     10|		r = sc_select_file(p15card->card, &file->path, NULL);
  504|     10|		sc_file_free(file);
  505|     10|		LOG_TEST_RET(ctx, r, "Cannot get key modulus: select key file 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  506|       |
  507|      9|		data_obj.P1 = 0x01;
  508|      9|		data_obj.P2 = 0x01;
  509|      9|		data_obj.Data = raw_pubkey;
  510|      9|		data_obj.DataLen = sizeof(raw_pubkey);
  511|       |
  512|      9|		r = sc_card_ctl(p15card->card, SC_CARDCTL_SETCOS_GETDATA, &data_obj);
  513|      9|		LOG_TEST_RET(ctx, r, "Cannot get key modulus: 'SETCOS_GETDATA' 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  514|       |
  515|      9|		if (data_obj.DataLen < 3 || data_obj.DataLen < pubkey->u.rsa.modulus.len)
  ------------------
  |  Branch (515:7): [True: 0, False: 9]
  |  Branch (515:31): [True: 0, False: 9]
  ------------------
  516|      9|			LOG_TEST_RET(ctx, SC_ERROR_UNKNOWN_DATA_RECEIVED, "Cannot get key modulus: wrong length of raw 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  517|       |
  518|      9|		keybits = ((raw_pubkey[0] * 256) + raw_pubkey[1]);  /* modulus bit length */
  519|      9|		if (keybits != key_info->modulus_length)  {
  ------------------
  |  Branch (519:7): [True: 7, False: 2]
  ------------------
  520|      7|			sc_log(ctx,
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  521|      7|				 "key-size from card[%"SC_FORMAT_LEN_SIZE_T"u] does not match[%"SC_FORMAT_LEN_SIZE_T"u]\n",
  522|      7|				 keybits, key_info->modulus_length);
  523|      7|			LOG_TEST_RET(ctx, SC_ERROR_PKCS15INIT, "Failed to generate key");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  524|      7|		}
  525|      2|		memcpy(pubkey->u.rsa.modulus.data, &raw_pubkey[2], pubkey->u.rsa.modulus.len);
  526|      2|	} else {
  527|      0|		sc_file_free(file);
  528|      0|	}
  529|       |
  530|      2|	return r;
  531|     10|}

sc_pkcs15init_get_starcos_ops:
  950|     97|{
  951|     97|	return &sc_pkcs15init_starcos_operations;
  952|     97|}
pkcs15-starcos.c:starcos_erase_card:
   47|     63|{
   48|       |	return sc_card_ctl(p15card->card, SC_CARDCTL_ERASE_CARD, NULL);
   49|     63|}
pkcs15-starcos.c:starcos_init_card:
   78|     40|{
   79|     40|	struct sc_card *card = p15card->card;
   80|     40|	static const u8 key[]  = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
   81|     40|	int		ret;
   82|     40|	sc_starcos_create_data  mf_data, ipf_data;
   83|     40|	sc_file_t	*mf_file, *isf_file, *ipf_file;
   84|     40|	sc_path_t	tpath;
   85|     40|	u8		*p = mf_data.data.mf.header, tmp = 0;
   86|     40|	sc_pkcs15_auth_info_t sopin = {0};
   87|       |
   88|       |	/* test if we already have a MF */
   89|     40|	memset(&tpath, 0, sizeof(sc_path_t));
   90|     40|	tpath.value[0] = 0x3f;
   91|     40|	tpath.value[1] = 0x00;
   92|     40|	tpath.len      = 2;
   93|     40|	tpath.type     = SC_PATH_TYPE_PATH;
  ------------------
  |  |  119|     40|#define SC_PATH_TYPE_PATH		2
  ------------------
   94|     40|	ret = sc_select_file(card, &tpath, NULL);
   95|     40|	if (ret == SC_SUCCESS)
  ------------------
  |  |   28|     40|#define SC_SUCCESS				0
  ------------------
  |  Branch (95:6): [True: 34, False: 6]
  ------------------
   96|       |		/* we already have a MF => return OK */
   97|     34|		return ret;
   98|       |
   99|      6|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &sopin);
  ------------------
  |  |  169|      6|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  100|       |
  101|       |	/* get mf profile */
  102|      6|	ret = sc_profile_get_file(profile, "MF", &mf_file);
  103|      6|	if (ret < 0)
  ------------------
  |  Branch (103:6): [True: 0, False: 6]
  ------------------
  104|      0|		return ret;
  105|       |	/* get size of the isf */
  106|      6|	ret = sc_profile_get_file(profile, "mf_isf", &isf_file);
  107|      6|	if (ret < 0) {
  ------------------
  |  Branch (107:6): [True: 6, False: 0]
  ------------------
  108|      6|		sc_file_free(mf_file);
  109|      6|		return ret;
  110|      6|	}
  111|      0|	mf_data.type = SC_STARCOS_MF_DATA;
  ------------------
  |  |  373|      0|#define	SC_STARCOS_MF_DATA	0x01
  ------------------
  112|      0|	memcpy(p, key, 8);
  113|      0|	p   += 8;
  114|      0|	*p++ = (mf_file->size  >> 8) & 0xff;
  115|      0|	*p++ = mf_file->size  & 0xff;
  116|      0|	*p++ = (isf_file->size >> 8) & 0xff;
  117|      0|	*p++ = isf_file->size & 0xff;
  118|       |	/* AC CREATE EF   */
  119|      0|	*p++ = get_so_ac(mf_file, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 1);
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              	*p++ = get_so_ac(mf_file, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 1);
  ------------------
  |  |   36|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  120|       |	/* AC CREATE KEY  */
  121|      0|	*p++ = get_so_ac(isf_file, SC_AC_OP_WRITE, &sopin, STARCOS_AC_NEVER,  1);
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
              	*p++ = get_so_ac(isf_file, SC_AC_OP_WRITE, &sopin, STARCOS_AC_NEVER,  1);
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
  122|       |	/* AC CREATE DF   */
  123|      0|	*p++ = get_so_ac(mf_file, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 1);
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              	*p++ = get_so_ac(mf_file, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 1);
  ------------------
  |  |   36|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  124|       |	/* AC REGISTER DF */
  125|      0|	*p++ = get_so_ac(mf_file, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 1);
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              	*p++ = get_so_ac(mf_file, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 1);
  ------------------
  |  |   36|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  126|      0|	*p++ = 0x00;	/* SM CR:  no */
  127|      0|	*p++ = 0x00;	/* SM EF:  no */
  128|      0|	*p = 0x00;	/* SM ISF: no */
  129|      0|	sc_file_free(mf_file);
  130|      0|	sc_file_free(isf_file);
  131|       |	/* call CREATE MF  */
  132|      0|	ret = sc_card_ctl(card, SC_CARDCTL_STARCOS_CREATE_FILE, &mf_data);
  133|      0|	if (ret != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (133:6): [True: 0, False: 0]
  ------------------
  134|      0|		return ret;
  135|       |	/* create IPF */
  136|       |	/* get size of the ipf */
  137|      0|	ret = sc_profile_get_file(profile, "mf_ipf", &ipf_file);
  138|      0|	if (ret < 0)
  ------------------
  |  Branch (138:6): [True: 0, False: 0]
  ------------------
  139|      0|		return ret;
  140|      0|	ipf_data.type = SC_STARCOS_EF_DATA;
  ------------------
  |  |  375|      0|#define SC_STARCOS_EF_DATA	0x04
  ------------------
  141|      0|	p = ipf_data.data.ef.header;
  142|      0|	*p++ = (ipf_file->id >> 8) & 0xff;
  143|      0|	*p++ = ipf_file->id & 0xff;
  144|      0|	*p++ = STARCOS_AC_ALWAYS;	/* AC READ: always */
  ------------------
  |  |   36|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  145|       |	/* AC WRITE IPF */
  146|      0|	*p++ = get_so_ac(ipf_file,SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 1);
  ------------------
  |  |  169|      0|#define SC_AC_OP_CREATE			3
  ------------------
              	*p++ = get_so_ac(ipf_file,SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 1);
  ------------------
  |  |   36|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  147|      0|	*p++ = STARCOS_AC_NEVER;	/* AC ERASE    */
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
  148|      0|	*p++ = STARCOS_AC_NEVER;	/* AC LOCK     */
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
  149|      0|	*p++ = STARCOS_AC_NEVER;	/* AC UNLOCK   */
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
  150|      0|	*p++ = STARCOS_AC_NEVER;	/* AC INCREASE */
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
  151|      0|	*p++ = STARCOS_AC_NEVER;	/* AC_DECREASE */
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
  152|      0|	*p++ = STARCOS_AC_NEVER;	/* RFU         */
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
  153|      0|	*p++ = STARCOS_AC_NEVER;	/* RFU         */
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
  154|      0|	*p++ = 0x00;			/* SM          */
  155|      0|	*p++ = 0x00;			/* SID         */
  156|      0|	*p++ = 0xA1;			/* IPF         */
  157|      0|	*p++ = (ipf_file->size >> 8) & 0xff;
  158|      0|	*p = ipf_file->size & 0xff;
  159|      0|	ret  = sc_card_ctl(card, SC_CARDCTL_STARCOS_CREATE_FILE, &ipf_data);
  160|      0|	if (ret != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (160:6): [True: 0, False: 0]
  ------------------
  161|      0|		sc_file_free(ipf_file);
  162|      0|		return ret;
  163|      0|	}
  164|       |	/* init IPF */
  165|      0|	ret = sc_select_file(card, &ipf_file->path, NULL);
  166|      0|	sc_file_free(ipf_file);
  167|      0|	if (ret < 0)
  ------------------
  |  Branch (167:6): [True: 0, False: 0]
  ------------------
  168|      0|		return ret;
  169|      0|	ret = sc_update_binary(card, 0, &tmp, 1, 0);
  170|      0|	if (ret < 0)
  ------------------
  |  Branch (170:6): [True: 0, False: 0]
  ------------------
  171|      0|		return ret;
  172|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  173|      0|}
pkcs15-starcos.c:get_so_ac:
   54|     38|{
   55|     38|	int is_global = 1;
   56|     38|	const sc_acl_entry_t *acl;
   57|       |
   58|     38|	if (auth->attrs.pin.flags & SC_PKCS15_PIN_FLAG_LOCAL)
  ------------------
  |  |   55|     38|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (58:6): [True: 38, False: 0]
  ------------------
   59|     38|		is_global = 0;
   60|     38|	if (!is_global && need_global)
  ------------------
  |  Branch (60:6): [True: 38, False: 0]
  |  Branch (60:20): [True: 0, False: 38]
  ------------------
   61|      0|		return def & 0xff;
   62|     38|	acl = sc_file_get_acl_entry(file, op);
   63|     38|	if (acl->method == SC_AC_NONE)
  ------------------
  |  |  150|     38|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (63:6): [True: 38, False: 0]
  ------------------
   64|     38|		return STARCOS_AC_ALWAYS;
  ------------------
  |  |   36|     38|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
   65|      0|	else if (acl->method == SC_AC_NEVER)
  ------------------
  |  |  163|      0|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (65:11): [True: 0, False: 0]
  ------------------
   66|      0|		return STARCOS_AC_NEVER;
  ------------------
  |  |   35|      0|#define STARCOS_AC_NEVER	0x5f
  ------------------
   67|      0|	else if (acl->method == SC_AC_SYMBOLIC) {
  ------------------
  |  |  155|      0|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (67:11): [True: 0, False: 0]
  ------------------
   68|      0|		if (is_global)
  ------------------
  |  Branch (68:7): [True: 0, False: 0]
  ------------------
   69|      0|			return STARCOS_SOPIN_GAC;
  ------------------
  |  |   40|      0|#define STARCOS_SOPIN_GAC	0x01
  ------------------
   70|      0|		else
   71|      0|			return STARCOS_SOPIN_LAC;
  ------------------
  |  |   42|      0|#define STARCOS_SOPIN_LAC	0x11;
  ------------------
   72|      0|	} else
   73|      0|		return def;
   74|     38|}
pkcs15-starcos.c:starcos_create_dir:
  177|     34|{
  178|     34|	struct sc_card *card = p15card->card;
  179|     34|	int             ret;
  180|     34|	sc_starcos_create_data df_data, ipf_data;
  181|     34|	sc_file_t	*isf_file, *ipf_file;
  182|     34|	u8		*p = df_data.data.df.header, tmp = 0;
  183|     34|	sc_pkcs15_auth_info_t sopin = {0};
  184|       |
  185|     34|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &sopin);
  ------------------
  |  |  169|     34|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  186|       |
  187|       |	/* get p15_isf profile */
  188|     34|	ret = sc_profile_get_file(profile, "p15_isf", &isf_file);
  189|     34|	if (ret < 0)
  ------------------
  |  Branch (189:6): [True: 21, False: 13]
  ------------------
  190|     21|		return ret;
  191|       |
  192|     13|	df_data.type = SC_STARCOS_DF_DATA;
  ------------------
  |  |  374|     13|#define SC_STARCOS_DF_DATA	0x02
  ------------------
  193|     13|	memset(p, 0, 25);
  194|     13|	*p++ = (df->id >> 8) & 0xff;
  195|     13|	*p++ = df->id & 0xff;
  196|     13|	*p++ = df->namelen & 0xff;
  197|     13|	memcpy(p, df->name, (u8) df->namelen);
  198|     13|	p   += 16;
  199|     13|	*p++ = (isf_file->size >> 8) & 0xff;
  200|     13|	*p++ = isf_file->size & 0xff;
  201|       |	/* AC CREATE EF  */
  202|     13|	*p++ = get_so_ac(df, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 0);
  ------------------
  |  |  169|     13|#define SC_AC_OP_CREATE			3
  ------------------
              	*p++ = get_so_ac(df, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 0);
  ------------------
  |  |   36|     13|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  203|       |	/* AC CREATE KEY */
  204|     13|	*p++ = get_so_ac(isf_file, SC_AC_OP_WRITE, &sopin, STARCOS_AC_NEVER, 0);
  ------------------
  |  |  190|     13|#define SC_AC_OP_WRITE			24
  ------------------
              	*p++ = get_so_ac(isf_file, SC_AC_OP_WRITE, &sopin, STARCOS_AC_NEVER, 0);
  ------------------
  |  |   35|     13|#define STARCOS_AC_NEVER	0x5f
  ------------------
  205|     13|	*p++ = 0x00;		/* SM EF:  no */
  206|     13|	*p = 0x00;		/* SM ISF: no */
  207|     13|	df_data.data.df.size[0] = (df->size >> 8) & 0xff;
  208|     13|	df_data.data.df.size[1] = df->size & 0xff;
  209|     13|	sc_file_free(isf_file);
  210|       |	/* call CREATE DF  */
  211|     13|	ret = sc_card_ctl(card, SC_CARDCTL_STARCOS_CREATE_FILE, &df_data);
  212|     13|	if (ret != SC_SUCCESS)
  ------------------
  |  |   28|     13|#define SC_SUCCESS				0
  ------------------
  |  Branch (212:6): [True: 1, False: 12]
  ------------------
  213|      1|		return ret;
  214|       |	/* create IPF */
  215|     12|	ret = sc_select_file(card, &df->path, NULL);
  216|     12|	if (ret != SC_SUCCESS)
  ------------------
  |  |   28|     12|#define SC_SUCCESS				0
  ------------------
  |  Branch (216:6): [True: 0, False: 12]
  ------------------
  217|      0|		return ret;
  218|     12|	ret = sc_profile_get_file(profile, "p15_ipf", &ipf_file);
  219|     12|	if (ret < 0)
  ------------------
  |  Branch (219:6): [True: 0, False: 12]
  ------------------
  220|      0|		return ret;
  221|     12|	ipf_data.type = SC_STARCOS_EF_DATA;
  ------------------
  |  |  375|     12|#define SC_STARCOS_EF_DATA	0x04
  ------------------
  222|     12|	p = ipf_data.data.ef.header;
  223|     12|	*p++ = (ipf_file->id >> 8) & 0xff;
  224|     12|	*p++ = ipf_file->id & 0xff;
  225|     12|	*p++ = STARCOS_AC_ALWAYS;	/* AC READ     */
  ------------------
  |  |   36|     12|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  226|       |	/* AC WRITE IPF */
  227|     12|	*p++ = get_so_ac(ipf_file, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 0);
  ------------------
  |  |  169|     12|#define SC_AC_OP_CREATE			3
  ------------------
              	*p++ = get_so_ac(ipf_file, SC_AC_OP_CREATE, &sopin, STARCOS_AC_ALWAYS, 0);
  ------------------
  |  |   36|     12|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  228|     12|	*p++ = STARCOS_AC_NEVER;	/* AC ERASE    */
  ------------------
  |  |   35|     12|#define STARCOS_AC_NEVER	0x5f
  ------------------
  229|     12|	*p++ = STARCOS_AC_NEVER;	/* AC LOCK     */
  ------------------
  |  |   35|     12|#define STARCOS_AC_NEVER	0x5f
  ------------------
  230|     12|	*p++ = STARCOS_AC_NEVER;	/* AC UNLOCK   */
  ------------------
  |  |   35|     12|#define STARCOS_AC_NEVER	0x5f
  ------------------
  231|     12|	*p++ = STARCOS_AC_NEVER;	/* AC INCREASE */
  ------------------
  |  |   35|     12|#define STARCOS_AC_NEVER	0x5f
  ------------------
  232|     12|	*p++ = STARCOS_AC_NEVER;	/* AC_DECREASE */
  ------------------
  |  |   35|     12|#define STARCOS_AC_NEVER	0x5f
  ------------------
  233|     12|	*p++ = STARCOS_AC_NEVER;	/* RFU         */
  ------------------
  |  |   35|     12|#define STARCOS_AC_NEVER	0x5f
  ------------------
  234|     12|	*p++ = STARCOS_AC_NEVER;	/* RFU         */
  ------------------
  |  |   35|     12|#define STARCOS_AC_NEVER	0x5f
  ------------------
  235|     12|	*p++ = 0x00;			/* SM          */
  236|     12|	*p++ = 0x00;			/* SID         */
  237|     12|	*p++ = 0xA1;			/* IPF         */
  238|     12|	*p++ = (ipf_file->size >> 8) & 0xff;
  239|     12|	*p = ipf_file->size & 0xff;
  240|     12|	ret  = sc_card_ctl(card, SC_CARDCTL_STARCOS_CREATE_FILE, &ipf_data);
  241|     12|	if (ret != SC_SUCCESS) {
  ------------------
  |  |   28|     12|#define SC_SUCCESS				0
  ------------------
  |  Branch (241:6): [True: 0, False: 12]
  ------------------
  242|      0|		sc_file_free(ipf_file);
  243|      0|		return ret;
  244|      0|	}
  245|       |	/* init IPF */
  246|     12|	ret = sc_select_file(card, &ipf_file->path, NULL);
  247|     12|	sc_file_free(ipf_file);
  248|     12|	if (ret < 0)
  ------------------
  |  Branch (248:6): [True: 0, False: 12]
  ------------------
  249|      0|		return ret;
  250|     12|	ret = sc_update_binary(card, 0, &tmp, 1, 0);
  251|     12|	if (ret < 0)
  ------------------
  |  Branch (251:6): [True: 0, False: 12]
  ------------------
  252|      0|		return ret;
  253|     12|	return SC_SUCCESS;
  ------------------
  |  |   28|     12|#define SC_SUCCESS				0
  ------------------
  254|     12|}
pkcs15-starcos.c:starcos_pin_reference:
  277|     89|{
  278|     89|	int tmp;
  279|       |
  280|     89|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     89|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (280:6): [True: 0, False: 89]
  ------------------
  281|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  282|       |
  283|     89|	tmp = auth_info->attrs.pin.reference;
  284|       |
  285|     89|	if (have_onepin(profile)) {
  ------------------
  |  Branch (285:6): [True: 56, False: 33]
  ------------------
  286|       |		/* we have the onepin profile */
  287|     56|		auth_info->attrs.pin.reference = STARCOS_SOPIN_GID;
  ------------------
  |  |   38|     56|#define STARCOS_SOPIN_GID	0x01
  ------------------
  288|     56|		return SC_SUCCESS;
  ------------------
  |  |   28|     56|#define SC_SUCCESS				0
  ------------------
  289|     56|	}
  290|       |
  291|     33|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_LOCAL) {
  ------------------
  |  |   55|     33|#define SC_PKCS15_PIN_FLAG_LOCAL			0x0002
  ------------------
  |  Branch (291:6): [True: 29, False: 4]
  ------------------
  292|       |		/* use local KID */
  293|       |		/* SO-pin */
  294|     29|		if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|     29|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (294:7): [True: 15, False: 14]
  ------------------
  295|     15|			tmp = STARCOS_SOPIN_LID;
  ------------------
  |  |   41|     15|#define STARCOS_SOPIN_LID	0x81
  ------------------
  296|     14|		else {
  297|     14|			if (tmp < STARCOS_MIN_LPIN_ID)
  ------------------
  |  |  271|     14|#define STARCOS_MIN_LPIN_ID	0x83
  ------------------
  |  Branch (297:8): [True: 14, False: 0]
  ------------------
  298|     14|				tmp = STARCOS_MIN_LPIN_ID;
  ------------------
  |  |  271|     14|#define STARCOS_MIN_LPIN_ID	0x83
  ------------------
  299|     14|			if (!(tmp & 0x01))
  ------------------
  |  Branch (299:8): [True: 0, False: 14]
  ------------------
  300|       |				/* odd KIDs for PINs and even KIDs for PUKs */
  301|      0|				tmp++;
  302|     14|			if (tmp > STARCOS_MAX_LPIN_ID)
  ------------------
  |  |  272|     14|#define STARCOS_MAX_LPIN_ID	0x8f
  ------------------
  |  Branch (302:8): [True: 0, False: 14]
  ------------------
  303|      0|				return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  304|     14|		}
  305|     29|	} else {
  306|       |		/* use global KID */
  307|       |		/* SO-pin */
  308|      4|		if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|      4|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (308:7): [True: 3, False: 1]
  ------------------
  309|      3|			tmp = STARCOS_SOPIN_GID;
  ------------------
  |  |   38|      3|#define STARCOS_SOPIN_GID	0x01
  ------------------
  310|      1|		else {
  311|      1|			if (tmp < STARCOS_MIN_GPIN_ID)
  ------------------
  |  |  273|      1|#define STARCOS_MIN_GPIN_ID	0x03
  ------------------
  |  Branch (311:8): [True: 1, False: 0]
  ------------------
  312|      1|				tmp = STARCOS_MIN_GPIN_ID;
  ------------------
  |  |  273|      1|#define STARCOS_MIN_GPIN_ID	0x03
  ------------------
  313|      1|			if (!(tmp & 0x01))
  ------------------
  |  Branch (313:8): [True: 0, False: 1]
  ------------------
  314|       |				/* odd KIDs for PINs and even KIDs for PUKs */
  315|      0|			tmp++;
  316|      1|			if (tmp > STARCOS_MAX_GPIN_ID)
  ------------------
  |  |  274|      1|#define STARCOS_MAX_GPIN_ID	0x0f
  ------------------
  |  Branch (316:8): [True: 0, False: 1]
  ------------------
  317|      0|				return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  318|      1|		}
  319|      4|	}
  320|     33|	auth_info->attrs.pin.reference = tmp;
  321|       |
  322|     33|	return SC_SUCCESS;
  ------------------
  |  |   28|     33|#define SC_SUCCESS				0
  ------------------
  323|     33|}
pkcs15-starcos.c:have_onepin:
  257|     89|{
  258|     89|	sc_pkcs15_auth_info_t sopin = {0};
  259|       |
  260|     89|	sc_profile_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &sopin);
  ------------------
  |  |  169|     89|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  261|       |
  262|     89|	if (!(sopin.attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN))
  ------------------
  |  |   61|     89|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (262:6): [True: 56, False: 33]
  ------------------
  263|     56|		return 1;
  264|     33|	else
  265|     33|		return 0;
  266|     89|}
pkcs15-starcos.c:starcos_create_pin:
  352|     60|{
  353|     60|	struct sc_card *card = p15card->card;
  354|     60|	int	r, is_local, pin_id, tmp, need_finalize = 0;
  355|     60|	size_t	akd;
  356|     60|	sc_file_t            *tfile;
  357|     60|	const sc_acl_entry_t *acl_entry;
  358|     60|	sc_pkcs15_auth_info_t *auth_info = (sc_pkcs15_auth_info_t *) pin_obj->data;
  359|     60|	sc_starcos_wkey_data  pin_d, puk_d;
  360|     60|	u8		      tpin[8];
  361|       |
  362|     60|	if (!pin || !pin_len || pin_len > 8)
  ------------------
  |  Branch (362:6): [True: 0, False: 60]
  |  Branch (362:14): [True: 0, False: 60]
  |  Branch (362:26): [True: 0, False: 60]
  ------------------
  363|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  364|       |
  365|     60|	if (auth_info->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     60|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (365:6): [True: 0, False: 60]
  ------------------
  366|      0|		return SC_ERROR_OBJECT_NOT_VALID;
  ------------------
  |  |   87|      0|#define SC_ERROR_OBJECT_NOT_VALID		-1406
  ------------------
  367|       |
  368|     60|	is_local = 0x80 & auth_info->attrs.pin.reference;
  369|     60|	if (is_local)
  ------------------
  |  Branch (369:6): [True: 14, False: 46]
  ------------------
  370|     14|		r = sc_select_file(card, &df->path, NULL);
  371|     46|	else
  372|     46|		r = sc_select_file(card, &profile->mf_info->file->path, NULL);
  373|     60|	if (r < 0)
  ------------------
  |  Branch (373:6): [True: 33, False: 27]
  ------------------
  374|     33|		return r;
  375|       |	/* get and verify sopin if necessary */
  376|     27|	r = sc_profile_get_file(profile, "p15_isf", &tfile);
  377|     27|        if (r < 0)
  ------------------
  |  Branch (377:13): [True: 7, False: 20]
  ------------------
  378|      7|                return r;
  379|     20|	acl_entry = sc_file_get_acl_entry(tfile, SC_AC_OP_WRITE);
  ------------------
  |  |  190|     20|#define SC_AC_OP_WRITE			24
  ------------------
  380|     20|	if (acl_entry->method != SC_AC_NONE) {
  ------------------
  |  |  150|     20|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (380:6): [True: 0, False: 20]
  ------------------
  381|      0|		if ((auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN) || have_onepin(profile))
  ------------------
  |  |   61|      0|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (381:7): [True: 0, False: 0]
  |  Branch (381:67): [True: 0, False: 0]
  ------------------
  382|      0|			need_finalize = 1;
  383|      0|		else
  384|      0|			r = sc_pkcs15init_authenticate(profile, p15card, tfile, SC_AC_OP_WRITE);
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  385|      0|	}
  386|     20|	sc_file_free(tfile);
  387|     20|	if (r < 0)
  ------------------
  |  Branch (387:6): [True: 0, False: 20]
  ------------------
  388|      0|		return r;
  389|       |
  390|       |	/* pad pin with 0 */
  391|     20|	memset(tpin, 0, 8);
  392|     20|	memcpy(tpin, pin, pin_len);
  393|       |
  394|       |	/* write PIN */
  395|     20|	tmp    = auth_info->tries_left;
  396|     20|	pin_id = auth_info->attrs.pin.reference;
  397|       |
  398|     20|	pin_d.mode    = 0;	/* install */
  399|     20|	pin_d.kid     = (u8) pin_id;
  400|     20|	pin_d.key     = tpin;
  401|     20|	pin_d.key_len = 8;
  402|     20|	pin_d.key_header[0]  = pin_d.kid;
  403|     20|	pin_d.key_header[1]  = 0;
  404|     20|	pin_d.key_header[2]  = 8;
  405|     20|	pin_d.key_header[3]  = STARCOS_AC_ALWAYS;
  ------------------
  |  |   36|     20|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  406|     20|	if (auth_info->attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN)
  ------------------
  |  |   61|     20|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (406:6): [True: 0, False: 20]
  ------------------
  407|      0|		pin_d.key_header[4] = STARCOS_SOPIN_STATE;
  ------------------
  |  |   39|      0|#define STARCOS_SOPIN_STATE	0x01
  ------------------
  408|     20|	else
  409|     20|		pin_d.key_header[4] = STARCOS_PINID2STATE(pin_id);
  ------------------
  |  |  346|     20|#define STARCOS_PINID2STATE(a)	(((a) == STARCOS_SOPIN_GID) ? STARCOS_SOPIN_STATE : (0x0f - ((0x0f & (a)) >> 1)))
  |  |  ------------------
  |  |  |  |   38|     20|#define STARCOS_SOPIN_GID	0x01
  |  |  ------------------
  |  |               #define STARCOS_PINID2STATE(a)	(((a) == STARCOS_SOPIN_GID) ? STARCOS_SOPIN_STATE : (0x0f - ((0x0f & (a)) >> 1)))
  |  |  ------------------
  |  |  |  |   39|     20|#define STARCOS_SOPIN_STATE	0x01
  |  |  ------------------
  |  |  |  Branch (346:33): [True: 20, False: 0]
  |  |  ------------------
  ------------------
  410|     20|	pin_d.key_header[5]  = STARCOS_AC_ALWAYS;
  ------------------
  |  |   36|     20|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  411|     20|	pin_d.key_header[6]  = ((0x0f & tmp) << 4) | (0x0f & tmp);
  412|     20|	pin_d.key_header[7]  = 0x00;
  413|     20|	pin_d.key_header[8]  = 0x00;
  414|     20|	akd = auth_info->attrs.pin.min_length;
  415|     20|	if (akd < 4)
  ------------------
  |  Branch (415:6): [True: 7, False: 13]
  ------------------
  416|      7|		akd = 4;
  417|     20|	if (akd > 8)
  ------------------
  |  Branch (417:6): [True: 3, False: 17]
  ------------------
  418|      3|		akd = 8;
  419|     20|	akd--;
  420|     20|	akd |= 0x08;
  421|     20|	pin_d.key_header[9]  = akd;	/* AKD: standard + every char != 0 +
  422|       |					 * pin min length */
  423|     20|	pin_d.key_header[10] = 0x00;	/* never allow WRITE KEY    */
  424|     20|	pin_d.key_header[11] = 0x81;	/* key attribute: akd + pin */
  425|       |	/* create/write PIN */
  426|     20|	r = sc_card_ctl(card, SC_CARDCTL_STARCOS_WRITE_KEY, &pin_d);
  427|     20|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|     20|#define SC_SUCCESS				0
  ------------------
  |  Branch (427:6): [True: 11, False: 9]
  ------------------
  428|     11|		return r;
  429|       |
  430|      9|	if (puk && puk_len) {
  ------------------
  |  Branch (430:6): [True: 9, False: 0]
  |  Branch (430:13): [True: 9, False: 0]
  ------------------
  431|      9|		sc_pkcs15_auth_info_t puk_info = {0};
  432|       |
  433|      9|		if (puk_len > 8)
  ------------------
  |  Branch (433:7): [True: 0, False: 9]
  ------------------
  434|      0|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
  435|      9|		memset(tpin, 0, 8);
  436|      9|		memcpy(tpin, puk, puk_len);
  437|       |
  438|      9|		sc_profile_get_pin_info(profile, SC_PKCS15INIT_USER_PUK, &puk_info);
  ------------------
  |  |  172|      9|#define SC_PKCS15INIT_USER_PUK		3
  ------------------
  439|      9|		tmp = puk_info.tries_left;
  440|       |
  441|      9|		puk_d.mode    = 0;	/* install */
  442|      9|		puk_d.kid     = (u8) pin_id + 1;
  443|      9|		puk_d.key     = tpin;
  444|      9|		puk_d.key_len = 8;
  445|      9|		puk_d.key_header[0]  = puk_d.kid;
  446|      9|		puk_d.key_header[1]  = 0;
  447|      9|		puk_d.key_header[2]  = 8;
  448|      9|		puk_d.key_header[3]  = STARCOS_AC_ALWAYS;
  ------------------
  |  |   36|      9|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  449|      9|		puk_d.key_header[4]  = ((pin_id & 0x1f) << 3) | 0x05;
  450|      9|		puk_d.key_header[5]  = 0x01;
  451|      9|		puk_d.key_header[6]  = ((0x0f & tmp) << 4) | (0x0f & tmp);
  452|      9|		puk_d.key_header[7]  = 0x0;
  453|      9|		puk_d.key_header[8]  = 0x0;
  454|      9|		puk_d.key_header[9]  = 0x0;
  455|      9|		puk_d.key_header[10] = 0x00;
  456|      9|		puk_d.key_header[11] = 0x02;
  457|       |		/* create/write PUK */
  458|      9|		r = sc_card_ctl(card, SC_CARDCTL_STARCOS_WRITE_KEY, &puk_d);
  459|      9|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      9|#define SC_SUCCESS				0
  ------------------
  |  Branch (459:7): [True: 0, False: 9]
  ------------------
  460|      0|			return r;
  461|      9|	}
  462|       |
  463|       |	/* in case of a global pin: write dummy entry in df isf */
  464|      9|	if (!is_local) {
  ------------------
  |  Branch (464:6): [True: 9, False: 0]
  ------------------
  465|      9|		r = sc_select_file(card, &df->path, NULL);
  466|      9|		if (r < 0)
  ------------------
  |  Branch (466:7): [True: 0, False: 9]
  ------------------
  467|      0|			return r;
  468|      9|		pin_d.key     = NULL;
  469|      9|		pin_d.key_len = 0;
  470|      9|		pin_d.key_header[1] = 0;
  471|      9|		pin_d.key_header[2] = 0;
  472|       |		/* create/write dummy PIN */
  473|      9|		r = sc_card_ctl(card, SC_CARDCTL_STARCOS_WRITE_KEY, &pin_d);
  474|      9|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|      9|#define SC_SUCCESS				0
  ------------------
  |  Branch (474:7): [True: 3, False: 6]
  ------------------
  475|      3|			return r;
  476|      9|	}
  477|       |
  478|       |	/* in case of a SOPIN: if AC WRITE KEY is protected by the
  479|       |	 * SOPIN, call starcos_finalize_card to activate the ACs  */
  480|      6|	if (need_finalize)
  ------------------
  |  Branch (480:6): [True: 0, False: 6]
  ------------------
  481|      0|		 r = starcos_finalize_card(card);
  482|       |
  483|      6|	return r;
  484|      9|}
pkcs15-starcos.c:starcos_key_reference:
  494|     63|{
  495|       |	/* use (local) KIDs 0x91-0x9f for private rsa keys */
  496|     63|	if (prkey->key_reference < STARCOS_MIN_LPKEY_ID)
  ------------------
  |  |  488|     63|#define STARCOS_MIN_LPKEY_ID	0x91
  ------------------
  |  Branch (496:6): [True: 63, False: 0]
  ------------------
  497|     63|		prkey->key_reference = STARCOS_MIN_LPKEY_ID;
  ------------------
  |  |  488|     63|#define STARCOS_MIN_LPKEY_ID	0x91
  ------------------
  498|     63|	if (prkey->key_reference > STARCOS_MAX_LPKEY_ID)
  ------------------
  |  |  489|     63|#define STARCOS_MAX_LPKEY_ID	0x9f
  ------------------
  |  Branch (498:6): [True: 0, False: 63]
  ------------------
  499|      0|		return SC_ERROR_TOO_MANY_OBJECTS;
  ------------------
  |  |   86|      0|#define SC_ERROR_TOO_MANY_OBJECTS		-1405
  ------------------
  500|     63|	return SC_SUCCESS;
  ------------------
  |  |   28|     63|#define SC_SUCCESS				0
  ------------------
  501|     63|}
pkcs15-starcos.c:starcos_create_key:
  727|     63|{
  728|     63|	struct sc_card *card = p15card->card;
  729|     63|	int	r, pin_id;
  730|     63|	u8	akd = 0, state;
  731|       |
  732|     63|	sc_file_t              *tfile;
  733|     63|	const sc_acl_entry_t   *acl_entry;
  734|     63|	sc_pkcs15_prkey_info_t *kinfo = (sc_pkcs15_prkey_info_t *)obj->data;
  735|     63|	sc_starcos_wkey_data    tkey;
  736|       |
  737|       |	/* get and verify sopin if necessary */
  738|     63|	r = sc_profile_get_file(profile, "p15_isf", &tfile);
  739|     63|        if (r < 0)
  ------------------
  |  Branch (739:13): [True: 52, False: 11]
  ------------------
  740|     52|                return r;
  741|     11|	acl_entry = sc_file_get_acl_entry(tfile, SC_AC_OP_WRITE);
  ------------------
  |  |  190|     11|#define SC_AC_OP_WRITE			24
  ------------------
  742|     11|	if (acl_entry->method  != SC_AC_NONE) {
  ------------------
  |  |  150|     11|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (742:6): [True: 0, False: 11]
  ------------------
  743|      0|		r = sc_pkcs15init_authenticate(profile, p15card, tfile, SC_AC_OP_WRITE);
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  744|      0|	}
  745|     11|	else   {
  746|     11|		r = sc_select_file(card, &tfile->path, NULL);
  747|     11|	}
  748|     11|	sc_file_free(tfile);
  749|     11|	if (r < 0)
  ------------------
  |  Branch (749:6): [True: 6, False: 5]
  ------------------
  750|      6|		return r;
  751|       |
  752|       |	/* create sc_starcos_wkey_data */
  753|      5|	tkey.mode    = 0x00;	/* install new key */
  754|      5|	tkey.kid     = (u8) kinfo->key_reference;
  755|      5|	tkey.key_header[0] = (u8) kinfo->key_reference;
  756|      5|	tkey.key_header[1] = (STARCOS_MAX_PR_KEYSIZE >> 8) & 0xff;
  ------------------
  |  |  503|      5|#define STARCOS_MAX_PR_KEYSIZE	370
  ------------------
  757|      5|	tkey.key_header[2] = STARCOS_MAX_PR_KEYSIZE & 0xff;
  ------------------
  |  |  503|      5|#define STARCOS_MAX_PR_KEYSIZE	370
  ------------------
  758|       |
  759|      5|	pin_id = sc_pkcs15init_get_pin_reference(p15card, profile, SC_AC_SYMBOLIC,
  ------------------
  |  |  155|      5|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  760|      5|			SC_PKCS15INIT_USER_PIN);
  ------------------
  |  |  171|      5|#define SC_PKCS15INIT_USER_PIN		2
  ------------------
  761|      5|	if (pin_id < 0)
  ------------------
  |  Branch (761:6): [True: 3, False: 2]
  ------------------
  762|      3|		state = STARCOS_AC_ALWAYS;
  ------------------
  |  |   36|      3|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  763|      2|	else {
  764|      2|		state  = STARCOS_PINID2STATE(pin_id);	/* get the necessary state */
  ------------------
  |  |  346|      2|#define STARCOS_PINID2STATE(a)	(((a) == STARCOS_SOPIN_GID) ? STARCOS_SOPIN_STATE : (0x0f - ((0x0f & (a)) >> 1)))
  |  |  ------------------
  |  |  |  |   38|      2|#define STARCOS_SOPIN_GID	0x01
  |  |  ------------------
  |  |               #define STARCOS_PINID2STATE(a)	(((a) == STARCOS_SOPIN_GID) ? STARCOS_SOPIN_STATE : (0x0f - ((0x0f & (a)) >> 1)))
  |  |  ------------------
  |  |  |  |   39|      2|#define STARCOS_SOPIN_STATE	0x01
  |  |  ------------------
  |  |  |  Branch (346:33): [True: 2, False: 0]
  |  |  ------------------
  ------------------
  765|      2|		state |= pin_id & 0x80 ? 0x10 : 0x00;	/* local vs. global key id */
  ------------------
  |  Branch (765:12): [True: 0, False: 2]
  ------------------
  766|      2|	}
  767|      5|	tkey.key_header[3] = state;		/* AC to access key        */
  768|      5|	if (obj->user_consent)
  ------------------
  |  Branch (768:6): [True: 0, False: 5]
  ------------------
  769|      0|		tkey.key_header[4] = 0x0f;	/* do state transition */
  770|      5|	else
  771|      5|		tkey.key_header[4] = 0x8f;	/* no state transition */
  772|      5|	tkey.key_header[5] = 0x11; /* require local state == 1 to update key */
  773|      5|	tkey.key_header[6] = 0x33;
  774|      5|	tkey.key_header[7] = 0x00;
  775|      5|	tkey.key_header[8] = 0x09;
  776|      5|	if (kinfo->usage & SC_PKCS15_PRKEY_USAGE_NONREPUDIATION)
  ------------------
  |  |  314|      5|#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION	0x200
  ------------------
  |  Branch (776:6): [True: 0, False: 5]
  ------------------
  777|      0|		akd |= 0x10;
  778|      5|	if (kinfo->usage & SC_PKCS15_PRKEY_USAGE_SIGN)
  ------------------
  |  |  307|      5|#define SC_PKCS15_PRKEY_USAGE_SIGN		0x04
  ------------------
  |  Branch (778:6): [True: 5, False: 0]
  ------------------
  779|      5|		akd |= 0x31;	/* allow DS, IA and PKCS11 */
  780|      5|	if (kinfo->usage & SC_PKCS15_PRKEY_USAGE_SIGNRECOVER)
  ------------------
  |  |  308|      5|#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER	0x08
  ------------------
  |  Branch (780:6): [True: 0, False: 5]
  ------------------
  781|      0|		akd |= 0x31;	/* allow DS, IA and PKCS11 */
  782|      5|	if (kinfo->usage & SC_PKCS15_PRKEY_USAGE_DECRYPT ||
  ------------------
  |  |  306|     10|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  |  Branch (782:6): [True: 0, False: 5]
  ------------------
  783|      5|	    kinfo->usage & SC_PKCS15_PRKEY_USAGE_UNWRAP)
  ------------------
  |  |  310|      5|#define SC_PKCS15_PRKEY_USAGE_UNWRAP		0x20
  ------------------
  |  Branch (783:6): [True: 0, False: 5]
  ------------------
  784|      0|		akd |= 0x02;
  785|      5|	tkey.key_header[9]  = akd;
  786|      5|	tkey.key_header[10] = 0x03;
  787|      5|	tkey.key_header[11] = 0xa0;
  788|      5|	tkey.key     = NULL;
  789|      5|	tkey.key_len = 0;
  790|       |
  791|      5|	return sc_card_ctl(card, SC_CARDCTL_STARCOS_WRITE_KEY, &tkey);
  792|     11|}
pkcs15-starcos.c:starcos_write_pukey:
  652|      4|{
  653|      4|	int		r;
  654|      4|	size_t		len, keylen, endpos;
  655|      4|	u8		*buf, key[280], *p, num_keys;
  656|      4|	sc_file_t	*tfile = NULL;
  657|      4|	sc_path_t	tpath;
  658|       |
  659|       |	/* get ipf profile */
  660|      4|	tpath = kinfo->path;
  661|      4|	r = sc_profile_get_file_in(profile, &tpath, "p15_ipf", &tfile);
  662|      4|	if (r < 0)
  ------------------
  |  Branch (662:6): [True: 0, False: 4]
  ------------------
  663|      0|		return r;
  664|      4|	tpath = tfile->path;
  665|      4|	sc_file_free(tfile);
  666|      4|	tfile = NULL;
  667|      4|	r = sc_select_file(card, &tpath, &tfile);
  668|      4|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|      4|#define SC_SUCCESS				0
  ------------------
  |  Branch (668:6): [True: 1, False: 3]
  ------------------
  669|       |		/* unable to select ipf */
  670|      1|		return r;
  671|      3|	len = tfile->size;
  672|      3|	sc_file_free(tfile);
  673|      3|	if (len == 0)
  ------------------
  |  Branch (673:6): [True: 3, False: 0]
  ------------------
  674|      3|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      3|#define SC_ERROR_INTERNAL			-1400
  ------------------
  675|      0|	buf = malloc(len);
  676|      0|	if (!buf)
  ------------------
  |  Branch (676:6): [True: 0, False: 0]
  ------------------
  677|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  678|       |	/* read the complete IPF */
  679|      0|	r = sc_read_binary(card, 0, buf, len, 0);
  680|      0|	if (r < 0 || r != (int)len) {
  ------------------
  |  Branch (680:6): [True: 0, False: 0]
  |  Branch (680:15): [True: 0, False: 0]
  ------------------
  681|      0|		free(buf);
  682|      0|		return r;
  683|      0|	}
  684|       |	/* get/fix number of keys */
  685|      0|	num_keys = buf[0];
  686|      0|	if (num_keys == 0xff)
  ------------------
  |  Branch (686:6): [True: 0, False: 0]
  ------------------
  687|      0|		num_keys = 0;
  688|       |	/* encode public key */
  689|      0|	keylen = starcos_encode_pukey(rsa, NULL, kinfo);
  690|      0|	if (!keylen) {
  ------------------
  |  Branch (690:6): [True: 0, False: 0]
  ------------------
  691|      0|		free(buf);
  692|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  693|      0|	}
  694|      0|	p = key;
  695|      0|	*p++ = (u8) kinfo->key_reference;
  696|      0|	*p++ = (keylen >> 8) & 0xff;
  697|      0|	*p++ = keylen & 0xff;
  698|      0|	*p++ = STARCOS_AC_ALWAYS;	/* AC WRITE etc XXX */
  ------------------
  |  |   36|      0|#define STARCOS_AC_ALWAYS	0x9f
  ------------------
  699|      0|	*p++ = 0x0f;
  700|      0|	*p++ = 0;
  701|      0|	*p++ = 0x09;			/* ALGO XXX */
  702|      0|	*p++ = 0x4a;			/* AKD  XXX */
  703|      0|	*p++ = ((keylen >> 8) & 0xff) | 0x80;
  704|      0|	*p++ = keylen & 0xff;
  705|      0|	r = starcos_encode_pukey(rsa, p, kinfo);
  706|      0|	if (r != SC_SUCCESS) {
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (706:6): [True: 0, False: 0]
  ------------------
  707|      0|		free(buf);
  708|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  709|      0|	}
  710|      0|	p   += keylen;
  711|      0|	*p++ = 0x04;				/* CPI */
  712|      0|	*p = (u8) kinfo->key_reference;	/* CHA */
  713|       |	/* updated IPF (XXX: currently append only) */
  714|      0|	num_keys++;
  715|      0|	r = sc_update_binary(card, 0, &num_keys, 1, 0);
  716|      0|	if (r < 0) {
  ------------------
  |  Branch (716:6): [True: 0, False: 0]
  ------------------
  717|      0|		free(buf);
  718|      0|		return r;
  719|      0|	}
  720|      0|	endpos = starcos_ipf_get_lastpos(buf, len);
  721|      0|	free(buf);
  722|      0|	return sc_update_binary(card, (unsigned)endpos, key, keylen + 12, 0);
  723|      0|}
pkcs15-starcos.c:starcos_generate_key:
  840|      4|{
  841|      4|	int r;
  842|      4|	const sc_acl_entry_t   *acl_entry;
  843|      4|	sc_file_t              *tfile;
  844|      4|	sc_starcos_gen_key_data	gendat;
  845|      4|	sc_pkcs15_prkey_info_t *kinfo = (sc_pkcs15_prkey_info_t *) obj->data;
  846|       |
  847|      4|	if (obj->type != SC_PKCS15_TYPE_PRKEY_RSA)
  ------------------
  |  |  419|      4|#define SC_PKCS15_TYPE_PRKEY_RSA		0x101
  ------------------
  |  Branch (847:6): [True: 0, False: 4]
  ------------------
  848|      0|		return SC_ERROR_NOT_SUPPORTED;
  ------------------
  |  |   89|      0|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  849|       |
  850|       |	/* get and verify sopin if necessary */
  851|      4|	r = sc_profile_get_file(profile, "p15_isf", &tfile);
  852|      4|        if (r < 0)
  ------------------
  |  Branch (852:13): [True: 0, False: 4]
  ------------------
  853|      0|                return r;
  854|      4|	acl_entry = sc_file_get_acl_entry(tfile, SC_AC_OP_WRITE);
  ------------------
  |  |  190|      4|#define SC_AC_OP_WRITE			24
  ------------------
  855|      4|	if (acl_entry->method  != SC_AC_NONE) {
  ------------------
  |  |  150|      4|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (855:6): [True: 0, False: 4]
  ------------------
  856|      0|		r = sc_pkcs15init_authenticate(profile, p15card, tfile, SC_AC_OP_WRITE);
  ------------------
  |  |  190|      0|#define SC_AC_OP_WRITE			24
  ------------------
  857|      0|	}
  858|      4|	sc_file_free(tfile);
  859|      4|	if (r < 0)
  ------------------
  |  Branch (859:6): [True: 0, False: 4]
  ------------------
  860|      0|		return r;
  861|       |
  862|       |	/* XXX It would be better to write the public key header
  863|       |	 * in the IPF when the private key header is created, but
  864|       |	 * as we don't know the size of the exponent at this time
  865|       |	 * we would waste space.
  866|       |	 */
  867|       |	/* create (empty) public key entry */
  868|      4|	r = starcos_write_pukey(profile, p15card->card, NULL, kinfo);
  869|      4|	if (r < 0)
  ------------------
  |  Branch (869:6): [True: 4, False: 0]
  ------------------
  870|      4|		return r;
  871|       |	/* generate key pair */
  872|      0|	gendat.key_id     = (u8) kinfo->key_reference;
  873|      0|	gendat.key_length = (size_t) kinfo->modulus_length;
  874|      0|	gendat.modulus    = NULL;
  875|      0|	r = sc_card_ctl(p15card->card, SC_CARDCTL_STARCOS_GENERATE_KEY, &gendat);
  876|      0|	if (r != SC_SUCCESS)
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  |  Branch (876:6): [True: 0, False: 0]
  ------------------
  877|      0|		return r;
  878|       |	/* get the modulus via READ PUBLIC KEY */
  879|      0|	if (pubkey) {
  ------------------
  |  Branch (879:6): [True: 0, False: 0]
  ------------------
  880|      0|		u8 *buf;
  881|      0|		struct sc_pkcs15_pubkey_rsa *rsa = &pubkey->u.rsa;
  882|       |		/* set the modulus */
  883|      0|		rsa->modulus.data = gendat.modulus;
  884|      0|		rsa->modulus.len  = kinfo->modulus_length >> 3;
  885|       |		/* set the exponent (always 0x10001) */
  886|      0|		buf = malloc(3);
  887|      0|		if (!buf)
  ------------------
  |  Branch (887:7): [True: 0, False: 0]
  ------------------
  888|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  889|      0|		buf[0] = 0x01;
  890|      0|		buf[1] = 0x00;
  891|      0|		buf[2] = 0x01;
  892|      0|		rsa->exponent.data = buf;
  893|      0|		rsa->exponent.len  = 3;
  894|       |
  895|      0|		pubkey->algorithm = SC_ALGORITHM_RSA;
  ------------------
  |  |   78|      0|#define SC_ALGORITHM_RSA		0
  ------------------
  896|      0|	} else
  897|       |		/* free public key */
  898|      0|		free(gendat.modulus);
  899|       |
  900|      0|	return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  901|      0|}
pkcs15-starcos.c:starcos_finalize_card:
  904|     63|{
  905|     63|	int       r;
  906|     63|	sc_file_t tfile;
  907|     63|	sc_path_t tpath;
  908|       |
  909|       |	/* SELECT FILE MF */
  910|     63|	sc_format_path("3F00", &tpath);
  911|     63|	r = sc_select_file(card, &tpath, NULL);
  912|     63|	if (r < 0)
  ------------------
  |  Branch (912:6): [True: 30, False: 33]
  ------------------
  913|     30|		return r;
  914|       |
  915|       |	/* call CREATE END for the MF (ignore errors) */
  916|     33|	tfile.type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     33|#define SC_FILE_TYPE_DF			0x04
  ------------------
  917|     33|	tfile.id   = 0x3f00;
  918|     33|	r = sc_card_ctl(card, SC_CARDCTL_STARCOS_CREATE_END, &tfile);
  919|     33|	if (r < 0)
  ------------------
  |  Branch (919:6): [True: 14, False: 19]
  ------------------
  920|     14|		sc_log(card->ctx,  "failed to call CREATE END for the MF\n");
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  921|       |	/* call CREATE END for the apps (pkcs15) DF */
  922|     33|	tfile.type = SC_FILE_TYPE_DF;
  ------------------
  |  |  214|     33|#define SC_FILE_TYPE_DF			0x04
  ------------------
  923|     33|	tfile.id   = 0x5015;
  924|     33|	r = sc_card_ctl(card, SC_CARDCTL_STARCOS_CREATE_END, &tfile);
  925|     33|	if (r == SC_ERROR_NOT_ALLOWED)
  ------------------
  |  |   59|     33|#define SC_ERROR_NOT_ALLOWED			-1209
  ------------------
  |  Branch (925:6): [True: 0, False: 33]
  ------------------
  926|       |		/* card is already finalized */
  927|      0|		return SC_SUCCESS;
  ------------------
  |  |   28|      0|#define SC_SUCCESS				0
  ------------------
  928|     33|	return r;
  929|     33|}

sc_profile_new:
  291|  3.45k|{
  292|  3.45k|	struct sc_pkcs15_card *p15card;
  293|  3.45k|	struct sc_profile *pro;
  294|       |
  295|  3.45k|	pro = calloc(1, sizeof(*pro));
  296|  3.45k|	if (pro == NULL)
  ------------------
  |  Branch (296:6): [True: 0, False: 3.45k]
  ------------------
  297|      0|		return NULL;
  298|  3.45k|	pro->p15_spec = p15card = sc_pkcs15_card_new();
  299|       |
  300|  3.45k|	pro->pkcs15.do_last_update = 1;
  301|       |
  302|  3.45k|	if (p15card) {
  ------------------
  |  Branch (302:6): [True: 3.45k, False: 0]
  ------------------
  303|  3.45k|		p15card->tokeninfo->label = strdup("OpenSC Card");
  304|  3.45k|		p15card->tokeninfo->manufacturer_id = strdup("OpenSC Project");
  305|  3.45k|		p15card->tokeninfo->serial_number = strdup("0000");
  306|  3.45k|		p15card->tokeninfo->flags = SC_PKCS15_TOKEN_EID_COMPLIANT;
  ------------------
  |  |  598|  3.45k|#define SC_PKCS15_TOKEN_EID_COMPLIANT			0x08
  ------------------
  307|  3.45k|		p15card->tokeninfo->version = 0;
  308|       |
  309|       |		/* Set up EF(TokenInfo) and EF(ODF) */
  310|  3.45k|		p15card->file_tokeninfo = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|  3.45k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  311|  3.45k|		p15card->file_odf = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|  3.45k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  312|  3.45k|		p15card->file_unusedspace = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|  3.45k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  313|  3.45k|	}
  314|       |
  315|       |	/* Assume card does RSA natively */
  316|  3.45k|	pro->rsa_access_flags = DEF_PRKEY_RSA_ACCESS;
  ------------------
  |  |   53|  3.45k|#define DEF_PRKEY_RSA_ACCESS	0x1D
  ------------------
  317|  3.45k|	pro->pin_encoding = SC_PKCS15_PIN_TYPE_ASCII_NUMERIC;
  ------------------
  |  |   89|  3.45k|#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC		1
  ------------------
  318|  3.45k|	pro->pin_minlen = 4;
  319|  3.45k|	pro->pin_maxlen = 8;
  320|  3.45k|	pro->id_style = SC_PKCS15INIT_ID_STYLE_NATIVE;
  ------------------
  |  |  165|  3.45k|#define SC_PKCS15INIT_ID_STYLE_NATIVE		0
  ------------------
  321|       |
  322|  3.45k|	return pro;
  323|  3.45k|}
sc_profile_finish:
  391|  3.06k|{
  392|  3.06k|	struct sc_context *ctx = profile->card->ctx;
  393|  3.06k|	struct file_info *fi;
  394|  3.06k|	struct pin_info	*pi;
  395|  3.06k|	char		reason[64];
  396|       |
  397|  3.06k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.06k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.06k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.06k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.06k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.06k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  398|  3.06k|	profile->mf_info = sc_profile_find_file(profile, NULL, "MF");
  399|  3.06k|	if (!profile->mf_info)
  ------------------
  |  Branch (399:6): [True: 290, False: 2.77k]
  ------------------
  400|  3.06k|		LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Profile doesn't define a MF");
  ------------------
  |  |  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: 290, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  169|    290|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, SC_COLOR_FG_RED, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|    290|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  170|    290|			"%s: %d (%s)\n", (text), _ret, sc_strerror(_ret)); \
  |  |  |  |  171|    290|		return _ret; \
  |  |  |  |  172|    290|	} \
  |  |  |  |  173|    290|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  401|       |
  402|  2.77k|	if (app_info && app_info->aid.len)   {
  ------------------
  |  Branch (402:6): [True: 0, False: 2.77k]
  |  Branch (402:18): [True: 0, False: 0]
  ------------------
  403|      0|		struct sc_path path;
  404|       |
  405|      0|		sc_log(ctx, "finish profile with '%s' application profile", app_info->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__
  |  |  ------------------
  ------------------
  406|      0|		memset(&path, 0, sizeof(struct sc_path));
  407|      0|		path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|      0|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  408|      0|		path.aid = app_info->aid;
  409|       |
  410|      0|		sc_log(ctx, "Look for file by path '%s'", 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__
  |  |  ------------------
  ------------------
  411|      0|		profile->df_info = sc_profile_find_file_by_path(profile, &path);
  412|      0|		sc_log(ctx, "returned DF info %p", profile->df_info);
  ------------------
  |  |   71|      0|#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|      0|		if (profile->df_info && profile->df_info->profile_extension)   {
  ------------------
  |  Branch (413:7): [True: 0, False: 0]
  |  Branch (413:27): [True: 0, False: 0]
  ------------------
  414|      0|			sc_log(ctx, "application profile extension '%s'", profile->df_info->profile_extension);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  415|      0|			if (sc_profile_load(profile, profile->df_info->profile_extension))
  ------------------
  |  Branch (415:8): [True: 0, False: 0]
  ------------------
  416|      0|				LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Cannot load application profile extension");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  417|      0|		}
  418|      0|	}
  419|       |
  420|  2.77k|	profile->df_info = sc_profile_find_file(profile, NULL, "PKCS15-AppDF");
  421|  2.77k|	if (!profile->df_info)
  ------------------
  |  Branch (421:6): [True: 26, False: 2.75k]
  ------------------
  422|  2.77k|		LOG_TEST_RET(ctx, SC_ERROR_INCONSISTENT_PROFILE, "Profile doesn't define a PKCS15-AppDF");
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  423|       |
  424|  2.75k|	profile->p15_spec->file_app = profile->df_info->file;
  425|  2.75k|	profile->df_info->dont_free = 1;
  426|       |
  427|  4.34k|	for (pi = profile->pin_list; pi; pi = pi->next) {
  ------------------
  |  Branch (427:31): [True: 1.59k, False: 2.75k]
  ------------------
  428|  1.59k|		const char	*name;
  429|       |
  430|  1.59k|		set_pin_defaults(profile, pi);
  431|  1.59k|		if (!(name = pi->file_name))
  ------------------
  |  Branch (431:7): [True: 1.59k, False: 0]
  ------------------
  432|  1.59k|			continue;
  433|      0|		if (!(fi = sc_profile_find_file(profile, NULL, name))) {
  ------------------
  |  Branch (433:7): [True: 0, False: 0]
  ------------------
  434|      0|			snprintf(reason, sizeof(reason), "unknown PIN file \"%s\"\n", name);
  435|      0|			goto whine;
  436|      0|		}
  437|       |
  438|      0|		pi->file = fi;
  439|      0|	}
  440|  2.75k|	LOG_FUNC_RETURN(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  441|       |
  442|      0|whine:
  443|      0|	sc_log(ctx, "%s", reason);
  ------------------
  |  |   71|      0|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  444|      0|	LOG_FUNC_RETURN(ctx, SC_ERROR_INCONSISTENT_PROFILE);
  ------------------
  |  |  164|      0|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|      0|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|      0|	int _ret = r; \
  |  |  |  |  155|      0|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|      0|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|      0|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|      0|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|      0|	return _ret; \
  |  |  |  |  163|      0|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  445|      0|}
sc_profile_free:
  449|  5.03k|{
  450|  5.03k|	struct auth_info *ai;
  451|  5.03k|	struct pin_info *pi;
  452|  5.03k|	sc_macro_t	*mi;
  453|  5.03k|	sc_template_t	*ti;
  454|       |
  455|  5.03k|	if (profile->name)
  ------------------
  |  Branch (455:6): [True: 3.27k, False: 1.76k]
  ------------------
  456|  3.27k|		free(profile->name);
  457|  5.03k|	if (profile->driver)
  ------------------
  |  Branch (457:6): [True: 2, False: 5.03k]
  ------------------
  458|      2|		free(profile->driver);
  459|       |
  460|  5.03k|	free_file_list(&profile->ef_list);
  461|       |
  462|  5.03k|	while ((ai = profile->auth_list) != NULL) {
  ------------------
  |  Branch (462:9): [True: 0, False: 5.03k]
  ------------------
  463|      0|		profile->auth_list = ai->next;
  464|      0|		free(ai);
  465|      0|	}
  466|       |
  467|  6.61k|	while ((ti = profile->template_list) != NULL) {
  ------------------
  |  Branch (467:9): [True: 1.58k, False: 5.03k]
  ------------------
  468|  1.58k|		profile->template_list = ti->next;
  469|  1.58k|		if (ti->data)
  ------------------
  |  Branch (469:7): [True: 1.58k, False: 0]
  ------------------
  470|  1.58k|			sc_profile_free(ti->data);
  471|  1.58k|		if (ti->name)
  ------------------
  |  Branch (471:7): [True: 1.58k, False: 0]
  ------------------
  472|  1.58k|			free(ti->name);
  473|  1.58k|		free(ti);
  474|  1.58k|	}
  475|       |
  476|  7.37k|	while ((mi = profile->macro_list) != NULL) {
  ------------------
  |  Branch (476:9): [True: 2.33k, False: 5.03k]
  ------------------
  477|  2.33k|		profile->macro_list = mi->next;
  478|  2.33k|		if (mi->name)
  ------------------
  |  Branch (478:7): [True: 2.33k, False: 0]
  ------------------
  479|  2.33k|			free(mi->name);
  480|  2.33k|		free(mi);
  481|  2.33k|	}
  482|       |
  483|  13.4k|	while ((pi = profile->pin_list) != NULL) {
  ------------------
  |  Branch (483:9): [True: 8.42k, False: 5.03k]
  ------------------
  484|  8.42k|		profile->pin_list = pi->next;
  485|  8.42k|		if (pi->file_name)
  ------------------
  |  Branch (485:7): [True: 10, False: 8.41k]
  ------------------
  486|     10|			free(pi->file_name);
  487|  8.42k|		free(pi);
  488|  8.42k|	}
  489|       |
  490|  5.06k|	for (int i = 0; profile->options[i]; i++) {
  ------------------
  |  Branch (490:18): [True: 26, False: 5.03k]
  ------------------
  491|     26|		free(profile->options[i]);
  492|     26|	}
  493|       |
  494|  5.03k|	if (profile->p15_spec)
  ------------------
  |  Branch (494:6): [True: 3.45k, False: 1.58k]
  ------------------
  495|  3.45k|		sc_pkcs15_card_free(profile->p15_spec);
  496|       |
  497|  5.03k|	if (profile->dll)
  ------------------
  |  Branch (497:6): [True: 0, False: 5.03k]
  ------------------
  498|      0|		sc_dlclose(profile->dll);
  499|       |
  500|  5.03k|	free(profile);
  501|  5.03k|}
sc_profile_get_pin_info:
  506|  12.0k|{
  507|  12.0k|	struct pin_info	*pi;
  508|       |
  509|  12.0k|	pi = new_pin(profile, id);
  510|  12.0k|	if (pi == NULL)
  ------------------
  |  Branch (510:6): [True: 0, False: 12.0k]
  ------------------
  511|      0|		return;
  512|       |
  513|  12.0k|	pi->pin.max_tries = pi->pin.tries_left;
  514|  12.0k|	*info = pi->pin;
  515|  12.0k|}
sc_profile_get_pin_retries:
  519|      4|{
  520|      4|	struct pin_info	*pi;
  521|       |
  522|      4|	pi = new_pin(profile, id);
  523|      4|	if (pi == NULL)
  ------------------
  |  Branch (523:6): [True: 0, False: 4]
  ------------------
  524|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  525|      4|	return pi->pin.tries_left;
  526|      4|}
sc_profile_get_pin_id:
  531|      1|{
  532|      1|	struct pin_info	*pi;
  533|       |
  534|      4|	for (pi = profile->pin_list; pi; pi = pi->next) {
  ------------------
  |  Branch (534:31): [True: 3, False: 1]
  ------------------
  535|      3|		if (pi->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|      3|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (535:7): [True: 0, False: 3]
  ------------------
  536|      0|			continue;
  537|      3|		if (pi->pin.attrs.pin.reference == (int)reference) {
  ------------------
  |  Branch (537:7): [True: 0, False: 3]
  ------------------
  538|      0|			*id = pi->id;
  539|      0|			return 0;
  540|      0|		}
  541|       |
  542|      3|	}
  543|      1|	return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      1|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  544|      1|}
sc_profile_get_file_in:
  549|      4|{
  550|      4|	struct file_info *fi;
  551|       |
  552|      4|	if ((fi = sc_profile_find_file(profile, path, name)) == NULL)
  ------------------
  |  Branch (552:6): [True: 0, False: 4]
  ------------------
  553|      0|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  554|      4|	sc_file_dup(ret, fi->file);
  555|      4|	if (*ret == NULL)
  ------------------
  |  Branch (555:6): [True: 0, False: 4]
  ------------------
  556|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  557|      4|	return 0;
  558|      4|}
sc_profile_get_file:
  563|  5.45k|{
  564|  5.45k|	struct file_info *fi;
  565|       |
  566|  5.45k|	if ((fi = sc_profile_find_file(profile, NULL, name)) == NULL)
  ------------------
  |  Branch (566:6): [True: 3.53k, False: 1.92k]
  ------------------
  567|  3.53k|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|  3.53k|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
  568|  1.92k|	sc_file_dup(ret, fi->file);
  569|  1.92k|	if (*ret == NULL)
  ------------------
  |  Branch (569:6): [True: 0, False: 1.92k]
  ------------------
  570|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  571|  1.92k|	return 0;
  572|  1.92k|}
sc_profile_get_file_instance:
  577|  14.1k|{
  578|  14.1k|	struct sc_context *ctx = profile->card->ctx;
  579|  14.1k|	struct file_info *fi;
  580|  14.1k|	struct sc_file *file;
  581|  14.1k|	int r;
  582|       |
  583|  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  584|  14.1k|	sc_log(ctx, "try to get '%s' file instance", name);
  ------------------
  |  |   71|  14.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__
  |  |  ------------------
  ------------------
  585|       |
  586|  14.1k|	if ((fi = sc_profile_find_file(profile, NULL, name)) == NULL)
  ------------------
  |  Branch (586:6): [True: 9.94k, False: 4.16k]
  ------------------
  587|  14.1k|		LOG_FUNC_RETURN(ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|  9.94k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  9.94k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  9.94k|	int _ret = r; \
  |  |  |  |  155|  9.94k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 9.94k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  9.94k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.94k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 9.94k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  9.94k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  9.94k|	} else { \
  |  |  |  |  159|      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.94k|	return _ret; \
  |  |  |  |  163|  9.94k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  588|  4.16k|	sc_file_dup(&file, fi->file);
  589|  4.16k|	sc_log(ctx, "ident '%s'; parent '%s'", fi->ident, fi->parent ? fi->parent->ident : "(null)");
  ------------------
  |  |   71|  8.33k|#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.09k, False: 1.07k]
  |  |  ------------------
  ------------------
  590|  4.16k|	if (file == NULL)
  ------------------
  |  Branch (590:6): [True: 0, False: 4.16k]
  ------------------
  591|  4.16k|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  592|  4.16k|	sc_log(ctx, "file (type:%X, path:'%s')", file->type, sc_print_path(&file->path));
  ------------------
  |  |   71|  4.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__
  |  |  ------------------
  ------------------
  593|       |
  594|  4.16k|	file->id += index;
  595|  4.16k|        if(file->type == SC_FILE_TYPE_BSO) {
  ------------------
  |  |  217|  4.16k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (595:12): [True: 0, False: 4.16k]
  ------------------
  596|      0|		r = sc_profile_add_file(profile, name, file);
  597|      0|		if (r < 0)
  ------------------
  |  Branch (597:7): [True: 0, False: 0]
  ------------------
  598|      0|			sc_file_free(file);
  599|      0|		LOG_TEST_RET(ctx, r, "Profile error: cannot add BSO 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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  600|      0|	}
  601|  4.16k|	else if (file->path.len)   {
  ------------------
  |  Branch (601:11): [True: 435, False: 3.73k]
  ------------------
  602|    435|		file->path.value[file->path.len - 2] = (file->id >> 8) & 0xFF;
  603|    435|		file->path.value[file->path.len - 1] = file->id & 0xFF;
  604|       |
  605|    435|		r = sc_profile_add_file(profile, name, file);
  606|    435|		if (r < 0)
  ------------------
  |  Branch (606:7): [True: 40, False: 395]
  ------------------
  607|     40|			sc_file_free(file);
  608|    435|		LOG_TEST_RET(ctx, r, "Profile error: cannot add file");
  ------------------
  |  |  174|    435|#define LOG_TEST_RET(ctx, r, text) SC_TEST_RET((ctx), SC_LOG_DEBUG_NORMAL, (r), (text))
  |  |  ------------------
  |  |  |  |  166|    435|#define SC_TEST_RET(ctx, level, r, text) do { \
  |  |  |  |  167|    435|	int _ret = (r); \
  |  |  |  |  168|    435|	if (_ret < 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (168:6): [True: 40, False: 395]
  |  |  |  |  ------------------
  |  |  |  |  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|    435|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (173:9): [Folded, False: 395]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  609|    435|	}
  610|       |
  611|  4.12k|	if (ret)
  ------------------
  |  Branch (611:6): [True: 4.12k, False: 0]
  ------------------
  612|  4.12k|		*ret = file;
  613|      0|	else
  614|      0|		sc_file_free(file);
  615|       |
  616|  4.12k|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|  4.12k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  4.12k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  4.12k|	int _ret = r; \
  |  |  |  |  155|  4.12k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 4.12k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  4.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: 4.12k]
  |  |  |  |  ------------------
  |  |  |  |  157|  4.12k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  4.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|  4.12k|	return _ret; \
  |  |  |  |  163|  4.12k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  617|  4.12k|}
sc_profile_get_file_by_path:
  634|  3.53k|{
  635|  3.53k|	struct sc_context *ctx = profile->card->ctx;
  636|  3.53k|	struct file_info *fi;
  637|       |
  638|  3.53k|	LOG_FUNC_CALLED(ctx);
  ------------------
  |  |  151|  3.53k|#define LOG_FUNC_CALLED(ctx) SC_FUNC_CALLED((ctx), SC_LOG_DEBUG_NORMAL)
  |  |  ------------------
  |  |  |  |  148|  3.53k|#define SC_FUNC_CALLED(ctx, level) do { \
  |  |  |  |  149|  3.53k|	 sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, "called\n"); \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  150|  3.53k|} while (0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (150:10): [Folded, False: 3.53k]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  639|  3.53k|	if ((fi = sc_profile_find_file_by_path(profile, path)) == NULL)
  ------------------
  |  Branch (639:6): [True: 1.49k, False: 2.03k]
  ------------------
  640|  3.53k|		LOG_FUNC_RETURN(ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  164|  1.49k|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|  1.49k|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|  1.49k|	int _ret = r; \
  |  |  |  |  155|  1.49k|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 1.49k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|  1.49k|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_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.49k|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 1.49k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  157|  1.49k|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|  1.49k|	} else { \
  |  |  |  |  159|      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.49k|	return _ret; \
  |  |  |  |  163|  1.49k|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  641|  2.03k|	sc_file_dup(ret, fi->file);
  642|  2.03k|	LOG_FUNC_RETURN(ctx, *ret ? SC_SUCCESS : SC_ERROR_OUT_OF_MEMORY);
  ------------------
  |  |  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|  4.07k|	int _ret = r; \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (154:13): [True: 2.03k, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  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|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 2.03k]
  |  |  |  |  ------------------
  |  |  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  643|  2.03k|}
sc_profile_add_file:
  647|    440|{
  648|    440|	struct sc_context *ctx = profile->card->ctx;
  649|    440|	sc_path_t	path = file->path;
  650|    440|	struct file_info	*parent;
  651|       |
  652|    440|	LOG_FUNC_CALLED(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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  653|    440|	if (!path.len)   {
  ------------------
  |  Branch (653:6): [True: 0, False: 440]
  ------------------
  654|      0|		parent = profile->df_info;
  655|    440|	} else {
  656|    440|		path.len -= 2;
  657|    440|		parent = sc_profile_find_file_by_path(profile, &path);
  658|    440|	}
  659|    440|	if (!parent)
  ------------------
  |  Branch (659:6): [True: 45, False: 395]
  ------------------
  660|    440|		LOG_FUNC_RETURN(ctx, SC_ERROR_FILE_NOT_FOUND);
  ------------------
  |  |  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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  661|    395|	sc_log(ctx, "Parent path:%s", sc_print_path(&parent->file->path));
  ------------------
  |  |   71|    395|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  662|       |
  663|    395|	sc_file_dup(&file, file);
  664|    395|	if (file == NULL)
  ------------------
  |  Branch (664:6): [True: 0, False: 395]
  ------------------
  665|    395|		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]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  666|       |
  667|    395|	add_file(profile, name, file, parent);
  668|    395|	LOG_FUNC_RETURN(ctx, SC_SUCCESS);
  ------------------
  |  |  164|    395|#define LOG_FUNC_RETURN(ctx, r) SC_FUNC_RETURN((ctx), SC_LOG_DEBUG_NORMAL, (r))
  |  |  ------------------
  |  |  |  |  153|    395|#define SC_FUNC_RETURN(ctx, level, r) do { \
  |  |  |  |  154|    395|	int _ret = r; \
  |  |  |  |  155|    395|	if (_ret <= 0) { \
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (155:6): [True: 395, False: 0]
  |  |  |  |  ------------------
  |  |  |  |  156|    395|		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |               		sc_do_log_color(ctx, level, FILENAME, __LINE__, __FUNCTION__, _ret ? SC_COLOR_FG_RED : 0, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   44|      0|#define SC_COLOR_FG_RED			0x0001
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (156:65): [True: 0, False: 395]
  |  |  |  |  ------------------
  |  |  |  |  157|    395|			"returning with: %d (%s)\n", _ret, sc_strerror(_ret)); \
  |  |  |  |  158|    395|	} else { \
  |  |  |  |  159|      0|		sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, \
  |  |  |  |  ------------------
  |  |  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  |  |  ------------------
  |  |  |  |  160|      0|			"returning with: %d\n", _ret); \
  |  |  |  |  161|      0|	} \
  |  |  |  |  162|    395|	return _ret; \
  |  |  |  |  163|    395|} while(0)
  |  |  |  |  ------------------
  |  |  |  |  |  Branch (163:9): [Folded, False: 0]
  |  |  |  |  ------------------
  |  |  ------------------
  ------------------
  669|    395|}
sc_profile_instantiate_template:
  679|  14.3k|{
  680|  14.3k|	struct sc_context *ctx = profile->card->ctx;
  681|  14.3k|	struct sc_profile	*tmpl;
  682|  14.3k|	struct sc_template	*info;
  683|  14.3k|	unsigned int	idx;
  684|  14.3k|	struct file_info *fi, *base_file, *match = NULL;
  685|       |
  686|       |#ifdef DEBUG_PROFILE
  687|       |	printf("Instantiate %s in template %s\n", file_name, template_name);
  688|       |	sc_profile_find_file_by_path(profile, base_path);
  689|       |#endif
  690|  14.5k|	for (info = profile->template_list; info; info = info->next)
  ------------------
  |  Branch (690:38): [True: 297, False: 14.2k]
  ------------------
  691|    297|		if (!strcmp(info->name, template_name))
  ------------------
  |  Branch (691:7): [True: 108, False: 189]
  ------------------
  692|    108|			break;
  693|  14.3k|	if (info == NULL)   {
  ------------------
  |  Branch (693:6): [True: 14.2k, False: 108]
  ------------------
  694|  14.2k|		sc_log(ctx, "Template %s not found", template_name);
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  695|  14.2k|		return SC_ERROR_TEMPLATE_NOT_FOUND;
  ------------------
  |  |  110|  14.2k|#define SC_ERROR_TEMPLATE_NOT_FOUND		-1508
  ------------------
  696|  14.2k|	}
  697|       |
  698|    108|	tmpl = info->data;
  699|    108|	idx = id->value[id->len-1];
  700|  1.37k|	for (fi = profile->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (700:30): [True: 1.28k, False: 89]
  ------------------
  701|  1.28k|		if (fi->base_template == tmpl
  ------------------
  |  Branch (701:7): [True: 568, False: 716]
  ------------------
  702|    568|		 && fi->inst_index == idx
  ------------------
  |  Branch (702:7): [True: 544, False: 24]
  ------------------
  703|    544|		 && sc_compare_path(&fi->inst_path, base_path)
  ------------------
  |  Branch (703:7): [True: 544, False: 0]
  ------------------
  704|    544|		 && !strcmp(fi->ident, file_name)) {
  ------------------
  |  Branch (704:7): [True: 19, False: 525]
  ------------------
  705|     19|			sc_file_dup(ret, fi->file);
  706|     19|			if (*ret == NULL)
  ------------------
  |  Branch (706:8): [True: 0, False: 19]
  ------------------
  707|      0|				return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  708|     19|			return 0;
  709|     19|		}
  710|  1.28k|	}
  711|       |
  712|     89|	sc_log(ctx, "Instantiating template %s at %s", template_name, sc_print_path(base_path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  713|       |
  714|     89|	base_file = sc_profile_find_file_by_path(profile, base_path);
  715|     89|	if (base_file == NULL) {
  ------------------
  |  Branch (715:6): [True: 3, False: 86]
  ------------------
  716|      3|		sc_log(ctx, "Directory %s not defined in profile", sc_print_path(base_path));
  ------------------
  |  |   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__
  |  |  ------------------
  ------------------
  717|      3|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|      3|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  718|      3|	}
  719|       |
  720|       |	/* This loop relies on the fact that new files are always
  721|       |	 * appended to the list, after the parent files they refer to
  722|       |	 */
  723|     86|	if (base_file->instance == NULL)
  ------------------
  |  Branch (723:6): [True: 0, False: 86]
  ------------------
  724|      0|		return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|      0|#define SC_ERROR_INTERNAL			-1400
  ------------------
  725|    334|	for (fi = tmpl->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (725:27): [True: 248, False: 86]
  ------------------
  726|    248|		struct file_info	*parent, *instance;
  727|    248|		unsigned int	skew = 0;
  728|       |
  729|    248|		fi->instance = NULL;
  730|    248|		if ((parent = fi->parent) == NULL) {
  ------------------
  |  Branch (730:7): [True: 163, False: 85]
  ------------------
  731|    163|			parent = base_file;
  732|    163|			skew = idx;
  733|    163|		}
  734|    248|		parent = parent->instance;
  735|       |
  736|    248|		instance = sc_profile_instantiate_file(profile, fi, parent, skew);
  737|    248|		if (instance == NULL)
  ------------------
  |  Branch (737:7): [True: 0, False: 248]
  ------------------
  738|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  739|    248|		instance->base_template = tmpl;
  740|    248|		instance->inst_index = idx;
  741|    248|		instance->inst_path = *base_path;
  742|       |
  743|    248|		if (!strcmp(instance->ident, file_name))
  ------------------
  |  Branch (743:7): [True: 6, False: 242]
  ------------------
  744|      6|			match = instance;
  745|    248|	}
  746|       |
  747|     86|	if (match == NULL) {
  ------------------
  |  Branch (747:6): [True: 80, False: 6]
  ------------------
  748|     80|		sc_log(ctx, "No file named \"%s\" in template \"%s\"",
  ------------------
  |  |   71|     80|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  749|     80|				file_name, template_name);
  750|     80|		return SC_ERROR_OBJECT_NOT_FOUND;
  ------------------
  |  |   88|     80|#define SC_ERROR_OBJECT_NOT_FOUND		-1407
  ------------------
  751|     80|	}
  752|      6|	sc_file_dup(ret, match->file);
  753|      6|	if (*ret == NULL)
  ------------------
  |  Branch (753:6): [True: 0, False: 6]
  ------------------
  754|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
  755|       |#ifdef DEBUG_PROFILE
  756|       |	printf("Template instantiated\n");
  757|       |#endif
  758|      6|	return 0;
  759|      6|}
sc_profile_get_pin_id_by_reference:
  806|  1.43k|{
  807|  1.43k|	struct pin_info *pinfo;
  808|       |
  809|  2.68k|	for (pinfo = profile->pin_list; pinfo; pinfo = pinfo->next)  {
  ------------------
  |  Branch (809:34): [True: 2.30k, False: 376]
  ------------------
  810|  2.30k|		if (auth_method == SC_AC_SYMBOLIC)   {
  ------------------
  |  |  155|  2.30k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
  |  Branch (810:7): [True: 1.88k, False: 420]
  ------------------
  811|  1.88k|			if (pinfo->id != reference)
  ------------------
  |  Branch (811:8): [True: 844, False: 1.04k]
  ------------------
  812|    844|				continue;
  813|  1.88k|		}
  814|    420|		else   {
  815|    420|			if (pinfo->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|    420|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (815:8): [True: 0, False: 420]
  ------------------
  816|      0|				continue;
  817|    420|			if (pinfo->pin.auth_method != auth_method)
  ------------------
  |  Branch (817:8): [True: 103, False: 317]
  ------------------
  818|    103|				continue;
  819|    317|			if (pinfo->pin.attrs.pin.reference != reference)
  ------------------
  |  Branch (819:8): [True: 299, False: 18]
  ------------------
  820|    299|				continue;
  821|    317|		}
  822|       |
  823|  1.06k|		if (auth_info)
  ------------------
  |  Branch (823:7): [True: 1.06k, False: 0]
  ------------------
  824|  1.06k|			*auth_info = pinfo->pin;
  825|  1.06k|		return pinfo->id;
  826|  2.30k|	}
  827|       |
  828|    376|	return -1;
  829|  1.43k|}
sc_profile_get_parent:
 2340|     28|{
 2341|     28|	struct file_info *fi = NULL;
 2342|       |
 2343|     28|	if ((fi = sc_profile_find_file(profile, NULL, name)) == NULL)
  ------------------
  |  Branch (2343:6): [True: 0, False: 28]
  ------------------
 2344|      0|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 2345|       |
 2346|     28|	if (!fi->parent)
  ------------------
  |  Branch (2346:6): [True: 0, False: 28]
  ------------------
 2347|      0|		return SC_ERROR_FILE_NOT_FOUND;
  ------------------
  |  |   51|      0|#define SC_ERROR_FILE_NOT_FOUND			-1201
  ------------------
 2348|       |
 2349|     28|	sc_file_dup(ret, fi->parent->file);
 2350|     28|	if (*ret == NULL)
  ------------------
  |  Branch (2350:6): [True: 0, False: 28]
  ------------------
 2351|      0|		return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 2352|     28|	return 0;
 2353|     28|}
fuzz_pkcs15init.c:init_file:
  271|  24.3k|{
  272|  24.3k|	struct sc_file	*file;
  273|  24.3k|	unsigned int	op;
  274|       |
  275|  24.3k|	file = sc_file_new();
  276|   777k|	for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|   777k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (276:15): [True: 753k, False: 24.3k]
  ------------------
  277|   753k|		sc_file_add_acl_entry(file, op, SC_AC_NONE, 0);
  ------------------
  |  |  150|   753k|#define SC_AC_NONE			0x00000000
  ------------------
  278|   753k|	}
  279|  24.3k|	file->type = type;
  280|  24.3k|	file->status = SC_FILE_STATUS_ACTIVATED;
  ------------------
  |  |  236|  24.3k|#define SC_FILE_STATUS_ACTIVATED	0x00 /* ISO7816-4: Operational state (activated)   (5, 7) */
  ------------------
  281|  24.3k|	if (file->type != SC_FILE_TYPE_DF && file->type != SC_FILE_TYPE_BSO)
  ------------------
  |  |  214|  48.6k|#define SC_FILE_TYPE_DF			0x04
  ------------------
              	if (file->type != SC_FILE_TYPE_DF && file->type != SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|  15.9k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (281:6): [True: 15.9k, False: 8.34k]
  |  Branch (281:39): [True: 15.8k, False: 80]
  ------------------
  282|  15.8k|		file->ef_structure = SC_FILE_EF_TRANSPARENT;
  ------------------
  |  |  221|  15.8k|#define SC_FILE_EF_TRANSPARENT		0x01
  ------------------
  283|  24.3k|	return file;
  284|  24.3k|}
fuzz_pkcs15init.c:sc_profile_instantiate_file:
  764|    248|{
  765|    248|	struct sc_context *ctx = profile->card->ctx;
  766|    248|	struct file_info *fi;
  767|       |
  768|    248|	fi = calloc(1, sizeof(*fi));
  769|    248|	if (fi == NULL)
  ------------------
  |  Branch (769:6): [True: 0, False: 248]
  ------------------
  770|      0|		return NULL;
  771|    248|	fi->instance = fi;
  772|    248|	fi->parent = parent;
  773|    248|	fi->ident = strdup(ft->ident);
  774|    248|	if (fi->ident == NULL) {
  ------------------
  |  Branch (774:6): [True: 0, False: 248]
  ------------------
  775|      0|		free(fi);
  776|      0|		return NULL;
  777|      0|	}
  778|    248|	sc_file_dup(&fi->file, ft->file);
  779|    248|	if (fi->file == NULL) {
  ------------------
  |  Branch (779:6): [True: 0, False: 248]
  ------------------
  780|      0|		free(fi->ident);
  781|      0|		free(fi);
  782|      0|		return NULL;
  783|      0|	}
  784|    248|	fi->file->path = parent->file->path;
  785|    248|	fi->file->id += skew;
  786|       |
  787|    248|	if (fi->file->type == SC_FILE_TYPE_INTERNAL_EF
  ------------------
  |  |  215|    496|#define SC_FILE_TYPE_INTERNAL_EF	0x03
  ------------------
  |  Branch (787:6): [True: 50, False: 198]
  ------------------
  788|    198|			|| fi->file->type == SC_FILE_TYPE_WORKING_EF
  ------------------
  |  |  216|    446|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (788:7): [True: 119, False: 79]
  ------------------
  789|     79|			|| (fi->file->type == SC_FILE_TYPE_DF && fi->file->id))
  ------------------
  |  |  214|    158|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (789:8): [True: 37, False: 42]
  |  Branch (789:45): [True: 37, False: 0]
  ------------------
  790|    206|		sc_append_file_id(&fi->file->path, fi->file->id);
  791|       |
  792|    248|	append_file(profile, fi);
  793|       |
  794|    248|	ft->instance = fi;
  795|       |
  796|    248|	sc_log(ctx, "Instantiated %s at %s", ft->ident, sc_print_path(&fi->file->path));
  ------------------
  |  |   71|    248|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
  797|    248|	sc_log(ctx, "  parent=%s@%s", parent->ident, sc_print_path(&parent->file->path));
  ------------------
  |  |   71|    248|#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|    248|	return fi;
  800|    248|}
fuzz_pkcs15init.c:append_file:
 1176|  14.9k|{
 1177|  14.9k|	struct file_info	**list, *fi;
 1178|       |
 1179|  14.9k|	list = &profile->ef_list;
 1180|  56.0k|	while ((fi = *list) != NULL)
  ------------------
  |  Branch (1180:9): [True: 41.0k, False: 14.9k]
  ------------------
 1181|  41.0k|		list = &fi->next;
 1182|  14.9k|	*list = nfile;
 1183|  14.9k|}
fuzz_pkcs15init.c:add_file:
 1192|  14.7k|{
 1193|  14.7k|	struct file_info	*info;
 1194|       |
 1195|  14.7k|	info = calloc(1, sizeof(*info));
 1196|  14.7k|	if (info == NULL)
  ------------------
  |  Branch (1196:6): [True: 0, False: 14.7k]
  ------------------
 1197|      0|		return NULL;
 1198|  14.7k|	info->instance = info;
 1199|  14.7k|	info->ident = strdup(name);
 1200|       |
 1201|  14.7k|	info->parent = parent;
 1202|  14.7k|	info->file = file;
 1203|       |
 1204|  14.7k|	append_file(profile, info);
 1205|  14.7k|	return info;
 1206|  14.7k|}
fuzz_pkcs15init.c:free_file_list:
 1213|  5.03k|{
 1214|  5.03k|	struct file_info	*fi;
 1215|       |
 1216|  20.0k|	while ((fi = *list) != NULL) {
  ------------------
  |  Branch (1216:9): [True: 14.9k, False: 5.03k]
  ------------------
 1217|  14.9k|		*list = fi->next;
 1218|       |
 1219|  14.9k|		if (fi->dont_free == 0)
  ------------------
  |  Branch (1219:7): [True: 11.8k, False: 3.14k]
  ------------------
 1220|  11.8k|			sc_file_free(fi->file);
 1221|  14.9k|		free(fi->profile_extension);
 1222|  14.9k|		free(fi->ident);
 1223|  14.9k|		free(fi);
 1224|  14.9k|	}
 1225|  5.03k|}
fuzz_pkcs15init.c:new_pin:
 1654|  16.3k|{
 1655|  16.3k|	struct pin_info	*pi, **tail;
 1656|       |
 1657|  29.3k|	for (tail = &profile->pin_list; (pi = *tail); tail = &pi->next) {
  ------------------
  |  Branch (1657:34): [True: 20.9k, False: 8.42k]
  ------------------
 1658|  20.9k|		if (pi->id == id)
  ------------------
  |  Branch (1658:7): [True: 7.93k, False: 13.0k]
  ------------------
 1659|  7.93k|			return pi;
 1660|  20.9k|	}
 1661|       |
 1662|       |	/* Create pin info object. Most values are
 1663|       |	 * set to their defaults in set_pin_defaults later
 1664|       |	 * We can't do this here because these pin info objects
 1665|       |	 * are usually created before we've read the card specific
 1666|       |	 * profile
 1667|       |	 */
 1668|  8.42k|	pi = calloc(1, sizeof(*pi));
 1669|  8.42k|	if (pi == NULL)
  ------------------
  |  Branch (1669:6): [True: 0, False: 8.42k]
  ------------------
 1670|      0|		return NULL;
 1671|  8.42k|	pi->id = id;
 1672|  8.42k|	pi->pin.auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|  8.42k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1673|  8.42k|	pi->pin.auth_method = SC_AC_CHV;
  ------------------
  |  |  151|  8.42k|#define SC_AC_CHV			0x00000001 /* Card Holder Verif. */
  ------------------
 1674|  8.42k|	pi->pin.attrs.pin.type = (unsigned int)-1;
 1675|  8.42k|	pi->pin.attrs.pin.flags = 0x32;
 1676|  8.42k|	pi->pin.attrs.pin.max_length = 0;
 1677|  8.42k|	pi->pin.attrs.pin.min_length = 0;
 1678|  8.42k|	pi->pin.attrs.pin.stored_length = 0;
 1679|  8.42k|	pi->pin.attrs.pin.pad_char = 0xA5;
 1680|  8.42k|	pi->pin.attrs.pin.reference = -1;
 1681|  8.42k|	pi->pin.tries_left = 3;
 1682|       |
 1683|  8.42k|	*tail = pi;
 1684|  8.42k|	return pi;
 1685|  8.42k|}
fuzz_pkcs15init.c:set_pin_defaults:
 1688|  1.59k|{
 1689|  1.59k|	struct sc_pkcs15_auth_info *info = &pi->pin;
 1690|  1.59k|	struct sc_pkcs15_pin_attributes *pin_attrs = &info->attrs.pin;
 1691|       |
 1692|  1.59k|	info->auth_type = SC_PKCS15_PIN_AUTH_TYPE_PIN;
  ------------------
  |  |   94|  1.59k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
 1693|       |
 1694|  1.59k|	if (pin_attrs->type == (unsigned int) -1)
  ------------------
  |  Branch (1694:6): [True: 1.59k, False: 0]
  ------------------
 1695|  1.59k|		pin_attrs->type = profile->pin_encoding;
 1696|  1.59k|	if (pin_attrs->max_length == 0)
  ------------------
  |  Branch (1696:6): [True: 1.27k, False: 324]
  ------------------
 1697|  1.27k|		pin_attrs->max_length = profile->pin_maxlen;
 1698|  1.59k|	if (pin_attrs->min_length == 0)
  ------------------
  |  Branch (1698:6): [True: 1.23k, False: 361]
  ------------------
 1699|  1.23k|		pin_attrs->min_length = profile->pin_minlen;
 1700|  1.59k|	if (pin_attrs->stored_length == 0) {
  ------------------
  |  Branch (1700:6): [True: 1.59k, False: 0]
  ------------------
 1701|  1.59k|		pin_attrs->stored_length = profile->pin_maxlen;
 1702|       |		/* BCD encoded PIN takes half the space */
 1703|  1.59k|		if (pin_attrs->type == SC_PKCS15_PIN_TYPE_BCD)
  ------------------
  |  |   88|  1.59k|#define SC_PKCS15_PIN_TYPE_BCD				0
  ------------------
  |  Branch (1703:7): [True: 0, False: 1.59k]
  ------------------
 1704|      0|			pin_attrs->stored_length = (pin_attrs->stored_length + 1) / 2;
 1705|  1.59k|	}
 1706|  1.59k|	if (pin_attrs->pad_char == 0xA5)
  ------------------
  |  Branch (1706:6): [True: 1.59k, False: 0]
  ------------------
 1707|  1.59k|		pin_attrs->pad_char = profile->pin_pad_char;
 1708|  1.59k|}
fuzz_pkcs15init.c:process_conf:
 2249|  3.26k|{
 2250|  3.26k|	struct state	state;
 2251|       |
 2252|  3.26k|	memset(&state, 0, sizeof(state));
 2253|  3.26k|	state.filename = conf->filename;
 2254|  3.26k|	state.profile = profile;
 2255|  3.26k|	return process_block(&state, &root_ops, "root", conf->root);
 2256|  3.26k|}
fuzz_pkcs15init.c:process_block:
 2195|  34.8k|{
 2196|  34.8k|	scconf_item	*item;
 2197|  34.8k|	struct command	*cp;
 2198|  34.8k|	struct block	*bp;
 2199|  34.8k|	const char	*cmd, *ident;
 2200|  34.8k|	int		res = 0;
 2201|       |
 2202|   152k|	for (item = blk->items; res == 0 && item; item = item->next) {
  ------------------
  |  Branch (2202:26): [True: 151k, False: 734]
  |  Branch (2202:38): [True: 117k, False: 34.0k]
  ------------------
 2203|   117k|		cmd = item->key;
 2204|   117k|		if (item->type == SCCONF_ITEM_TYPE_COMMENT)
  ------------------
  |  |   42|   117k|#define SCCONF_ITEM_TYPE_COMMENT	0	/* key = NULL, comment */
  ------------------
  |  Branch (2204:7): [True: 46.7k, False: 71.2k]
  ------------------
 2205|  46.7k|			continue;
 2206|  71.2k|		if (!cmd) {
  ------------------
  |  Branch (2206:7): [True: 3, False: 71.1k]
  ------------------
 2207|      3|			parse_error(cur, "Command can not be processed.");
 2208|      3|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      3|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2209|      3|		}
 2210|  71.1k|		if (item->type == SCCONF_ITEM_TYPE_BLOCK) {
  ------------------
  |  |   43|  71.1k|#define SCCONF_ITEM_TYPE_BLOCK		1	/* key = key, block */
  ------------------
  |  Branch (2210:7): [True: 33.2k, False: 37.9k]
  ------------------
 2211|  33.2k|			scconf_list *nlist;
 2212|       |
 2213|  33.2k|			ident = NULL;
 2214|  33.2k|			if ((nlist = item->value.block->name) != NULL) {
  ------------------
  |  Branch (2214:8): [True: 33.2k, False: 0]
  ------------------
 2215|  33.2k|				if (nlist->next) {
  ------------------
  |  Branch (2215:9): [True: 1, False: 33.2k]
  ------------------
 2216|      1|					parse_error(cur, "Too many name components in block name.");
 2217|      1|					return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      1|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2218|      1|				}
 2219|  33.2k|				ident = nlist->data;
 2220|  33.2k|			}
 2221|       |#ifdef DEBUG_PROFILE
 2222|       |			printf("Processing %s %s\n", cmd, ident? ident : "");
 2223|       |#endif
 2224|  33.2k|			if ((bp = find_block_handler(info->blk_info, cmd))) {
  ------------------
  |  Branch (2224:8): [True: 33.1k, False: 47]
  ------------------
 2225|  33.1k|				res = bp->handler(cur, bp, ident, item->value.block);
 2226|  33.1k|				continue;
 2227|  33.1k|			}
 2228|  33.2k|		}
 2229|  37.9k|		else if (item->type == SCCONF_ITEM_TYPE_VALUE) {
  ------------------
  |  |   44|  37.9k|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (2229:12): [True: 37.9k, False: 0]
  ------------------
 2230|       |#ifdef DEBUG_PROFILE
 2231|       |			printf("Processing %s\n", cmd);
 2232|       |#endif
 2233|  37.9k|			if ((cp = find_cmd_handler(info->cmd_info, cmd))) {
  ------------------
  |  Branch (2233:8): [True: 37.9k, False: 33]
  ------------------
 2234|  37.9k|				res = process_command(cur, cp, item->value.list);
 2235|  37.9k|				continue;
 2236|  37.9k|			}
 2237|  37.9k|		}
 2238|     80|		parse_error(cur, "Command \"%s\" not understood in this context.", cmd);
 2239|     80|		return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|     80|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2240|  71.1k|	}
 2241|       |
 2242|  34.7k|	if (res > 0)
  ------------------
  |  Branch (2242:6): [True: 84, False: 34.6k]
  ------------------
 2243|     84|		res = SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|     84|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2244|  34.7k|	return res;
 2245|  34.8k|}
fuzz_pkcs15init.c:parse_error:
 2699|    295|{
 2700|    295|	char	buffer[1024], *sp;
 2701|    295|	va_list	ap;
 2702|       |
 2703|    295|	va_start(ap, fmt);
 2704|    295|	vsnprintf(buffer, sizeof(buffer), fmt, ap);
 2705|    295|	va_end(ap);
 2706|       |
 2707|    295|	if ((sp = strchr(buffer, '\n')) != NULL)
  ------------------
  |  Branch (2707:6): [True: 148, False: 147]
  ------------------
 2708|    148|		*sp = '\0';
 2709|       |
 2710|    295|	if (cur->profile->card && cur->profile->card->ctx)
  ------------------
  |  Branch (2710:6): [True: 269, False: 26]
  |  Branch (2710:28): [True: 269, False: 0]
  ------------------
 2711|    269|		sc_log(cur->profile->card->ctx, "%s: %s", cur->filename, buffer);
  ------------------
  |  |   71|    269|#define sc_log(ctx, format, args...)   sc_do_log(ctx, SC_LOG_DEBUG_NORMAL, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
 2712|     26|	else
 2713|     26|		fprintf(stdout, "%s: %s\n", cur->filename, buffer);
 2714|    295|}
fuzz_pkcs15init.c:find_block_handler:
 2170|  33.2k|{
 2171|  33.2k|	if (bp == NULL)
  ------------------
  |  Branch (2171:6): [True: 5, False: 33.2k]
  ------------------
 2172|      5|		return NULL;
 2173|  72.7k|	for (; bp->name; bp++) {
  ------------------
  |  Branch (2173:9): [True: 72.7k, False: 42]
  ------------------
 2174|  72.7k|		if (!strcasecmp(bp->name, name))
  ------------------
  |  Branch (2174:7): [True: 33.1k, False: 39.5k]
  ------------------
 2175|  33.1k|			return bp;
 2176|  72.7k|	}
 2177|     42|	return NULL;
 2178|  33.2k|}
fuzz_pkcs15init.c:find_cmd_handler:
 2182|  37.9k|{
 2183|  37.9k|	if (cp == NULL)
  ------------------
  |  Branch (2183:6): [True: 3, False: 37.9k]
  ------------------
 2184|      3|		return NULL;
 2185|   166k|	for (; cp->name; cp++) {
  ------------------
  |  Branch (2185:9): [True: 166k, False: 30]
  ------------------
 2186|   166k|		if (!strcasecmp(cp->name, name))
  ------------------
  |  Branch (2186:7): [True: 37.9k, False: 128k]
  ------------------
 2187|  37.9k|			return cp;
 2188|   166k|	}
 2189|     30|	return NULL;
 2190|  37.9k|}
fuzz_pkcs15init.c:process_command:
 2150|  37.9k|{
 2151|  37.9k|	const char	*cmd = cmd_info->name;
 2152|  37.9k|	char		*argv[32];
 2153|  37.9k|	int		argc, max = 32;
 2154|       |
 2155|  37.9k|	if (cmd_info->max_args >= 0 && max > cmd_info->max_args)
  ------------------
  |  Branch (2155:6): [True: 32.2k, False: 5.65k]
  |  Branch (2155:33): [True: 32.2k, False: 0]
  ------------------
 2156|  32.2k|		max = cmd_info->max_args;
 2157|       |
 2158|  37.9k|	if ((argc = build_argv(cur, cmd, list, argv, max)) < 0)
  ------------------
  |  Branch (2158:6): [True: 12, False: 37.9k]
  ------------------
 2159|     12|		return argc;
 2160|       |
 2161|  37.9k|	if (argc < cmd_info->min_args) {
  ------------------
  |  Branch (2161:6): [True: 0, False: 37.9k]
  ------------------
 2162|      0|		parse_error(cur, "%s: not enough arguments\n", cmd);
 2163|      0|		return 1;
 2164|      0|	}
 2165|  37.9k|	return cmd_info->func(cur, argc, argv);
 2166|  37.9k|}
fuzz_pkcs15init.c:build_argv:
 2082|  38.8k|{
 2083|  38.8k|	unsigned int	argc;
 2084|  38.8k|	const char	*str;
 2085|  38.8k|	sc_macro_t	*macro;
 2086|  38.8k|	int		r;
 2087|       |
 2088|  87.2k|	for (argc = 0; list; list = list->next) {
  ------------------
  |  Branch (2088:17): [True: 48.4k, False: 38.8k]
  ------------------
 2089|  48.4k|		if (argc >= max) {
  ------------------
  |  Branch (2089:7): [True: 6, False: 48.4k]
  ------------------
 2090|      6|			parse_error(cur, "%s: too many arguments", cmdname);
 2091|      6|			return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      6|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 2092|      6|		}
 2093|       |
 2094|  48.4k|		str = list->data;
 2095|  48.4k|		if (str[0] != '$') {
  ------------------
  |  Branch (2095:7): [True: 47.5k, False: 930]
  ------------------
 2096|       |			/* When str contains macro inside, macro reference loop needs to be checked */
 2097|  47.5k|			const char *macro_name = NULL;
 2098|  47.5k|			if ((macro_name = strchr(str, '$'))) {
  ------------------
  |  Branch (2098:8): [True: 5.72k, False: 41.7k]
  ------------------
 2099|       |				/* Macro does not have to start at the first position */
 2100|  5.72k|				char word[WORD_SIZE];
 2101|  5.72k|				if (get_inner_word(macro_name + 1, word) != 0) {
  ------------------
  |  Branch (2101:9): [True: 2, False: 5.72k]
  ------------------
 2102|      2|					return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      2|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2103|      2|				}
 2104|  5.72k|				if ((macro = find_macro(cur->profile, word))
  ------------------
  |  Branch (2104:9): [True: 12, False: 5.71k]
  ------------------
 2105|     12|				    && check_macro_reference_loop(macro->name, macro, cur->profile, 0)) {
  ------------------
  |  Branch (2105:12): [True: 0, False: 12]
  ------------------
 2106|      0|					return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      0|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2107|      0|				}
 2108|  5.72k|			}
 2109|       |
 2110|  47.5k|			argv[argc++] = list->data;
 2111|  47.5k|			continue;
 2112|  47.5k|		}
 2113|       |
 2114|       |		/* Expand macro reference */
 2115|    930|		if (!(macro = find_macro(cur->profile, str + 1))) {
  ------------------
  |  Branch (2115:7): [True: 4, False: 926]
  ------------------
 2116|      4|			parse_error(cur, "%s: unknown macro \"%s\"",
 2117|      4|					cmdname, str);
 2118|      4|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      4|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2119|      4|		}
 2120|       |
 2121|    926|		if (list == macro->value) {
  ------------------
  |  Branch (2121:7): [True: 0, False: 926]
  ------------------
 2122|      0|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      0|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2123|      0|		}
 2124|    926|		if (check_macro_reference_loop(macro->name, macro, cur->profile, 0)) {
  ------------------
  |  Branch (2124:7): [True: 0, False: 926]
  ------------------
 2125|      0|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      0|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2126|      0|		}
 2127|       |#ifdef DEBUG_PROFILE
 2128|       |		{
 2129|       |			scconf_list *list;
 2130|       |
 2131|       |			printf("Expanding macro %s:", macro->name);
 2132|       |			for (list = macro->value; list; list = list->next)
 2133|       |				printf(" %s", list->data);
 2134|       |			printf("\n");
 2135|       |		}
 2136|       |#endif
 2137|    926|		r = build_argv(cur, cmdname, macro->value,
 2138|    926|				argv + argc, max - argc);
 2139|    926|		if (r < 0)
  ------------------
  |  Branch (2139:7): [True: 0, False: 926]
  ------------------
 2140|      0|			return r;
 2141|       |
 2142|    926|		argc += r;
 2143|    926|	}
 2144|       |
 2145|  38.8k|	return argc;
 2146|  38.8k|}
fuzz_pkcs15init.c:get_inner_word:
 2024|  5.73k|{
 2025|  5.73k|	const char *inner = NULL;
 2026|  5.73k|	size_t len = 0;
 2027|       |
 2028|  5.73k|	inner = str;
 2029|       |
 2030|  44.6k|	while (is_macro_character(*inner)) {
  ------------------
  |  Branch (2030:9): [True: 38.9k, False: 5.73k]
  ------------------
 2031|  38.9k|		inner++;
 2032|  38.9k|		len++;
 2033|  38.9k|	}
 2034|  5.73k|	if (len >= WORD_SIZE)
  ------------------
  |  |   58|  5.73k|#define WORD_SIZE	64
  ------------------
  |  Branch (2034:6): [True: 2, False: 5.73k]
  ------------------
 2035|      2|		return 1;
 2036|  5.73k|	memcpy(word, str, len);
 2037|  5.73k|	word[len] = '\0';
 2038|  5.73k|	return 0;
 2039|  5.73k|}
fuzz_pkcs15init.c:is_macro_character:
 2016|   123k|{
 2017|   123k|	if (isalnum(c) || c == '-' || c == '_')
  ------------------
  |  Branch (2017:6): [True: 104k, False: 19.8k]
  |  Branch (2017:20): [True: 7.54k, False: 12.2k]
  |  Branch (2017:32): [True: 1, False: 12.2k]
  ------------------
 2018|   111k|		return 1;
 2019|  12.2k|	return 0;
 2020|   123k|}
fuzz_pkcs15init.c:find_macro:
 1898|  13.1k|{
 1899|  13.1k|	sc_macro_t	*mac;
 1900|       |
 1901|   123k|	for (mac = profile->macro_list; mac; mac = mac->next) {
  ------------------
  |  Branch (1901:34): [True: 115k, False: 8.06k]
  ------------------
 1902|   115k|		if (!strcmp(mac->name, name))
  ------------------
  |  Branch (1902:7): [True: 5.11k, False: 110k]
  ------------------
 1903|  5.11k|			return mac;
 1904|   115k|	}
 1905|  8.06k|	return NULL;
 1906|  13.1k|}
fuzz_pkcs15init.c:check_macro_reference_loop:
 2047|    938|{
 2048|    938|	scconf_list *value;
 2049|    938|	const char *name = NULL;
 2050|    938|	sc_macro_t	*m;
 2051|    938|	char word[WORD_SIZE];
 2052|       |
 2053|    938|	if (!start_name || !macro || !profile || depth == 16)
  ------------------
  |  Branch (2053:6): [True: 0, False: 938]
  |  Branch (2053:21): [True: 0, False: 938]
  |  Branch (2053:31): [True: 0, False: 938]
  |  Branch (2053:43): [True: 0, False: 938]
  ------------------
 2054|      0|		return 1;
 2055|       |
 2056|       |	/* For some reason, the macro value is a list where we need to check for references */
 2057|  1.88k|	for (value = macro->value; value != NULL; value = value->next) {
  ------------------
  |  Branch (2057:29): [True: 950, False: 938]
  ------------------
 2058|       |		/* Find name in macro value */
 2059|    950|		char *macro_value = value->data;
 2060|    950|		if (!(name = strchr(macro_value, '$')))
  ------------------
  |  Branch (2060:7): [True: 938, False: 12]
  ------------------
 2061|    938|			continue;
 2062|       |		/* Extract the macro name from the string */
 2063|     12|		if (get_inner_word(name + 1, word))
  ------------------
  |  Branch (2063:7): [True: 0, False: 12]
  ------------------
 2064|      0|			return 1;
 2065|       |		/* Find whether name corresponds to some other macro */
 2066|     12|		if (!(m = find_macro(profile, word)))
  ------------------
  |  Branch (2066:7): [True: 12, False: 0]
  ------------------
 2067|     12|			continue;
 2068|       |		/* Check for loop */
 2069|      0|		if (!strcmp(m->name, start_name))
  ------------------
  |  Branch (2069:7): [True: 0, False: 0]
  ------------------
 2070|      0|			return 1;
 2071|       |		/* Reference loop was found to the original macro name */
 2072|      0|		if (check_macro_reference_loop(start_name, m, profile, depth + 1) == 1) {
  ------------------
  |  Branch (2072:7): [True: 0, False: 0]
  ------------------
 2073|      0|			return 1;
 2074|      0|		}
 2075|      0|	}
 2076|    938|	return 0;
 2077|    938|}
fuzz_pkcs15init.c:process_df:
 1022|  11.3k|{
 1023|  11.3k|	struct state	state;
 1024|       |
 1025|  11.3k|	init_state(cur, &state);
 1026|  11.3k|	if (name == NULL) {
  ------------------
  |  Branch (1026:6): [True: 0, False: 11.3k]
  ------------------
 1027|      0|		parse_error(cur, "No name given for DF object.");
 1028|      0|		return 1;
 1029|      0|	}
 1030|  11.3k|	if (!(state.file = new_file(cur, name, SC_FILE_TYPE_DF)))
  ------------------
  |  |  214|  11.3k|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1030:6): [True: 4, False: 11.3k]
  ------------------
 1031|      4|		return 1;
 1032|  11.3k|	return process_block(&state, info, name, blk);
 1033|  11.3k|}
fuzz_pkcs15init.c:init_state:
  836|  24.7k|{
  837|  24.7k|	memset(new_state, 0, sizeof(*new_state));
  838|  24.7k|	new_state->filename = cur_state->filename;
  839|  24.7k|	new_state->profile = cur_state->profile;
  840|  24.7k|	new_state->frame = cur_state;
  841|  24.7k|}
fuzz_pkcs15init.c:new_file:
 1233|  18.8k|{
 1234|  18.8k|	sc_profile_t	*profile = cur->profile;
 1235|  18.8k|	struct file_info	*info;
 1236|  18.8k|	sc_file_t	*file;
 1237|  18.8k|	unsigned int	df_type = 0, dont_free = 0;
 1238|  18.8k|	int	free_file = 0;
 1239|       |
 1240|  18.8k|	if ((info = sc_profile_find_file(profile, NULL, name)) != NULL)
  ------------------
  |  Branch (1240:6): [True: 4.51k, False: 14.3k]
  ------------------
 1241|  4.51k|		return info;
 1242|       |
 1243|       |	/* Special cases for those EFs handled separately
 1244|       |	 * by the PKCS15 logic */
 1245|  14.3k|	if (strncasecmp(name, "PKCS15-", 7)) {
  ------------------
  |  Branch (1245:6): [True: 8.71k, False: 5.63k]
  ------------------
 1246|  8.71k|		file = init_file(type);
 1247|  8.71k|		free_file = 1;
 1248|  8.71k|	} else if (!strcasecmp(name+7, "TokenInfo")) {
  ------------------
  |  Branch (1248:13): [True: 92, False: 5.54k]
  ------------------
 1249|     92|		if (!profile->p15_spec) {
  ------------------
  |  Branch (1249:7): [True: 0, False: 92]
  ------------------
 1250|      0|			parse_error(cur, "no pkcs15 spec in profile");
 1251|      0|			return NULL;
 1252|      0|		}
 1253|     92|		file = profile->p15_spec->file_tokeninfo;
 1254|     92|		dont_free = 1;
 1255|  5.54k|	} else if (!strcasecmp(name+7, "ODF")) {
  ------------------
  |  Branch (1255:13): [True: 228, False: 5.31k]
  ------------------
 1256|    228|		if (!profile->p15_spec) {
  ------------------
  |  Branch (1256:7): [True: 0, False: 228]
  ------------------
 1257|      0|			parse_error(cur, "no pkcs15 spec in profile");
 1258|      0|			return NULL;
 1259|      0|		}
 1260|    228|		file = profile->p15_spec->file_odf;
 1261|    228|		dont_free = 1;
 1262|  5.31k|	} else if (!strcasecmp(name+7, "UnusedSpace")) {
  ------------------
  |  Branch (1262:13): [True: 72, False: 5.24k]
  ------------------
 1263|     72|		if (!profile->p15_spec) {
  ------------------
  |  Branch (1263:7): [True: 0, False: 72]
  ------------------
 1264|      0|			parse_error(cur, "no pkcs15 spec in profile");
 1265|      0|			return NULL;
 1266|      0|		}
 1267|     72|		file = profile->p15_spec->file_unusedspace;
 1268|     72|		dont_free = 1;
 1269|  5.24k|	} else if (!strcasecmp(name+7, "AppDF")) {
  ------------------
  |  Branch (1269:13): [True: 4.00k, False: 1.24k]
  ------------------
 1270|  4.00k|		file = init_file(SC_FILE_TYPE_DF);
  ------------------
  |  |  214|  4.00k|#define SC_FILE_TYPE_DF			0x04
  ------------------
 1271|  4.00k|		free_file = 1;
 1272|  4.00k|	} else {
 1273|  1.24k|		if (map_str2int(cur, name+7, &df_type, pkcs15DfNames)
  ------------------
  |  Branch (1273:7): [True: 14, False: 1.23k]
  ------------------
 1274|  1.23k|				|| df_type >= SC_PKCS15_DF_TYPE_COUNT)
  ------------------
  |  |  497|  1.23k|#define SC_PKCS15_DF_TYPE_COUNT		9
  ------------------
  |  Branch (1274:8): [True: 0, False: 1.23k]
  ------------------
 1275|     14|			return NULL;
 1276|       |
 1277|  1.23k|		file = init_file(SC_FILE_TYPE_WORKING_EF);
  ------------------
  |  |  216|  1.23k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
 1278|  1.23k|		profile->df[df_type] = file;
 1279|  1.23k|		free_file = 1;
 1280|  1.23k|	}
 1281|  14.3k|	if (!file)
  ------------------
  |  Branch (1281:6): [True: 0, False: 14.3k]
  ------------------
 1282|      0|		return NULL;
 1283|  14.3k|	if (file->type != type) {
  ------------------
  |  Branch (1283:6): [True: 0, False: 14.3k]
  ------------------
 1284|      0|		parse_error(cur, "inconsistent file type (should be %s)",
 1285|      0|			file->type == SC_FILE_TYPE_DF
  ------------------
  |  |  214|      0|#define SC_FILE_TYPE_DF			0x04
  ------------------
  |  Branch (1285:4): [True: 0, False: 0]
  ------------------
 1286|      0|				? "DF" : file->type == SC_FILE_TYPE_BSO
  ------------------
  |  |  217|      0|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (1286:14): [True: 0, False: 0]
  ------------------
 1287|      0|					? "BS0" : "EF");
 1288|      0|		if (free_file)
  ------------------
  |  Branch (1288:7): [True: 0, False: 0]
  ------------------
 1289|      0|			sc_file_free(file);
 1290|      0|		return NULL;
 1291|      0|	}
 1292|       |
 1293|  14.3k|	info = add_file(profile, name, file, cur->file);
 1294|  14.3k|	if (info == NULL) {
  ------------------
  |  Branch (1294:6): [True: 0, False: 14.3k]
  ------------------
 1295|      0|		parse_error(cur, "memory allocation failed");
 1296|      0|		return NULL;
 1297|      0|	}
 1298|  14.3k|	info->dont_free = dont_free;
 1299|  14.3k|	return info;
 1300|  14.3k|}
fuzz_pkcs15init.c:map_str2int:
 2430|  33.9k|{
 2431|  33.9k|	unsigned int	n;
 2432|  33.9k|	const char	*what;
 2433|       |
 2434|  33.9k|	if (isdigit((unsigned char) *value))
  ------------------
  |  Branch (2434:6): [True: 2.09k, False: 31.8k]
  ------------------
 2435|  2.09k|		return get_uint(cur, value, vp);
 2436|   151k|	for (n = 0; map[n].name; n++) {
  ------------------
  |  Branch (2436:14): [True: 151k, False: 29]
  ------------------
 2437|   151k|		if (!strcasecmp(value, map[n].name)) {
  ------------------
  |  Branch (2437:7): [True: 31.8k, False: 119k]
  ------------------
 2438|  31.8k|			*vp = map[n].val;
 2439|  31.8k|			return 0;
 2440|  31.8k|		}
 2441|   151k|	}
 2442|       |
 2443|       |	/* Try to print a meaningful error message */
 2444|     29|	what = "argument";
 2445|    131|	for (n = 0; mapNames[n].name; n++) {
  ------------------
  |  Branch (2445:14): [True: 131, False: 0]
  ------------------
 2446|    131|		if (mapNames[n].addr == map) {
  ------------------
  |  Branch (2446:7): [True: 29, False: 102]
  ------------------
 2447|     29|			what = mapNames[n].name;
 2448|     29|			break;
 2449|     29|		}
 2450|    131|	}
 2451|       |
 2452|     29|	parse_error(cur, "invalid %s \"%s\"\n", what, value);
 2453|     29|	return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|     29|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2454|  31.8k|}
fuzz_pkcs15init.c:get_uint:
 2386|  11.2k|{
 2387|  11.2k|	char	*ep;
 2388|  11.2k|	unsigned long tmp;
 2389|       |
 2390|  11.2k|	if (strstr(value, "0x") == value)
  ------------------
  |  Branch (2390:6): [True: 1.04k, False: 10.2k]
  ------------------
 2391|  1.04k|		tmp = strtoul(value + 2, &ep, 16);
 2392|  10.2k|	else if (strstr(value, "x") == value)
  ------------------
  |  Branch (2392:11): [True: 144, False: 10.0k]
  ------------------
 2393|    144|		tmp = strtoul(value + 1, &ep, 16);
 2394|  10.0k|	else
 2395|  10.0k|		tmp = strtoul(value, &ep, 0);
 2396|  11.2k|	if (*ep != '\0') {
  ------------------
  |  Branch (2396:6): [True: 104, False: 11.1k]
  ------------------
 2397|    104|		parse_error(cur, "invalid integer argument \"%s\"\n", value);
 2398|    104|		return 1;
 2399|    104|	}
 2400|  11.1k|	if (tmp > INT_MAX) {
  ------------------
  |  Branch (2400:6): [True: 5, False: 11.1k]
  ------------------
 2401|      5|		parse_error(cur, "the number \"%s\" is too large\n", value);
 2402|      5|		return 1;
 2403|      5|	}
 2404|  11.1k|	*vp = (int)tmp;
 2405|  11.1k|	return 0;
 2406|  11.1k|}
fuzz_pkcs15init.c:do_file_type:
 1304|  4.29k|{
 1305|  4.29k|	unsigned int	type;
 1306|       |
 1307|  4.29k|	if (!cur->file) {
  ------------------
  |  Branch (1307:6): [True: 0, False: 4.29k]
  ------------------
 1308|      0|		parse_error(cur, "Invalid state\n");
 1309|      0|		return 1;
 1310|      0|	}
 1311|       |
 1312|  4.29k|	if (map_str2int(cur, argv[0], &type, fileTypeNames))
  ------------------
  |  Branch (1312:6): [True: 1, False: 4.29k]
  ------------------
 1313|      1|		return 1;
 1314|  4.29k|	cur->file->file->type = type;
 1315|  4.29k|	return 0;
 1316|  4.29k|}
fuzz_pkcs15init.c:do_file_path:
 1320|  2.80k|{
 1321|  2.80k|	struct sc_file	*file = NULL;
 1322|  2.80k|	struct sc_path	*path = NULL;
 1323|       |
 1324|  2.80k|	if (!cur->file) {
  ------------------
  |  Branch (1324:6): [True: 0, False: 2.80k]
  ------------------
 1325|      0|		parse_error(cur, "Invalid state\n");
 1326|      0|		return 1;
 1327|      0|	}
 1328|  2.80k|	file = cur->file->file;
 1329|  2.80k|	path = &file->path;
 1330|       |
 1331|       |	/* sc_format_path doesn't return an error indication
 1332|       |	 * when it's unable to parse the path */
 1333|  2.80k|	sc_format_path(argv[0], path);
 1334|  2.80k|	if (!path->len || (path->len & 1)) {
  ------------------
  |  Branch (1334:6): [True: 0, False: 2.80k]
  |  Branch (1334:20): [True: 2, False: 2.80k]
  ------------------
 1335|      2|		parse_error(cur, "Invalid path length\n");
 1336|      2|		return 1;
 1337|      2|	}
 1338|  2.80k|	file->id = (path->value[path->len-2] << 8) | path->value[path->len-1];
 1339|  2.80k|	return 0;
 1340|  2.80k|}
fuzz_pkcs15init.c:do_fileid:
 1344|  8.08k|{
 1345|  8.08k|	struct file_info *fi;
 1346|  8.08k|	struct sc_file	*df, *file = NULL;
 1347|  8.08k|	struct sc_path	temp, *path = NULL;
 1348|       |
 1349|  8.08k|	if (!cur->file) {
  ------------------
  |  Branch (1349:6): [True: 0, False: 8.08k]
  ------------------
 1350|      0|		parse_error(cur, "Invalid state\n");
 1351|      0|		return 1;
 1352|      0|	}
 1353|  8.08k|	file = cur->file->file;
 1354|  8.08k|	path = &file->path;
 1355|       |
 1356|       |	/* sc_format_path doesn't return an error indication
 1357|       |	 * when it's unable to parse the path */
 1358|  8.08k|	sc_format_path(argv[0], &temp);
 1359|  8.08k|	if (temp.len != 2) {
  ------------------
  |  Branch (1359:6): [True: 3, False: 8.08k]
  ------------------
 1360|      3|		parse_error(cur, "Invalid file ID length\n");
 1361|      3|		return 1;
 1362|      3|	}
 1363|       |
 1364|       |	/* Get the DF, if any */
 1365|  8.08k|	if ((fi = cur->file->parent) && (df = fi->file)) {
  ------------------
  |  Branch (1365:6): [True: 5.91k, False: 2.17k]
  |  Branch (1365:34): [True: 5.91k, False: 0]
  ------------------
 1366|  5.91k|		if (!df->path.len && !df->path.aid.len) {
  ------------------
  |  Branch (1366:7): [True: 63, False: 5.84k]
  |  Branch (1366:24): [True: 0, False: 63]
  ------------------
 1367|      0|			parse_error(cur, "No path/fileid set for parent DF\n");
 1368|      0|			return 1;
 1369|      0|		}
 1370|  5.91k|		if (df->path.len + 2 > sizeof(df->path.value)) {
  ------------------
  |  Branch (1370:7): [True: 0, False: 5.91k]
  ------------------
 1371|      0|			parse_error(cur, "File path too long\n");
 1372|      0|			return 1;
 1373|      0|		}
 1374|  5.91k|		*path = df->path;
 1375|  5.91k|	}
 1376|  8.08k|	if (path->len + 2 > sizeof(path->value)) {
  ------------------
  |  Branch (1376:6): [True: 2, False: 8.08k]
  ------------------
 1377|      2|		parse_error(cur, "File path too long\n");
 1378|      2|		return 1;
 1379|      2|	}
 1380|  8.08k|	memcpy(path->value + path->len, temp.value, 2);
 1381|  8.08k|	path->len += 2;
 1382|       |
 1383|  8.08k|	file->id = (temp.value[0] << 8) | temp.value[1];
 1384|  8.08k|	return 0;
 1385|  8.08k|}
fuzz_pkcs15init.c:do_structure:
 1389|  1.33k|{
 1390|  1.33k|	unsigned int	ef_structure;
 1391|       |
 1392|  1.33k|	if (!cur->file) {
  ------------------
  |  Branch (1392:6): [True: 1, False: 1.33k]
  ------------------
 1393|      1|		parse_error(cur, "Invalid state\n");
 1394|      1|		return 1;
 1395|      1|	}
 1396|       |
 1397|  1.33k|	if (map_str2int(cur, argv[0], &ef_structure, fileStructureNames))
  ------------------
  |  Branch (1397:6): [True: 0, False: 1.33k]
  ------------------
 1398|      0|		return 1;
 1399|  1.33k|	cur->file->file->ef_structure = ef_structure;
 1400|  1.33k|	return 0;
 1401|  1.33k|}
fuzz_pkcs15init.c:do_size:
 1405|  1.60k|{
 1406|  1.60k|	unsigned int	size;
 1407|       |
 1408|  1.60k|	if (!cur->file) {
  ------------------
  |  Branch (1408:6): [True: 0, False: 1.60k]
  ------------------
 1409|      0|		parse_error(cur, "Invalid state\n");
 1410|      0|		return 1;
 1411|      0|	}
 1412|       |
 1413|  1.60k|	if (get_uint_eval(cur, argc, argv, &size))
  ------------------
  |  Branch (1413:6): [True: 5, False: 1.59k]
  ------------------
 1414|      5|		return 1;
 1415|  1.59k|	cur->file->file->size = size;
 1416|  1.59k|	return 0;
 1417|  1.60k|}
fuzz_pkcs15init.c:get_uint_eval:
 2677|  1.60k|{
 2678|  1.60k|	struct num_exp_ctx	ctx;
 2679|       |
 2680|  1.60k|	memset(&ctx, 0, sizeof(ctx));
 2681|  1.60k|	ctx.state = cur;
 2682|  1.60k|	ctx.argc  = argc;
 2683|  1.60k|	ctx.argv  = argv;
 2684|       |
 2685|  1.60k|	if (setjmp(ctx.error)) {
  ------------------
  |  Branch (2685:6): [True: 5, False: 1.59k]
  ------------------
 2686|      5|		parse_error(cur, "invalid numeric expression\n");
 2687|      5|		return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      5|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 2688|      5|	}
 2689|       |
 2690|  1.59k|	expr_eval(&ctx, vp, 0, 0);
 2691|  1.59k|	if (ctx.str[0] || ctx.argc)
  ------------------
  |  Branch (2691:6): [True: 0, False: 1.59k]
  |  Branch (2691:20): [True: 0, False: 1.59k]
  ------------------
 2692|      1|		expr_fail(&ctx);
 2693|       |
 2694|  1.59k|	return 0;
 2695|  1.60k|}
fuzz_pkcs15init.c:expr_eval:
 2616|  2.31k|{
 2617|  2.31k|	unsigned int	left, right, new_pri;
 2618|  2.31k|	char		*tok, op;
 2619|       |
 2620|  2.31k|	expr_term(ctx, &left, opening_brackets);
 2621|       |
 2622|  2.91k|	while (1) {
  ------------------
  |  Branch (2622:9): [True: 2.85k, Folded]
  ------------------
 2623|  2.85k|		tok = __expr_get(ctx, 1);
 2624|  2.85k|		if (tok == NULL)
  ------------------
  |  Branch (2624:7): [True: 1.81k, False: 1.03k]
  ------------------
 2625|  1.81k|			break;
 2626|       |
 2627|  1.03k|		op = tok[0];
 2628|       |
 2629|  1.03k|		new_pri = 0;
 2630|  1.03k|		switch (op) {
 2631|    770|		case '*':
  ------------------
  |  Branch (2631:3): [True: 770, False: 269]
  ------------------
 2632|    819|		case '/':
  ------------------
  |  Branch (2632:3): [True: 49, False: 990]
  ------------------
 2633|    819|			new_pri++;
 2634|       |			/* fall through */
 2635|  1.00k|		case '+':
  ------------------
  |  Branch (2635:3): [True: 184, False: 855]
  ------------------
 2636|  1.03k|		case '-':
  ------------------
  |  Branch (2636:3): [True: 35, False: 1.00k]
  ------------------
 2637|  1.03k|			new_pri++;
 2638|       |			/* fall through */
 2639|  1.03k|		case '&':
  ------------------
  |  Branch (2639:3): [True: 1, False: 1.03k]
  ------------------
 2640|  1.03k|			new_pri++;
 2641|       |			/* fall through */
 2642|  1.03k|		case '|':
  ------------------
  |  Branch (2642:3): [True: 0, False: 1.03k]
  ------------------
 2643|  1.03k|			new_pri++;
 2644|       |			/* fall through */
 2645|  1.03k|		case ')':
  ------------------
  |  Branch (2645:3): [True: 0, False: 1.03k]
  ------------------
 2646|  1.03k|			break;
 2647|      0|		default:
  ------------------
  |  Branch (2647:3): [True: 0, False: 1.03k]
  ------------------
 2648|      0|			expr_fail(ctx);
 2649|  1.03k|		}
 2650|       |
 2651|  1.03k|		if (new_pri < pri) {
  ------------------
  |  Branch (2651:7): [True: 389, False: 650]
  ------------------
 2652|    389|			expr_unget(ctx, tok);
 2653|    389|			break;
 2654|    389|		}
 2655|    650|		pri = new_pri;
 2656|       |
 2657|    650|		expr_eval(ctx, &right, new_pri + 1, opening_brackets);
 2658|    650|		switch (op) {
 2659|    362|		case '*': left *= right; break;
  ------------------
  |  Branch (2659:3): [True: 362, False: 288]
  ------------------
 2660|     49|		case '/':
  ------------------
  |  Branch (2660:3): [True: 49, False: 601]
  ------------------
 2661|     49|			if (right == 0)
  ------------------
  |  Branch (2661:8): [True: 1, False: 48]
  ------------------
 2662|      1|				expr_fail(ctx);
 2663|     49|			left /= right; break;
 2664|    158|		case '+': left += right; break;
  ------------------
  |  Branch (2664:3): [True: 158, False: 492]
  ------------------
 2665|     35|		case '-': left -= right; break;
  ------------------
  |  Branch (2665:3): [True: 35, False: 615]
  ------------------
 2666|      0|		case '&': left &= right; break;
  ------------------
  |  Branch (2666:3): [True: 0, False: 650]
  ------------------
 2667|      0|		case '|': left |= right; break;
  ------------------
  |  Branch (2667:3): [True: 0, False: 650]
  ------------------
 2668|      0|		default: expr_fail(ctx);
  ------------------
  |  Branch (2668:3): [True: 0, False: 650]
  ------------------
 2669|    650|		}
 2670|    650|	}
 2671|       |
 2672|  2.26k|	*vp = left;
 2673|  2.26k|}
fuzz_pkcs15init.c:expr_term:
 2574|  2.31k|{
 2575|  2.31k|	char	*tok;
 2576|       |
 2577|  2.31k|	tok = expr_get(ctx);
 2578|  2.31k|	if (*tok == '(') {
  ------------------
  |  Branch (2578:6): [True: 58, False: 2.25k]
  ------------------
 2579|     58|		if (opening_brackets + 1 > MAX_BRACKETS) {
  ------------------
  |  | 2571|     58|#define MAX_BRACKETS 32
  ------------------
  |  Branch (2579:7): [True: 0, False: 58]
  ------------------
 2580|      0|			parse_error(ctx->state, "Too many \"%s\" in expression", tok);
 2581|      0|			expr_fail(ctx);
 2582|      0|		}
 2583|     58|		expr_eval(ctx, vp, 1, opening_brackets + 1);
 2584|     58|		expr_expect(ctx, ')');
 2585|     58|	}
 2586|  2.25k|	else if (isdigit((unsigned char)*tok)) {
  ------------------
  |  Branch (2586:11): [True: 2.25k, False: 2]
  ------------------
 2587|  2.25k|		char	*ep;
 2588|  2.25k|		unsigned long tmp;
 2589|       |
 2590|  2.25k|		tmp = strtoul(tok, &ep, 0);
 2591|  2.25k|		if (*ep)
  ------------------
  |  Branch (2591:7): [True: 0, False: 2.25k]
  ------------------
 2592|      0|			expr_fail(ctx);
 2593|  2.25k|		if (tmp > UINT_MAX)
  ------------------
  |  Branch (2593:7): [True: 1, False: 2.25k]
  ------------------
 2594|      1|			expr_fail(ctx);
 2595|  2.25k|		*vp = (unsigned int)tmp;
 2596|  2.25k|	}
 2597|      2|	else if (*tok == '$') {
  ------------------
  |  Branch (2597:11): [True: 0, False: 2]
  ------------------
 2598|      0|		sc_macro_t	*mac;
 2599|      0|		char		*argv[32];
 2600|      0|		int		argc;
 2601|       |
 2602|      0|		if (!(mac = find_macro(ctx->state->profile, tok + 1)))
  ------------------
  |  Branch (2602:7): [True: 0, False: 0]
  ------------------
 2603|      0|			expr_fail(ctx);
 2604|      0|		argc = build_argv(ctx->state, "<expr>", mac->value, argv, 32);
 2605|      0|		if (argc < 0 || get_uint_eval(ctx->state, argc, argv, vp) < 0)
  ------------------
  |  Branch (2605:7): [True: 0, False: 0]
  |  Branch (2605:19): [True: 0, False: 0]
  ------------------
 2606|      0|			expr_fail(ctx);
 2607|      0|	}
 2608|      2|	else {
 2609|      2|		parse_error(ctx->state, "Unexpected token \"%s\" in expression", tok);
 2610|      2|		expr_fail(ctx);
 2611|      2|	}
 2612|  2.31k|}
fuzz_pkcs15init.c:expr_get:
 2549|  2.31k|{
 2550|  2.31k|	return __expr_get(ctx, 0);
 2551|  2.31k|}
fuzz_pkcs15init.c:__expr_get:
 2501|  5.16k|{
 2502|  5.16k|	char	*s;
 2503|       |
 2504|  5.16k|	if ((s = ctx->unget) != NULL) {
  ------------------
  |  Branch (2504:6): [True: 388, False: 4.77k]
  ------------------
 2505|    388|		ctx->unget = NULL;
 2506|    388|		return s;
 2507|    388|	}
 2508|       |
 2509|  4.77k|	ctx->j = 0;
 2510|  4.77k|	s = ctx->str;
 2511|  4.77k|	do {
 2512|  4.77k|		if (s == NULL || *s == '\0') {
  ------------------
  |  Branch (2512:7): [True: 1.60k, False: 3.17k]
  |  Branch (2512:20): [True: 1.81k, False: 1.36k]
  ------------------
 2513|  3.41k|			if (ctx->argc == 0) {
  ------------------
  |  Branch (2513:8): [True: 1.81k, False: 1.60k]
  ------------------
 2514|  1.81k|				if (eof_okay)
  ------------------
  |  Branch (2514:9): [True: 1.81k, False: 0]
  ------------------
 2515|  1.81k|					return NULL;
 2516|      0|				expr_fail(ctx);
 2517|      0|			}
 2518|  1.60k|			ctx->str = s = *(ctx->argv++);
 2519|  1.60k|			ctx->argc--;
 2520|  1.60k|		}
 2521|       |
 2522|  2.96k|		while (isspace((unsigned char)*s))
  ------------------
  |  Branch (2522:10): [True: 1, False: 2.96k]
  ------------------
 2523|      1|			s++;
 2524|  2.96k|	} while (*s == '\0');
  ------------------
  |  Branch (2524:11): [True: 1, False: 2.96k]
  ------------------
 2525|       |
 2526|  2.96k|	if (isdigit((unsigned char)*s)) {
  ------------------
  |  Branch (2526:6): [True: 2.25k, False: 711]
  ------------------
 2527|  2.25k|		while (isdigit((unsigned char)*s))
  ------------------
  |  Branch (2527:10): [True: 6.51k, False: 2.25k]
  ------------------
 2528|  6.51k|			expr_put(ctx, *s++);
 2529|  2.25k|	}
 2530|    711|	else if (*s == '$') {
  ------------------
  |  Branch (2530:11): [True: 0, False: 711]
  ------------------
 2531|      0|		expr_put(ctx, *s++);
 2532|      0|		while (is_macro_character(*s))
  ------------------
  |  Branch (2532:10): [True: 0, False: 0]
  ------------------
 2533|      0|			expr_put(ctx, *s++);
 2534|      0|	}
 2535|    711|	else if (strchr("*/+-()|&", *s)) {
  ------------------
  |  Branch (2535:11): [True: 711, False: 0]
  ------------------
 2536|    711|		expr_put(ctx, *s++);
 2537|    711|	}
 2538|      0|	else {
 2539|      0|		expr_fail(ctx);
 2540|      0|	}
 2541|  2.96k|	ctx->str = s;
 2542|       |
 2543|  2.96k|	expr_put(ctx, '\0');
 2544|  2.96k|	return ctx->word;
 2545|  4.77k|}
fuzz_pkcs15init.c:expr_put:
 2493|  10.1k|{
 2494|  10.1k|	if (ctx->j >= (int)sizeof(ctx->word))
  ------------------
  |  Branch (2494:6): [True: 0, False: 10.1k]
  ------------------
 2495|      0|		expr_fail(ctx);
 2496|  10.1k|	ctx->word[ctx->j++] = (char)c;
 2497|  10.1k|}
fuzz_pkcs15init.c:expr_unget:
 2555|    389|{
 2556|    389|	if (ctx->unget)
  ------------------
  |  Branch (2556:6): [True: 0, False: 389]
  ------------------
 2557|      0|		expr_fail(ctx);
 2558|    389|	ctx->unget = s;
 2559|    389|}
fuzz_pkcs15init.c:expr_fail:
 2487|      5|{
 2488|      5|	longjmp(ctx->error, 1);
 2489|      5|}
fuzz_pkcs15init.c:do_aid:
 1482|    251|{
 1483|    251|	struct sc_file	*file = NULL;
 1484|    251|	const char	*name = argv[0];
 1485|    251|	size_t len;
 1486|    251|	int		res = 0;
 1487|       |
 1488|    251|	if (!cur->file) {
  ------------------
  |  Branch (1488:6): [True: 0, False: 251]
  ------------------
 1489|      0|		parse_error(cur, "Invalid state\n");
 1490|      0|		return 1;
 1491|      0|	}
 1492|    251|	file = cur->file->file;
 1493|       |
 1494|    251|	if (*name == '=') {
  ------------------
  |  Branch (1494:6): [True: 0, False: 251]
  ------------------
 1495|      0|		len = strlen(++name);
 1496|      0|		if (len > sizeof(file->name)) {
  ------------------
  |  Branch (1496:7): [True: 0, False: 0]
  ------------------
 1497|      0|			parse_error(cur, "AID \"%s\" too long\n", name);
 1498|      0|			return 1;
 1499|      0|		}
 1500|      0|		memcpy(file->name, name, len);
 1501|      0|		file->namelen = len;
 1502|      0|	}
 1503|    251|	else {
 1504|    251|		file->namelen = sizeof(file->name);
 1505|    251|		res = sc_hex_to_bin(name, file->name, &file->namelen);
 1506|    251|	}
 1507|    251|	return res;
 1508|    251|}
fuzz_pkcs15init.c:do_acl:
 1579|  2.72k|{
 1580|  2.72k|	struct sc_file	*file = NULL;
 1581|  2.72k|	char		oper[64], *what = NULL;
 1582|  2.72k|	memset(oper, 0, sizeof(oper));
 1583|       |
 1584|  2.72k|	if (!cur->file)
  ------------------
  |  Branch (1584:6): [True: 1, False: 2.72k]
  ------------------
 1585|      1|		goto bad;
 1586|  2.72k|	file = cur->file->file;
 1587|       |
 1588|  13.7k|	while (argc--) {
  ------------------
  |  Branch (1588:9): [True: 11.0k, False: 2.69k]
  ------------------
 1589|  11.0k|		unsigned int	op, method, id;
 1590|       |
 1591|  11.0k|		if (strlen(*argv) >= sizeof(oper))
  ------------------
  |  Branch (1591:7): [True: 4, False: 11.0k]
  ------------------
 1592|      4|			goto bad;
 1593|  11.0k|		strlcpy(oper, *argv++, sizeof(oper));
  ------------------
  |  |   43|  11.0k|#define strlcpy _strlcpy
  ------------------
 1594|       |
 1595|  11.0k|		if ((what = strchr(oper, '=')) == NULL)
  ------------------
  |  Branch (1595:7): [True: 6, False: 10.9k]
  ------------------
 1596|      6|			goto bad;
 1597|  10.9k|		*what++ = '\0';
 1598|       |
 1599|  10.9k|		if (*what == '$') {
  ------------------
  |  Branch (1599:7): [True: 5.47k, False: 5.52k]
  ------------------
 1600|  5.47k|			method = SC_AC_SYMBOLIC;
  ------------------
  |  |  155|  5.47k|#define SC_AC_SYMBOLIC			0x00000010 /* internal use only */
  ------------------
 1601|  5.47k|			if (map_str2int(cur, what+1, &id, pinIdNames))
  ------------------
  |  Branch (1601:8): [True: 1, False: 5.47k]
  ------------------
 1602|      1|				return 1;
 1603|  5.47k|		}
 1604|  5.52k|		else if (get_authid(cur, what, &method, &id))
  ------------------
  |  Branch (1604:12): [True: 8, False: 5.51k]
  ------------------
 1605|      8|			goto bad;
 1606|       |
 1607|       |
 1608|  10.9k|		if (!strcmp(oper, "*")) {
  ------------------
  |  Branch (1608:7): [True: 1.70k, False: 9.28k]
  ------------------
 1609|  54.5k|			for (op = 0; op < SC_MAX_AC_OPS; op++) {
  ------------------
  |  |  198|  54.5k|#define SC_MAX_AC_OPS			31
  ------------------
  |  Branch (1609:17): [True: 52.8k, False: 1.70k]
  ------------------
 1610|  52.8k|				sc_file_clear_acl_entries(file, op);
 1611|  52.8k|				sc_file_add_acl_entry(file, op, method, id);
 1612|  52.8k|			}
 1613|  9.28k|		} else {
 1614|  9.28k|			const sc_acl_entry_t *acl;
 1615|       |
 1616|  9.28k|			if (map_str2int(cur, oper, &op, fileOpNames))
  ------------------
  |  Branch (1616:8): [True: 2, False: 9.28k]
  ------------------
 1617|      2|				goto bad;
 1618|  9.28k|			if (!(acl = sc_file_get_acl_entry(file, op)))
  ------------------
  |  Branch (1618:8): [True: 2, False: 9.28k]
  ------------------
 1619|      2|				goto bad;
 1620|  9.28k|			if (acl->method == SC_AC_NEVER
  ------------------
  |  |  163|  18.5k|#define SC_AC_NEVER			0xFFFFFFFF
  ------------------
  |  Branch (1620:8): [True: 3.09k, False: 6.18k]
  ------------------
 1621|  6.18k|			 || acl->method == SC_AC_NONE
  ------------------
  |  |  150|  15.4k|#define SC_AC_NONE			0x00000000
  ------------------
  |  Branch (1621:8): [True: 4.64k, False: 1.54k]
  ------------------
 1622|  1.54k|			 || acl->method == SC_AC_UNKNOWN)
  ------------------
  |  |  162|  1.54k|#define SC_AC_UNKNOWN			0xFFFFFFFE
  ------------------
  |  Branch (1622:8): [True: 0, False: 1.54k]
  ------------------
 1623|  7.73k|				sc_file_clear_acl_entries(file, op);
 1624|       |
 1625|  9.28k|			sc_file_add_acl_entry(file, op, method, id);
 1626|  9.28k|		}
 1627|  10.9k|	}
 1628|  2.69k|	return 0;
 1629|       |
 1630|     23|bad:	parse_error(cur,
 1631|     23|		"Invalid ACL \"%s%s%s\"\n",
 1632|     23|		oper, what? "=" : "", what? what : "");
  ------------------
  |  Branch (1632:9): [True: 14, False: 9]
  |  Branch (1632:25): [True: 14, False: 9]
  ------------------
 1633|     23|	return 1;
 1634|  2.72k|}
fuzz_pkcs15init.c:get_authid:
 2361|  5.52k|{
 2362|  5.52k|	char	temp[16];
 2363|  5.52k|	size_t	n;
 2364|       |
 2365|  5.52k|	if (isdigit((unsigned char) *value)) {
  ------------------
  |  Branch (2365:6): [True: 993, False: 4.53k]
  ------------------
 2366|    993|		*num = 0;
 2367|    993|		return get_uint(cur, value, type);
 2368|    993|	}
 2369|       |
 2370|  4.53k|	if (strlen(value) >= sizeof(temp))
  ------------------
  |  Branch (2370:6): [True: 0, False: 4.53k]
  ------------------
 2371|      0|		return 1;
 2372|       |
 2373|  4.53k|	n = strcspn(value, "0123456789x");
 2374|  4.53k|	strlcpy(temp, value, (sizeof(temp) > n) ? n + 1 : sizeof(temp));
  ------------------
  |  |   43|  4.53k|#define strlcpy _strlcpy
  ------------------
  |  Branch (2374:23): [True: 4.53k, False: 0]
  ------------------
 2375|       |
 2376|  4.53k|	if (map_str2int(cur, temp, type, aclNames))
  ------------------
  |  Branch (2376:6): [True: 5, False: 4.52k]
  ------------------
 2377|      5|		return 1;
 2378|  4.52k|	if (value[n])
  ------------------
  |  Branch (2378:6): [True: 1.12k, False: 3.40k]
  ------------------
 2379|  1.12k|		return get_uint(cur, value + n, num);
 2380|  3.40k|	*num = 0;
 2381|  3.40k|	return 0;
 2382|  4.52k|}
fuzz_pkcs15init.c:setstr:
 2458|  1.62k|{
 2459|  1.62k|	if (*strp)
  ------------------
  |  Branch (2459:6): [True: 1.62k, False: 0]
  ------------------
 2460|  1.62k|		free(*strp);
 2461|  1.62k|	*strp = strdup(value);
 2462|  1.62k|	return 0;
 2463|  1.62k|}
fuzz_pkcs15init.c:do_exclusive_aid:
 1512|    547|{
 1513|    547|	struct sc_file	*file = NULL;
 1514|    547|	const char	*name = argv[0];
 1515|    547|	size_t len;
 1516|    547|	int		res = 0;
 1517|       |
 1518|    547|	if (!cur->file) {
  ------------------
  |  Branch (1518:6): [True: 0, False: 547]
  ------------------
 1519|      0|		parse_error(cur, "Invalid state\n");
 1520|      0|		return 1;
 1521|      0|	}
 1522|    547|	file = cur->file->file;
 1523|       |
 1524|       |#ifdef DEBUG_PROFILE
 1525|       |	printf("do_exclusive_aid(): exclusive-aid '%s'\n", name);
 1526|       |	printf("do_exclusive_aid(): current file '%s' (path:%s)\n", cur->file->ident, sc_print_path(&file->path));
 1527|       |#endif
 1528|    547|	sc_format_path(name, &file->path);
 1529|    547|	if (file->path.len > SC_MAX_AID_SIZE)   {
  ------------------
  |  |   43|    547|#define SC_MAX_AID_SIZE			16
  ------------------
  |  Branch (1529:6): [True: 0, False: 547]
  ------------------
 1530|      0|		parse_error(cur, "Path length is too big\n");
 1531|      0|		return 1;
 1532|      0|	}
 1533|       |
 1534|    547|	memcpy(file->path.aid.value, file->path.value, file->path.len);
 1535|    547|	file->path.aid.len = file->path.len;
 1536|       |
 1537|    547|	file->path.len = 0;
 1538|    547|	file->path.type = SC_PATH_TYPE_DF_NAME;
  ------------------
  |  |  118|    547|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
 1539|       |
 1540|       |#ifdef DEBUG_PROFILE
 1541|       |	printf("do_exclusive_aid(): '%s' exclusive-aid path %s\n", cur->file->ident, sc_print_path(&file->path));
 1542|       |#endif
 1543|    547|	if (*name == '=') {
  ------------------
  |  Branch (1543:6): [True: 8, False: 539]
  ------------------
 1544|      8|		len = strlen(++name);
 1545|      8|		if (len > sizeof(file->name)) {
  ------------------
  |  Branch (1545:7): [True: 1, False: 7]
  ------------------
 1546|      1|			parse_error(cur, "AID \"%s\" too long\n", name);
 1547|      1|			return 1;
 1548|      1|		}
 1549|      7|		memcpy(file->name, name, len);
 1550|      7|		file->namelen = len;
 1551|      7|	}
 1552|    539|	else {
 1553|    539|		file->namelen = sizeof(file->name);
 1554|    539|		res = sc_hex_to_bin(name, file->name, &file->namelen);
 1555|    539|	}
 1556|    546|	return res;
 1557|    547|}
fuzz_pkcs15init.c:do_content:
 1437|    675|{
 1438|    675|	struct sc_file *file = NULL;
 1439|    675|	size_t len = (strlen(argv[0]) + 1) / 2;
 1440|    675|	int rv = 0;
 1441|       |
 1442|    675|	if (!cur->file) {
  ------------------
  |  Branch (1442:6): [True: 0, False: 675]
  ------------------
 1443|      0|		parse_error(cur, "Invalid state\n");
 1444|      0|		return 1;
 1445|      0|	}
 1446|    675|	file = cur->file->file;
 1447|       |
 1448|    675|	free(file->encoded_content);
 1449|       |
 1450|    675|	file->encoded_content = malloc(len);
 1451|    675|	if (!file->encoded_content)
  ------------------
  |  Branch (1451:6): [True: 0, False: 675]
  ------------------
 1452|      0|		return 1;
 1453|    675|	rv = sc_hex_to_bin(argv[0], file->encoded_content, &len);
 1454|    675|	file->encoded_content_len = len;
 1455|    675|	return rv;
 1456|    675|}
fuzz_pkcs15init.c:do_prop_attr:
 1460|      1|{
 1461|      1|	struct sc_file *file = NULL;
 1462|      1|	size_t len = (strlen(argv[0]) + 1) / 2;
 1463|      1|	int rv = 0;
 1464|       |
 1465|      1|	if (!cur->file) {
  ------------------
  |  Branch (1465:6): [True: 0, False: 1]
  ------------------
 1466|      0|		parse_error(cur, "Invalid state\n");
 1467|      0|		return 1;
 1468|      0|	}
 1469|      1|	file = cur->file->file;
 1470|       |
 1471|      1|	free(file->prop_attr);
 1472|      1|	file->prop_attr = malloc(len);
 1473|      1|	if (!file->prop_attr)
  ------------------
  |  Branch (1473:6): [True: 0, False: 1]
  ------------------
 1474|      0|		return 1;
 1475|      1|	rv = sc_hex_to_bin(argv[0], file->prop_attr, &len);
 1476|      1|	file->prop_attr_len = len;
 1477|      1|	return rv;
 1478|      1|}
fuzz_pkcs15init.c:process_ef:
 1038|  7.41k|{
 1039|  7.41k|	struct state	state;
 1040|       |
 1041|  7.41k|	init_state(cur, &state);
 1042|  7.41k|	if (name == NULL) {
  ------------------
  |  Branch (1042:6): [True: 0, False: 7.41k]
  ------------------
 1043|      0|		parse_error(cur, "No name given for EF object.");
 1044|      0|		return 1;
 1045|      0|	}
 1046|  7.41k|	if (!(state.file = new_file(cur, name, SC_FILE_TYPE_WORKING_EF)))
  ------------------
  |  |  216|  7.41k|#define SC_FILE_TYPE_WORKING_EF		0x01
  ------------------
  |  Branch (1046:6): [True: 10, False: 7.40k]
  ------------------
 1047|     10|		return 1;
 1048|  7.40k|	return process_block(&state, info, name, blk);
 1049|  7.41k|}
fuzz_pkcs15init.c:process_bso:
 1055|    113|{
 1056|    113|	struct state	state;
 1057|       |
 1058|    113|	init_state(cur, &state);
 1059|    113|	if (name == NULL) {
  ------------------
  |  Branch (1059:6): [True: 0, False: 113]
  ------------------
 1060|      0|		parse_error(cur, "No name given for BSO object.");
 1061|      0|		return 1;
 1062|      0|	}
 1063|    113|	if (!(state.file = new_file(cur, name, SC_FILE_TYPE_BSO)))
  ------------------
  |  |  217|    113|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (1063:6): [True: 0, False: 113]
  ------------------
 1064|      0|		return 1;
 1065|    113|	return process_block(&state, info, name, blk);
 1066|    113|}
fuzz_pkcs15init.c:process_tmpl:
 1125|  1.58k|{
 1126|  1.58k|	struct state	state;
 1127|  1.58k|	sc_template_t	*tinfo;
 1128|  1.58k|	sc_profile_t	*templ;
 1129|  1.58k|	int r;
 1130|       |
 1131|       |#ifdef DEBUG_PROFILE
 1132|       |	printf("Process template:%s; block:%s\n", name, info->name);
 1133|       |#endif
 1134|  1.58k|	if (name == NULL) {
  ------------------
  |  Branch (1134:6): [True: 0, False: 1.58k]
  ------------------
 1135|      0|		parse_error(cur, "No name given for template.");
 1136|      0|		return 1;
 1137|      0|	}
 1138|       |
 1139|  1.58k|	templ = calloc(1, sizeof(*templ));
 1140|  1.58k|	if (templ == NULL) {
  ------------------
  |  Branch (1140:6): [True: 0, False: 1.58k]
  ------------------
 1141|      0|		parse_error(cur, "memory allocation failed");
 1142|      0|		return 1;
 1143|      0|	}
 1144|       |
 1145|  1.58k|	tinfo = calloc(1, sizeof(*tinfo));
 1146|  1.58k|	if (tinfo == NULL) {
  ------------------
  |  Branch (1146:6): [True: 0, False: 1.58k]
  ------------------
 1147|      0|		parse_error(cur, "memory allocation failed");
 1148|      0|		free(templ);
 1149|      0|		return 1;
 1150|      0|	}
 1151|  1.58k|	tinfo->name = strdup(name);
 1152|  1.58k|	tinfo->data = templ;
 1153|       |
 1154|  1.58k|	tinfo->next = cur->profile->template_list;
 1155|  1.58k|	cur->profile->template_list = tinfo;
 1156|       |
 1157|  1.58k|	init_state(cur, &state);
 1158|  1.58k|	state.profile = tinfo->data;
 1159|  1.58k|	state.file = NULL;
 1160|       |
 1161|  1.58k|	r = process_block(&state, info, name, blk);
 1162|  1.58k|	if (!r)
  ------------------
  |  Branch (1162:6): [True: 1.46k, False: 119]
  ------------------
 1163|  1.46k|		r = template_sanity_check(cur, templ);
 1164|       |
 1165|       |#ifdef DEBUG_PROFILE
 1166|       |	printf("Template %s processed; returns %i\n", name, r);
 1167|       |#endif
 1168|  1.58k|	return r;
 1169|  1.58k|}
fuzz_pkcs15init.c:template_sanity_check:
 1074|  1.46k|{
 1075|  1.46k|	struct file_info *fi, *ffi;
 1076|       |
 1077|  6.09k|	for (fi = templ->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (1077:28): [True: 4.65k, False: 1.44k]
  ------------------
 1078|  4.65k|		struct sc_path fi_path =  fi->file->path;
 1079|  4.65k|		int fi_id;
 1080|       |
 1081|  4.65k|		if (fi->file->type == SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|  4.65k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (1081:7): [True: 24, False: 4.63k]
  ------------------
 1082|     24|			continue;
 1083|       |
 1084|  4.63k|		if (fi_path.len < 2) {
  ------------------
  |  Branch (1084:7): [True: 5, False: 4.62k]
  ------------------
 1085|      5|			parse_error(cur, "Template insane: file-path length should not be less than 2 bytes");
 1086|      5|			return 1;
 1087|      5|		}
 1088|       |
 1089|  4.62k|		fi_id = fi_path.value[fi_path.len - 2] * 0x100
 1090|  4.62k|				+ fi_path.value[fi_path.len - 1];
 1091|       |
 1092|  24.3k|		for (ffi = templ->ef_list; ffi; ffi = ffi->next) {
  ------------------
  |  Branch (1092:30): [True: 19.7k, False: 4.60k]
  ------------------
 1093|  19.7k|			struct sc_path ffi_path =  ffi->file->path;
 1094|  19.7k|			int dlt, ffi_id;
 1095|       |
 1096|  19.7k|			if (ffi->file->type == SC_FILE_TYPE_BSO)
  ------------------
  |  |  217|  19.7k|#define SC_FILE_TYPE_BSO		0x10
  ------------------
  |  Branch (1096:8): [True: 0, False: 19.7k]
  ------------------
 1097|      0|				continue;
 1098|       |
 1099|  19.7k|			if (ffi_path.len < 2) {
  ------------------
  |  Branch (1099:8): [True: 6, False: 19.7k]
  ------------------
 1100|      6|				parse_error(cur, "Template insane: file-path length should not be less than 2 bytes");
 1101|      6|				return 1;
 1102|      6|			}
 1103|       |
 1104|  19.7k|			ffi_id = ffi_path.value[ffi_path.len - 2] * 0x100
 1105|  19.7k|					+ ffi_path.value[ffi_path.len - 1];
 1106|       |
 1107|  19.7k|			dlt = fi_id > ffi_id ? fi_id - ffi_id : ffi_id - fi_id;
  ------------------
  |  Branch (1107:10): [True: 7.54k, False: 12.1k]
  ------------------
 1108|  19.7k|			if (strcmp(ffi->ident, fi->ident))   {
  ------------------
  |  Branch (1108:8): [True: 15.0k, False: 4.62k]
  ------------------
 1109|  15.0k|				if (dlt >= TEMPLATE_FILEID_MIN_DIFF)
  ------------------
  |  |   56|  15.0k|#define TEMPLATE_FILEID_MIN_DIFF	0x20
  ------------------
  |  Branch (1109:9): [True: 15.0k, False: 11]
  ------------------
 1110|  15.0k|					continue;
 1111|       |
 1112|     11|				parse_error(cur, "Template insane: file-ids should be substantially different");
 1113|     11|				return 1;
 1114|  15.0k|			}
 1115|  19.7k|		}
 1116|  4.62k|	}
 1117|       |
 1118|  1.44k|	return SC_SUCCESS;
  ------------------
  |  |   28|  1.44k|#define SC_SUCCESS				0
  ------------------
 1119|  1.46k|}
fuzz_pkcs15init.c:do_card_driver:
  845|     33|{
  846|     33|	free(cur->profile->driver);
  847|     33|	cur->profile->driver = strdup(argv[0]);
  848|     33|	return 0;
  849|     33|}
fuzz_pkcs15init.c:do_maxpinlength:
  853|    176|{
  854|    176|	return get_uint(cur, argv[0], &cur->profile->pin_maxlen);
  855|    176|}
fuzz_pkcs15init.c:do_minpinlength:
  859|    443|{
  860|    443|	return get_uint(cur, argv[0], &cur->profile->pin_minlen);
  861|    443|}
fuzz_pkcs15init.c:do_default_pin_type:
  865|    576|{
  866|    576|	return map_str2int(cur, argv[0],
  867|    576|		       	&cur->profile->pin_encoding, pinTypeNames);
  868|    576|}
fuzz_pkcs15init.c:do_pin_pad_char:
  872|    747|{
  873|    747|	return get_uint(cur, argv[0], &cur->profile->pin_pad_char);
  874|    747|}
fuzz_pkcs15init.c:do_pin_domains:
  878|     17|{
  879|     17|	return get_bool(cur, argv[0], &cur->profile->pin_domains);
  880|     17|}
fuzz_pkcs15init.c:get_bool:
 2410|  2.94k|{
 2411|  2.94k|	if (!strcasecmp(value, "on")
  ------------------
  |  Branch (2411:6): [True: 196, False: 2.75k]
  ------------------
 2412|  2.75k|	 || !strcasecmp(value, "yes")
  ------------------
  |  Branch (2412:6): [True: 191, False: 2.56k]
  ------------------
 2413|  2.56k|	 || !strcasecmp(value, "true")) {
  ------------------
  |  Branch (2413:6): [True: 794, False: 1.76k]
  ------------------
 2414|  1.18k|		*vp = 1;
 2415|  1.18k|	} else
 2416|  1.76k|	if (!strcasecmp(value, "off")
  ------------------
  |  Branch (2416:6): [True: 0, False: 1.76k]
  ------------------
 2417|  1.76k|	 || !strcasecmp(value, "no")
  ------------------
  |  Branch (2417:6): [True: 1.76k, False: 2]
  ------------------
 2418|  1.76k|	 || !strcasecmp(value, "false")) {
  ------------------
  |  Branch (2418:6): [True: 0, False: 2]
  ------------------
 2419|  1.76k|		*vp = 0;
 2420|  1.76k|	} else {
 2421|      2|		parse_error(cur, "invalid boolean argument \"%s\"\n", value);
 2422|      2|		return 1;
 2423|      2|	}
 2424|  2.94k|	return 0;
 2425|  2.94k|}
fuzz_pkcs15init.c:do_card_label:
  884|  1.12k|{
  885|  1.12k|	struct sc_pkcs15_card	*p15card = cur->profile->p15_spec;
  886|       |
  887|  1.12k|	return setstr(&p15card->tokeninfo->label, argv[0]);
  888|  1.12k|}
fuzz_pkcs15init.c:do_card_manufacturer:
  892|    496|{
  893|    496|	struct sc_pkcs15_card	*p15card = cur->profile->p15_spec;
  894|       |
  895|    496|	return setstr(&p15card->tokeninfo->manufacturer_id, argv[0]);
  896|    496|}
fuzz_pkcs15init.c:process_pin:
 1639|  4.28k|{
 1640|  4.28k|	struct state	state;
 1641|  4.28k|	unsigned int	id;
 1642|       |
 1643|  4.28k|	if (map_str2int(cur, name, &id, pinIdNames))
  ------------------
  |  Branch (1643:6): [True: 2, False: 4.28k]
  ------------------
 1644|      2|		return 1;
 1645|       |
 1646|  4.28k|	init_state(cur, &state);
 1647|  4.28k|	state.pin = new_pin(cur->profile, (int)id);
 1648|       |
 1649|  4.28k|	return process_block(&state, info, name, blk);
 1650|  4.28k|}
fuzz_pkcs15init.c:do_pin_file:
 1712|    360|{
 1713|    360|	free(cur->pin->file_name);
 1714|    360|	cur->pin->file_name = strdup(argv[0]);
 1715|    360|	return 0;
 1716|    360|}
fuzz_pkcs15init.c:do_pin_offset:
 1720|     38|{
 1721|     38|	return get_uint(cur, argv[0], &cur->pin->file_offset);
 1722|     38|}
fuzz_pkcs15init.c:do_pin_attempts:
 1726|  1.48k|{
 1727|  1.48k|	struct pin_info	*pi = cur->pin;
 1728|  1.48k|	unsigned int	count;
 1729|       |
 1730|  1.48k|	if (get_uint(cur, argv[0], &count))
  ------------------
  |  Branch (1730:6): [True: 0, False: 1.48k]
  ------------------
 1731|      0|		return 1;
 1732|  1.48k|	pi->pin.tries_left = count;
 1733|  1.48k|	return 0;
 1734|  1.48k|}
fuzz_pkcs15init.c:do_pin_type:
 1750|     32|{
 1751|     32|	unsigned int	type;
 1752|       |
 1753|     32|	if (map_str2int(cur, argv[0], &type, pinTypeNames))
  ------------------
  |  Branch (1753:6): [True: 0, False: 32]
  ------------------
 1754|      0|		return 1;
 1755|     32|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     32|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1755:6): [True: 0, False: 32]
  ------------------
 1756|      0|		return 1;
 1757|     32|	cur->pin->pin.attrs.pin.type = type;
 1758|     32|	return 0;
 1759|     32|}
fuzz_pkcs15init.c:do_pin_reference:
 1763|  1.34k|{
 1764|  1.34k|	unsigned int	reference;
 1765|       |
 1766|  1.34k|	if (get_uint(cur, argv[0], &reference))
  ------------------
  |  Branch (1766:6): [True: 1, False: 1.34k]
  ------------------
 1767|      1|		return 1;
 1768|  1.34k|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.34k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1768:6): [True: 0, False: 1.34k]
  ------------------
 1769|      0|		return 1;
 1770|  1.34k|	cur->pin->pin.attrs.pin.reference = reference;
 1771|  1.34k|	return 0;
 1772|  1.34k|}
fuzz_pkcs15init.c:do_pin_authid:
 1776|  1.26k|{
 1777|  1.26k|	sc_pkcs15_format_id(argv[0], &cur->pin->pin.auth_id);
 1778|  1.26k|	return 0;
 1779|  1.26k|}
fuzz_pkcs15init.c:do_pin_maxlength:
 1796|  1.22k|{
 1797|  1.22k|	unsigned int	len;
 1798|       |
 1799|  1.22k|	if (get_uint(cur, argv[0], &len))
  ------------------
  |  Branch (1799:6): [True: 0, False: 1.22k]
  ------------------
 1800|      0|		return 1;
 1801|  1.22k|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.22k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1801:6): [True: 0, False: 1.22k]
  ------------------
 1802|      0|		return 1;
 1803|  1.22k|	cur->pin->pin.attrs.pin.max_length = len;
 1804|  1.22k|	return 0;
 1805|  1.22k|}
fuzz_pkcs15init.c:do_pin_minlength:
 1783|  1.54k|{
 1784|  1.54k|	unsigned int	len;
 1785|       |
 1786|  1.54k|	if (get_uint(cur, argv[0], &len))
  ------------------
  |  Branch (1786:6): [True: 0, False: 1.54k]
  ------------------
 1787|      0|		return 1;
 1788|  1.54k|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.54k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1788:6): [True: 0, False: 1.54k]
  ------------------
 1789|      0|		return 1;
 1790|  1.54k|	cur->pin->pin.attrs.pin.min_length = len;
 1791|  1.54k|	return 0;
 1792|  1.54k|}
fuzz_pkcs15init.c:do_pin_storedlength:
 1809|     51|{
 1810|     51|	unsigned int	len;
 1811|       |
 1812|     51|	if (get_uint(cur, argv[0], &len))
  ------------------
  |  Branch (1812:6): [True: 0, False: 51]
  ------------------
 1813|      0|		return 1;
 1814|     51|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|     51|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1814:6): [True: 0, False: 51]
  ------------------
 1815|      0|		return 1;
 1816|     51|	cur->pin->pin.attrs.pin.stored_length = len;
 1817|     51|	return 0;
 1818|     51|}
fuzz_pkcs15init.c:do_pin_maxunlocks:
 1738|     24|{
 1739|     24|	struct pin_info	*pi = cur->pin;
 1740|     24|	unsigned int	count;
 1741|       |
 1742|     24|	if (get_uint(cur, argv[0], &count))
  ------------------
  |  Branch (1742:6): [True: 0, False: 24]
  ------------------
 1743|      0|		return 1;
 1744|     24|	pi->pin.max_unlocks = count;
 1745|     24|	return 0;
 1746|     24|}
fuzz_pkcs15init.c:do_pin_flags:
 1822|  1.32k|{
 1823|  1.32k|	unsigned int flags = 0;
 1824|  1.32k|	int		i, r;
 1825|       |
 1826|  1.32k|	if (cur->pin->pin.auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
  ------------------
  |  |   94|  1.32k|#define SC_PKCS15_PIN_AUTH_TYPE_PIN			0
  ------------------
  |  Branch (1826:6): [True: 0, False: 1.32k]
  ------------------
 1827|      0|		return -1;
 1828|       |
 1829|  1.32k|	cur->pin->pin.attrs.pin.flags = 0;
 1830|  3.84k|	for (i = 0; i < argc; i++) {
  ------------------
  |  Branch (1830:14): [True: 2.52k, False: 1.31k]
  ------------------
 1831|  2.52k|		if ((r = map_str2int(cur, argv[i], &flags, pinFlagNames)) < 0)
  ------------------
  |  Branch (1831:7): [True: 2, False: 2.52k]
  ------------------
 1832|      2|			return r;
 1833|  2.52k|		cur->pin->pin.attrs.pin.flags |= flags;
 1834|  2.52k|	}
 1835|       |
 1836|  1.31k|	return 0;
 1837|  1.32k|}
fuzz_pkcs15init.c:process_option:
  937|  1.30k|{
  938|  1.30k|	sc_profile_t	*profile = cur->profile;
  939|  1.30k|	int		match = 0, i;
  940|       |
  941|  1.30k|	for (i = 0; profile->options[i]; i++)
  ------------------
  |  Branch (941:14): [True: 5, False: 1.30k]
  ------------------
  942|      5|		match |= !strcmp(profile->options[i], name);
  943|  1.30k|	if (!match && strcmp("default", name))
  ------------------
  |  Branch (943:6): [True: 1.30k, False: 0]
  |  Branch (943:16): [True: 614, False: 688]
  ------------------
  944|    614|		return 0;
  945|    688|	return process_block(cur, info, name, blk);
  946|  1.30k|}
fuzz_pkcs15init.c:process_macros:
 1842|    974|{
 1843|    974|	scconf_item	*item;
 1844|    974|	const char	*name;
 1845|    974|	int		 r;
 1846|       |
 1847|  8.10k|	for (item = blk->items; item; item = item->next) {
  ------------------
  |  Branch (1847:26): [True: 7.13k, False: 966]
  ------------------
 1848|  7.13k|		char *s = item->key;
 1849|  7.13k|		name = item->key;
 1850|  7.13k|		if (item->type != SCCONF_ITEM_TYPE_VALUE || !name)
  ------------------
  |  |   44|  14.2k|#define SCCONF_ITEM_TYPE_VALUE		2	/* key = key, list */
  ------------------
  |  Branch (1850:7): [True: 355, False: 6.78k]
  |  Branch (1850:47): [True: 262, False: 6.52k]
  ------------------
 1851|    617|			continue;
 1852|       |
 1853|       |		/* make sure the macro name consist only of allowed characters.
 1854|       |		 * This is not guaranteed by the tokenizer */
 1855|  79.2k|		while (is_macro_character(*s)) {
  ------------------
  |  Branch (1855:10): [True: 72.7k, False: 6.52k]
  ------------------
 1856|  72.7k|			s++;
 1857|  72.7k|		}
 1858|  6.52k|		if (*s != '\0') {
  ------------------
  |  Branch (1858:7): [True: 8, False: 6.51k]
  ------------------
 1859|       |#ifdef DEBUG_PROFILE
 1860|       |			printf("Invalid macro name %s\n", name);
 1861|       |#endif
 1862|      8|			return SC_ERROR_SYNTAX_ERROR;
  ------------------
  |  |  103|      8|#define SC_ERROR_SYNTAX_ERROR			-1501
  ------------------
 1863|      8|		}
 1864|       |#ifdef DEBUG_PROFILE
 1865|       |		printf("Defining %s\n", name);
 1866|       |#endif
 1867|  6.51k|		r = new_macro(cur->profile, name, item->value.list);
 1868|  6.51k|		if (r != SC_SUCCESS)
  ------------------
  |  |   28|  6.51k|#define SC_SUCCESS				0
  ------------------
  |  Branch (1868:7): [True: 0, False: 6.51k]
  ------------------
 1869|      0|			return r;
 1870|  6.51k|	}
 1871|       |
 1872|    966|	return SC_SUCCESS;
  ------------------
  |  |   28|    966|#define SC_SUCCESS				0
  ------------------
 1873|    974|}
fuzz_pkcs15init.c:new_macro:
 1877|  6.51k|{
 1878|  6.51k|	sc_macro_t	*mac;
 1879|       |
 1880|  6.51k|	if (!profile || !name || !value)
  ------------------
  |  Branch (1880:6): [True: 0, False: 6.51k]
  |  Branch (1880:18): [True: 0, False: 6.51k]
  |  Branch (1880:27): [True: 0, False: 6.51k]
  ------------------
 1881|      0|		return SC_ERROR_INVALID_ARGUMENTS;
  ------------------
  |  |   73|      0|#define SC_ERROR_INVALID_ARGUMENTS		-1300
  ------------------
 1882|       |
 1883|  6.51k|	if ((mac = find_macro(profile, name)) == NULL) {
  ------------------
  |  Branch (1883:6): [True: 2.33k, False: 4.17k]
  ------------------
 1884|  2.33k|		mac = calloc(1, sizeof(*mac));
 1885|  2.33k|		if (mac == NULL)
  ------------------
  |  Branch (1885:7): [True: 0, False: 2.33k]
  ------------------
 1886|      0|			return SC_ERROR_OUT_OF_MEMORY;
  ------------------
  |  |   85|      0|#define SC_ERROR_OUT_OF_MEMORY			-1404
  ------------------
 1887|  2.33k|		mac->name = strdup(name);
 1888|  2.33k|		mac->next = profile->macro_list;
 1889|  2.33k|		profile->macro_list = mac;
 1890|  2.33k|	}
 1891|       |
 1892|  6.51k|	mac->value = value;
 1893|  6.51k|	return SC_SUCCESS;
  ------------------
  |  |   28|  6.51k|#define SC_SUCCESS				0
  ------------------
 1894|  6.51k|}
fuzz_pkcs15init.c:do_direct_certificates:
  903|  1.34k|{
  904|  1.34k|	return get_bool(cur, argv[0], &cur->profile->pkcs15.direct_certificates);
  905|  1.34k|}
fuzz_pkcs15init.c:do_encode_df_length:
  909|  1.02k|{
  910|  1.02k|	return get_bool(cur, argv[0], &cur->profile->pkcs15.encode_df_length);
  911|  1.02k|}
fuzz_pkcs15init.c:do_encode_update_field:
  915|    566|{
  916|    566|	return get_bool(cur, argv[0], &cur->profile->pkcs15.do_last_update);
  917|    566|}
fuzz_pkcs15init.c:do_pkcs15_id_style:
  921|    359|{
  922|    359|	return map_str2int(cur, argv[0], &cur->profile->id_style, idStyleNames);
  923|    359|}
fuzz_pkcs15init.c:sc_profile_find_file:
 2261|  44.3k|{
 2262|  44.3k|	struct file_info	*fi;
 2263|  44.3k|	size_t				len;
 2264|  44.3k|	const u8			*value;
 2265|       |
 2266|  44.3k|	value = path ? path->value : (const u8*) "";
  ------------------
  |  Branch (2266:10): [True: 4, False: 44.3k]
  ------------------
 2267|  44.3k|	len = path ? path->len : 0;
  ------------------
  |  Branch (2267:8): [True: 4, False: 44.3k]
  ------------------
 2268|   163k|	for (fi = pro->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (2268:26): [True: 135k, False: 28.1k]
  ------------------
 2269|   135k|		sc_path_t *fpath = &fi->file->path;
 2270|       |
 2271|   135k|		if (!strcasecmp(fi->ident, name) && fpath->len >= len && !memcmp(fpath->value, value, len))
  ------------------
  |  Branch (2271:7): [True: 16.1k, False: 119k]
  |  Branch (2271:39): [True: 16.1k, False: 0]
  |  Branch (2271:60): [True: 16.1k, False: 0]
  ------------------
 2272|  16.1k|			return fi;
 2273|   135k|	}
 2274|  28.1k|	return NULL;
 2275|  44.3k|}
fuzz_pkcs15init.c:sc_profile_find_file_by_path:
 2280|  4.05k|{
 2281|  4.05k|	struct file_info *fi, *out = NULL;
 2282|  4.05k|	struct sc_path *fp_path, *fpp_path;
 2283|       |
 2284|       |#ifdef DEBUG_PROFILE
 2285|       |	struct sc_context *ctx = pro->card->ctx;
 2286|       |
 2287|       |	sc_log(ctx, "profile's EF list:");
 2288|       |	for (fi = pro->ef_list; fi; fi = fi->next)   {
 2289|       |		sc_log(ctx, "'%s' (path:%s)",  fi->ident, sc_print_path(&fi->file->path));
 2290|       |		sc_log(ctx, "fi parent %p", fi->parent);
 2291|       |		if (fi->parent && fi->parent->file)
 2292|       |			sc_log(ctx, "fi parent path %s", sc_print_path(&fi->parent->file->path));
 2293|       |	}
 2294|       |	sc_log(ctx, "find profile file by path:%s", sc_print_path(path));
 2295|       |#endif
 2296|       |
 2297|  4.05k|	if (!path || (!path->len && !path->aid.len))
  ------------------
  |  Branch (2297:6): [True: 0, False: 4.05k]
  |  Branch (2297:16): [True: 1.50k, False: 2.55k]
  |  Branch (2297:30): [True: 1.41k, False: 84]
  ------------------
 2298|  1.41k|		return NULL;
 2299|       |
 2300|  27.3k|	for (fi = pro->ef_list; fi; fi = fi->next) {
  ------------------
  |  Branch (2300:26): [True: 24.6k, False: 2.64k]
  ------------------
 2301|  24.6k|		fp_path = &fi->file->path;
 2302|  24.6k|		fpp_path = fi->parent ? &fi->parent->file->path : NULL;
  ------------------
  |  Branch (2302:14): [True: 20.6k, False: 4.08k]
  ------------------
 2303|       |
 2304|  24.6k|		if (fp_path->len != path->len)
  ------------------
  |  Branch (2304:7): [True: 12.3k, False: 12.3k]
  ------------------
 2305|  12.3k|			continue;
 2306|  12.3k|		if (fp_path->len && memcmp(fp_path->value, path->value, path->len))
  ------------------
  |  Branch (2306:7): [True: 11.8k, False: 495]
  |  Branch (2306:23): [True: 9.19k, False: 2.61k]
  ------------------
 2307|  9.19k|			continue;
 2308|       |
 2309|  3.10k|		if (path->aid.len && fp_path->aid.len)   {
  ------------------
  |  Branch (2309:7): [True: 498, False: 2.61k]
  |  Branch (2309:24): [True: 148, False: 350]
  ------------------
 2310|    148|			if (memcmp(fp_path->aid.value, path->aid.value, path->aid.len))
  ------------------
  |  Branch (2310:8): [True: 60, False: 88]
  ------------------
 2311|     60|				continue;
 2312|    148|		}
 2313|  2.96k|		else if (path->aid.len && !fp_path->aid.len && fpp_path)   {
  ------------------
  |  Branch (2313:12): [True: 350, False: 2.61k]
  |  Branch (2313:29): [True: 350, False: 0]
  |  Branch (2313:50): [True: 299, False: 51]
  ------------------
 2314|    299|			if (fpp_path->type == SC_PATH_TYPE_DF_NAME && fpp_path->len)   {
  ------------------
  |  |  118|    598|#define SC_PATH_TYPE_DF_NAME		1
  ------------------
  |  Branch (2314:8): [True: 25, False: 274]
  |  Branch (2314:50): [True: 6, False: 19]
  ------------------
 2315|      6|				if (fpp_path->len != path->aid.len)
  ------------------
  |  Branch (2315:9): [True: 0, False: 6]
  ------------------
 2316|      0|					continue;
 2317|      6|				if (memcmp(fpp_path->value, path->aid.value, path->aid.len))
  ------------------
  |  Branch (2317:9): [True: 6, False: 0]
  ------------------
 2318|      6|					continue;
 2319|      6|			}
 2320|    293|			else if (fpp_path->aid.len)   {
  ------------------
  |  Branch (2320:13): [True: 19, False: 274]
  ------------------
 2321|     19|				if (fpp_path->aid.len != path->aid.len)
  ------------------
  |  Branch (2321:9): [True: 0, False: 19]
  ------------------
 2322|      0|					continue;
 2323|     19|				if (memcmp(fpp_path->aid.value, path->aid.value, path->aid.len))
  ------------------
  |  Branch (2323:9): [True: 6, False: 13]
  ------------------
 2324|      6|					continue;
 2325|     19|			}
 2326|    299|		}
 2327|       |
 2328|  3.03k|		out = fi;
 2329|  3.03k|	}
 2330|       |
 2331|       |#ifdef DEBUG_PROFILE
 2332|       |	sc_log(ctx, "returns (%s)", out ? out->ident: "<null>");
 2333|       |#endif
 2334|  2.64k|	return out;
 2335|  4.05k|}

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

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

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

fuzz_profile_load:
   34|  3.26k|{
   35|  3.26k|    int rv = 0;
   36|  3.26k|    scconf_context	*conf = NULL;
   37|  3.26k|    conf = scconf_new(NULL);
   38|  3.26k|    if (!conf)
  ------------------
  |  Branch (38:9): [True: 0, False: 3.26k]
  ------------------
   39|      0|        return 0;
   40|       |
   41|  3.26k|    if ((rv = scconf_parse_string(conf, (char *)data)) < 0) {
  ------------------
  |  Branch (41:9): [True: 0, False: 3.26k]
  ------------------
   42|      0|        scconf_free(conf);
   43|      0|        return rv;
   44|      0|    }
   45|       |
   46|  3.26k|    rv = process_conf(profile, conf);
   47|  3.26k|    scconf_free(conf);
   48|  3.26k|    return rv;
   49|  3.26k|}
fuzz_pkcs15init_bind:
   53|  3.45k|{
   54|  3.45k|    struct sc_profile *profile = NULL;
   55|  3.45k|    const char	      *driver;
   56|  3.45k|    struct sc_pkcs15init_operations * (* func)(void) = NULL;
   57|  3.45k|    int r = 0;
   58|       |
   59|  3.45k|    if (!card || !card->driver || !result)
  ------------------
  |  Branch (59:9): [True: 0, False: 3.45k]
  |  Branch (59:18): [True: 0, False: 3.45k]
  |  Branch (59:35): [True: 0, False: 3.45k]
  ------------------
   60|      0|        return;
   61|       |
   62|  3.45k|    *result = NULL;
   63|       |
   64|  3.45k|    r = sc_pkcs15init_set_lifecycle(card, SC_CARDCTRL_LIFECYCLE_ADMIN);
   65|  3.45k|    if (r < 0 && r != SC_ERROR_NOT_SUPPORTED) {
  ------------------
  |  |   89|  3.21k|#define SC_ERROR_NOT_SUPPORTED			-1408
  ------------------
  |  Branch (65:9): [True: 3.21k, False: 235]
  |  Branch (65:18): [True: 0, False: 3.21k]
  ------------------
   66|      0|        return;
   67|      0|    }
   68|       |
   69|  3.45k|	profile = sc_profile_new();
   70|  3.45k|    if (!profile)
  ------------------
  |  Branch (70:9): [True: 0, False: 3.45k]
  ------------------
   71|      0|        return;
   72|  3.45k|    profile->card = card;
   73|  3.45k|    driver = card->driver->short_name;
   74|       |
   75|  43.5k|    for (int i = 0; profile_operations[i].name; i++) {
  ------------------
  |  Branch (75:21): [True: 43.3k, False: 177]
  ------------------
   76|  43.3k|		if (!strcasecmp(driver, profile_operations[i].name)) {
  ------------------
  |  Branch (76:7): [True: 3.27k, False: 40.0k]
  ------------------
   77|  3.27k|			func = (struct sc_pkcs15init_operations *(*)(void)) profile_operations[i].func;
   78|  3.27k|			break;
   79|  3.27k|		}
   80|  43.3k|	}
   81|  3.45k|    if (func) {
  ------------------
  |  Branch (81:9): [True: 3.27k, False: 177]
  ------------------
   82|  3.27k|        profile->ops = func();
   83|  3.27k|    } else {
   84|    177|        sc_profile_free(profile);
   85|    177|        return;
   86|    177|    }
   87|  3.27k|    profile->name = strdup("Fuzz profile");
   88|       |
   89|  3.27k|    r = sc_pkcs15init_read_info(card, profile);
   90|  3.27k|    if (r < 0) {
  ------------------
  |  Branch (90:9): [True: 17, False: 3.26k]
  ------------------
   91|     17|		sc_profile_free(profile);
   92|     17|        return;
   93|     17|	}
   94|       |
   95|  3.26k|    if (fuzz_profile_load(profile, data, size) < 0) {
  ------------------
  |  Branch (95:9): [True: 194, False: 3.06k]
  ------------------
   96|    194|        sc_profile_free(profile);
   97|    194|        return;
   98|    194|    }
   99|       |
  100|  3.06k|    if (sc_profile_finish(profile, NULL) < 0) {
  ------------------
  |  Branch (100:9): [True: 316, False: 2.75k]
  ------------------
  101|    316|        sc_profile_free(profile);
  102|    316|        return;
  103|    316|    }
  104|  2.75k|    *result = profile;
  105|  2.75k|}
fuzz_get_reader_data:
  108|  3.69k|{
  109|  3.69k|    size_t i = 0;
  110|  12.3M|    while(i < from_size - 1 && from[i] != '\0')
  ------------------
  |  Branch (110:11): [True: 12.3M, False: 0]
  |  Branch (110:32): [True: 12.3M, False: 3.69k]
  ------------------
  111|  12.3M|        i++;
  112|       |
  113|  3.69k|    if (from[i] != '\0')
  ------------------
  |  Branch (113:9): [True: 0, False: 3.69k]
  ------------------
  114|      0|        return 0;
  115|       |
  116|  3.69k|    *to_size = from_size - (i + 1);
  117|  3.69k|    *to = from + (i + 1);
  118|  3.69k|    return 1;
  119|  3.69k|}
do_init_app:
  123|  2.75k|{
  124|  2.75k|    struct sc_pkcs15init_initargs init_args;
  125|  2.75k|    sc_pkcs15_auth_info_t         info;
  126|  2.75k|    int                           so_puk_disabled = 0;
  127|       |
  128|  2.75k|    memset(&init_args, 0, sizeof(init_args));
  129|  2.75k|    memset(&info, 0, sizeof(info));
  130|  2.75k|    sc_pkcs15init_get_pin_info(profile, SC_PKCS15INIT_SO_PIN, &info);
  ------------------
  |  |  169|  2.75k|#define SC_PKCS15INIT_SO_PIN		0
  ------------------
  131|  2.75k|    if ((info.attrs.pin.flags & SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED) &&
  ------------------
  |  |   57|  2.75k|#define SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED		0x0008
  ------------------
  |  Branch (131:9): [True: 131, False: 2.61k]
  ------------------
  132|    131|        (info.attrs.pin.flags & SC_PKCS15_PIN_FLAG_SO_PIN))
  ------------------
  |  |   61|    131|#define SC_PKCS15_PIN_FLAG_SO_PIN			0x0080
  ------------------
  |  Branch (132:9): [True: 128, False: 3]
  ------------------
  133|    128|        so_puk_disabled = 1;
  134|       |
  135|  2.75k|    sc_pkcs15init_get_pin_info(profile, SC_PKCS15INIT_SO_PUK, &info);
  ------------------
  |  |  170|  2.75k|#define SC_PKCS15INIT_SO_PUK		1
  ------------------
  136|       |
  137|  2.75k|    init_args.so_pin = so_pin;
  138|  2.75k|    init_args.so_pin_len = 8;
  139|       |
  140|  2.75k|    if (!so_puk_disabled) {
  ------------------
  |  Branch (140:9): [True: 2.62k, False: 128]
  ------------------
  141|  2.62k|        init_args.so_puk = so_puk;
  142|  2.62k|        init_args.so_puk_len = 8;
  143|  2.62k|    }
  144|       |
  145|  2.75k|    sc_pkcs15init_add_app(card, profile, &init_args);
  146|  2.75k|}
do_store_pin:
  150|  2.21k|{
  151|  2.21k|    struct sc_pkcs15init_pinargs pin_args;
  152|  2.21k|    char   pin_id[SC_PKCS15_MAX_ID_SIZE] = "1\0";
  153|  2.21k|    sc_pkcs15init_set_p15card(profile, p15card);
  154|       |
  155|  2.21k|    memcpy(pin, "1234555678\0", 11); /* Set new pin */
  156|  2.21k|    memset(&pin_args, 0, sizeof(pin_args));
  157|       |
  158|  2.21k|    sc_pkcs15_format_id(pin_id, &pin_args.auth_id);
  159|  2.21k|    pin_args.pin = pin;
  160|  2.21k|    pin_args.pin_len = 6;
  161|  2.21k|    pin_args.label = "Basic PIN";
  162|       |
  163|  2.21k|    pin_args.puk = so_pin;
  164|  2.21k|    pin_args.puk_len = 8;
  165|       |
  166|  2.21k|    sc_pkcs15init_store_pin(p15card, profile, &pin_args);
  167|  2.21k|}
do_store_data_object:
  171|  2.21k|{
  172|  2.21k|    struct sc_pkcs15init_dataargs args;
  173|  2.21k|    char value[SC_MAX_OBJECT_ID_OCTETS];
  174|       |
  175|  2.21k|    memcpy(value, buf, SC_MAX_OBJECT_ID_OCTETS);
  ------------------
  |  |   46|  2.21k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  176|  2.21k|    value[len < SC_MAX_OBJECT_ID_OCTETS ? len : SC_MAX_OBJECT_ID_OCTETS - 1] = '\0';
  ------------------
  |  |   46|  2.21k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
                  value[len < SC_MAX_OBJECT_ID_OCTETS ? len : SC_MAX_OBJECT_ID_OCTETS - 1] = '\0';
  ------------------
  |  |   46|  2.21k|#define SC_MAX_OBJECT_ID_OCTETS		16
  ------------------
  |  Branch (176:11): [True: 0, False: 2.21k]
  ------------------
  177|       |
  178|  2.21k|    memset(&args, 0, sizeof(args));
  179|  2.21k|    sc_init_oid(&args.app_oid);
  180|  2.21k|    args.label = "label";
  181|  2.21k|    args.app_label = "pkcs15-init";
  182|       |
  183|  2.21k|    sc_format_oid(&args.app_oid, value);
  184|       |
  185|  2.21k|    args.der_encoded.value = buf;
  186|  2.21k|    args.der_encoded.len = len;
  187|       |    sc_pkcs15init_store_data_object(p15card, profile, &args, NULL);
  188|  2.21k|}
do_generate_key:
  191|  2.21k|{
  192|  2.21k|    struct sc_pkcs15init_keygen_args keygen_args;
  193|  2.21k|    int algorithms[] = { SC_ALGORITHM_RSA, SC_ALGORITHM_EC };
  ------------------
  |  |   78|  2.21k|#define SC_ALGORITHM_RSA		0
  ------------------
                  int algorithms[] = { SC_ALGORITHM_RSA, SC_ALGORITHM_EC };
  ------------------
  |  |   79|  2.21k|#define SC_ALGORITHM_EC		2
  ------------------
  194|  2.21k|    unsigned int keybits[] = { 1024, 0 };
  195|       |
  196|  2.21k|    memset(&keygen_args, 0, sizeof(keygen_args));
  197|  2.21k|    sc_pkcs15_format_id("01", &(keygen_args.prkey_args.auth_id));
  198|  2.21k|    keygen_args.prkey_args.access_flags |=
  199|  2.21k|                    SC_PKCS15_PRKEY_ACCESS_SENSITIVE
  ------------------
  |  |  316|  2.21k|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
  200|  2.21k|                | SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE
  ------------------
  |  |  318|  2.21k|#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE	0x04
  ------------------
  201|  2.21k|                | SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE
  ------------------
  |  |  319|  2.21k|#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE	0x08
  ------------------
  202|  2.21k|                | SC_PKCS15_PRKEY_ACCESS_LOCAL;
  ------------------
  |  |  320|  2.21k|#define SC_PKCS15_PRKEY_ACCESS_LOCAL		0x10
  ------------------
  203|       |
  204|  6.65k|    for (int i = 0; i < 2; i++) {
  ------------------
  |  Branch (204:21): [True: 4.43k, False: 2.21k]
  ------------------
  205|  4.43k|        keygen_args.prkey_args.key.algorithm = algorithms[i];
  206|  4.43k|        if (algorithms[i] == SC_ALGORITHM_EC) /* strdup called also in parse_alg_spec() */
  ------------------
  |  |   79|  4.43k|#define SC_ALGORITHM_EC		2
  ------------------
  |  Branch (206:13): [True: 2.21k, False: 2.21k]
  ------------------
  207|  2.21k|            keygen_args.prkey_args.key.u.ec.params.named_curve = strdup("prime256v1");
  208|  4.43k|        sc_pkcs15init_generate_key(p15card, profile, &keygen_args, keybits[i], NULL);
  209|       |	/* clear the keygen prkey by algorithms which includes the pubkey and ec_params */
  210|  4.43k|	sc_pkcs15_erase_prkey(&keygen_args.prkey_args.key);
  211|  4.43k|    }
  212|  2.21k|}
do_generate_skey:
  215|  2.21k|{
  216|  2.21k|    struct sc_pkcs15init_skeyargs skey_args;
  217|  2.21k|    int algorithms[] = { SC_ALGORITHM_DES, SC_ALGORITHM_3DES, SC_ALGORITHM_AES };
  ------------------
  |  |   85|  2.21k|#define SC_ALGORITHM_DES		64
  ------------------
                  int algorithms[] = { SC_ALGORITHM_DES, SC_ALGORITHM_3DES, SC_ALGORITHM_AES };
  ------------------
  |  |   86|  2.21k|#define SC_ALGORITHM_3DES		65
  ------------------
                  int algorithms[] = { SC_ALGORITHM_DES, SC_ALGORITHM_3DES, SC_ALGORITHM_AES };
  ------------------
  |  |   88|  2.21k|#define SC_ALGORITHM_AES		67
  ------------------
  218|  2.21k|    unsigned int keybits[] = { 64, 192, 128 };
  219|       |
  220|       |    /* init keygen_args*/
  221|  2.21k|    memset(&skey_args, 0, sizeof(skey_args));
  222|  2.21k|    skey_args.label = "label";
  223|  2.21k|    skey_args.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  305|  2.21k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
                  skey_args.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  306|  2.21k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  224|  2.21k|    skey_args.user_consent = 0;
  225|       |
  226|  8.87k|    for (int i = 0; i < 3; i++) {
  ------------------
  |  Branch (226:21): [True: 6.65k, False: 2.21k]
  ------------------
  227|  6.65k|        skey_args.algorithm = algorithms[i];
  228|  6.65k|        skey_args.value_len = keybits[i];
  229|       |        sc_pkcs15init_generate_secret_key(p15card, profile, &skey_args, NULL);
  230|  6.65k|    }
  231|  2.21k|}
do_store_secret_key:
  235|  2.21k|{
  236|  2.21k|    struct sc_pkcs15init_skeyargs args;
  237|  2.21k|    int algorithms[] = { SC_ALGORITHM_AES, SC_ALGORITHM_DES, SC_ALGORITHM_3DES };
  ------------------
  |  |   88|  2.21k|#define SC_ALGORITHM_AES		67
  ------------------
                  int algorithms[] = { SC_ALGORITHM_AES, SC_ALGORITHM_DES, SC_ALGORITHM_3DES };
  ------------------
  |  |   85|  2.21k|#define SC_ALGORITHM_DES		64
  ------------------
                  int algorithms[] = { SC_ALGORITHM_AES, SC_ALGORITHM_DES, SC_ALGORITHM_3DES };
  ------------------
  |  |   86|  2.21k|#define SC_ALGORITHM_3DES		65
  ------------------
  238|  2.21k|    unsigned int keybits[] = { 128, 64, 192 };
  239|       |
  240|  2.21k|    memset(&args, 0, sizeof(args));
  241|  2.21k|    args.access_flags |= SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE | SC_PKCS15_PRKEY_ACCESS_SENSITIVE;
  ------------------
  |  |  317|  2.21k|#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE	0x02
  ------------------
                  args.access_flags |= SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE | SC_PKCS15_PRKEY_ACCESS_SENSITIVE;
  ------------------
  |  |  316|  2.21k|#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE	0x01
  ------------------
  242|  2.21k|    args.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  305|  2.21k|#define SC_PKCS15_PRKEY_USAGE_ENCRYPT		0x01
  ------------------
                  args.usage |= SC_PKCS15_PRKEY_USAGE_ENCRYPT | SC_PKCS15_PRKEY_USAGE_DECRYPT;
  ------------------
  |  |  306|  2.21k|#define SC_PKCS15_PRKEY_USAGE_DECRYPT		0x02
  ------------------
  243|  2.21k|    sc_pkcs15_format_id("02", &(args.auth_id));
  244|       |
  245|  8.87k|    for (int i = 0; i < 3; i++) {
  ------------------
  |  Branch (245:21): [True: 6.65k, False: 2.21k]
  ------------------
  246|  6.65k|	size_t keybytes = BYTES4BITS(keybits[i]);
  ------------------
  |  |  146|  6.65k|#define BYTES4BITS(num)  (((num) + 7) / 8)    /* number of bytes necessary to hold 'num' bits */
  ------------------
  247|  6.65k|	args.key.data = malloc(keybytes);
  248|  6.65k|	memcpy(args.key.data, buf, keybytes);
  249|  6.65k|	args.key.data_len = keybytes;
  250|  6.65k|	args.algorithm = algorithms[i];
  251|  6.65k|	args.value_len = keybits[i];
  252|       |
  253|  6.65k|	sc_pkcs15init_store_secret_key(p15card, profile, &args, NULL);
  254|  6.65k|	if (args.key.data)
  ------------------
  |  Branch (254:6): [True: 6.65k, False: 0]
  ------------------
  255|  6.65k|		free(args.key.data);
  256|  6.65k|    }
  257|  2.21k|}
do_erase:
  260|  2.21k|{
  261|  2.21k|    struct sc_pkcs15_card *p15card;
  262|       |
  263|  2.21k|    p15card = sc_pkcs15_card_new();
  264|  2.21k|    p15card->card = card;
  265|       |
  266|       |    sc_pkcs15init_erase_card(p15card, profile, NULL);
  267|  2.21k|    sc_pkcs15_card_free(p15card);
  268|  2.21k|}
LLVMFuzzerTestOneInput:
  271|  3.69k|{
  272|  3.69k|    sc_context_t          *ctx = NULL;
  273|  3.69k|    sc_card_t             *card = NULL;
  274|  3.69k|    struct sc_pkcs15_card *p15card = NULL;
  275|  3.69k|    struct sc_profile     *profile = NULL;
  276|  3.69k|    struct sc_reader      *reader = NULL;
  277|  3.69k|    const uint8_t         *reader_data = NULL;
  278|  3.69k|    size_t                 reader_data_size = 0;
  279|  3.69k|    uint8_t               *buf = NULL;
  280|  3.69k|    uint16_t               len = size < 256 ? size : 256;
  ------------------
  |  Branch (280:34): [True: 0, False: 3.69k]
  ------------------
  281|  3.69k|    unsigned char         *pin = NULL;
  282|  3.69k|    unsigned char         *so_pin = NULL;
  283|  3.69k|    unsigned char         *puk = NULL;
  284|  3.69k|    unsigned char         *so_puk = NULL;
  285|  3.69k|    struct sc_pkcs15_card *tmp_p15_data = NULL;
  286|       |
  287|  3.69k|#ifdef FUZZING_ENABLED
  288|  3.69k|    fclose(stdout);
  289|  3.69k|#endif
  290|       |
  291|  3.69k|    if (size == 0)
  ------------------
  |  Branch (291:9): [True: 0, False: 3.69k]
  ------------------
  292|      0|        return 0;
  293|       |
  294|  3.69k|    if (!fuzz_get_reader_data(data, size, &reader_data, &reader_data_size)) {
  ------------------
  |  Branch (294:9): [True: 0, False: 3.69k]
  ------------------
  295|      0|        return 0;
  296|      0|    }
  297|       |
  298|       |    /* Establish context for fuzz app*/
  299|  3.69k|    sc_establish_context(&ctx, "fuzz");
  300|  3.69k|    if (!ctx)
  ------------------
  |  Branch (300:9): [True: 0, False: 3.69k]
  ------------------
  301|      0|        return 0;
  302|       |
  303|  3.69k|    if (fuzz_connect_card(ctx, &card, &reader, reader_data, reader_data_size) != SC_SUCCESS)
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
  |  Branch (303:9): [True: 240, False: 3.45k]
  ------------------
  304|    240|        goto end;
  305|       |
  306|       |    /* Load profile and bind with card */
  307|  3.45k|    fuzz_pkcs15init_bind(card, &profile, data, size - reader_data_size);
  308|       |
  309|  3.45k|    if(!profile)
  ------------------
  |  Branch (309:8): [True: 704, False: 2.75k]
  ------------------
  310|    704|        goto end;
  311|       |
  312|  2.75k|    pin = malloc(11);
  313|  2.75k|    so_pin = malloc(9);
  314|  2.75k|    puk = malloc(9);
  315|  2.75k|    so_puk = malloc(9);
  316|  2.75k|    buf = malloc(len * sizeof(char));
  317|  2.75k|    if (!pin || !so_pin || !puk || !so_puk || !buf)
  ------------------
  |  Branch (317:9): [True: 0, False: 2.75k]
  |  Branch (317:17): [True: 0, False: 2.75k]
  |  Branch (317:28): [True: 0, False: 2.75k]
  |  Branch (317:36): [True: 0, False: 2.75k]
  |  Branch (317:47): [True: 0, False: 2.75k]
  ------------------
  318|      0|        goto end_release;
  319|       |
  320|  2.75k|    memcpy(pin, "123456\0", 7);
  321|  2.75k|    memcpy(so_pin, "12345678\0", 9);
  322|  2.75k|    memcpy(puk, "12345678\0", 9);
  323|  2.75k|    memcpy(so_puk, "12345678\0", 9);
  324|  2.75k|    memcpy(buf, data, len);
  325|       |
  326|       |    /* test pkcs15-init functionality*/
  327|  2.75k|    do_init_app(profile, p15card, card, so_pin, so_puk);
  328|       |
  329|  2.75k|    if (!sc_pkcs15_bind(card, NULL, &p15card)) { /* First and only sc_pkcs15_bind calling, is omitted in next cases*/
  ------------------
  |  Branch (329:9): [True: 2.21k, False: 531]
  ------------------
  330|  2.21k|        do_store_pin(profile, p15card, card, pin, so_pin);
  331|  2.21k|    }
  332|       |
  333|       |    /* sc_pkcs15_bind failed, no point in testing next cases */
  334|  2.75k|    if (!p15card)
  ------------------
  |  Branch (334:9): [True: 531, False: 2.21k]
  ------------------
  335|    531|        goto end_release;
  336|       |
  337|  2.21k|    do_store_data_object(profile, p15card, card, buf, len);
  338|  2.21k|    do_generate_key(profile, p15card, card);
  339|  2.21k|    do_generate_skey(profile, p15card, card);
  340|  2.21k|    do_store_secret_key(profile, p15card, card, buf);
  341|       |
  342|  2.21k|    sc_pkcs15init_finalize_card(card, profile);
  343|  2.21k|    sc_pkcs15init_sanity_check(p15card, profile);
  344|       |
  345|  2.21k|    do_erase(profile, card);
  346|       |
  347|  2.75k|end_release:
  348|  2.75k|    free(pin);
  349|  2.75k|    free(puk);
  350|  2.75k|    free(so_pin);
  351|  2.75k|    free(so_puk);
  352|  2.75k|    free(buf);
  353|       |
  354|  3.69k|end:
  355|  3.69k|	if (profile) {
  ------------------
  |  Branch (355:6): [True: 2.75k, False: 944]
  ------------------
  356|  2.75k|		tmp_p15_data = profile->p15_data;
  357|  2.75k|		sc_pkcs15init_unbind(profile);
  358|  2.75k|		if (tmp_p15_data != p15card)
  ------------------
  |  Branch (358:7): [True: 231, False: 2.51k]
  ------------------
  359|    231|			sc_pkcs15_unbind(tmp_p15_data);
  360|  2.75k|	}
  361|  3.69k|	if (p15card) {
  ------------------
  |  Branch (361:6): [True: 2.21k, False: 1.47k]
  ------------------
  362|  2.21k|		sc_pkcs15_unbind(p15card);
  363|  2.21k|	}
  364|  3.69k|    if (card)
  ------------------
  |  Branch (364:9): [True: 3.45k, False: 240]
  ------------------
  365|  3.45k|	    sc_disconnect_card(card);
  366|  3.69k|    sc_release_context(ctx);
  367|       |
  368|  3.69k|    return 0;
  369|  2.75k|}

fuzz_get_chunk:
   36|   747k|{
   37|   747k|    struct driver_data *data;
   38|   747k|    uint16_t c_size;
   39|   747k|    const uint8_t *c;
   40|       |
   41|   747k|    if (chunk)
  ------------------
  |  Branch (41:9): [True: 747k, False: 0]
  ------------------
   42|   747k|        *chunk = NULL;
   43|   747k|    if (chunk_size)
  ------------------
  |  Branch (43:9): [True: 747k, False: 0]
  ------------------
   44|   747k|        *chunk_size = 0;
   45|       |
   46|   747k|    if (!chunk || !chunk_size || !reader) {
  ------------------
  |  Branch (46:9): [True: 0, False: 747k]
  |  Branch (46:19): [True: 0, False: 747k]
  |  Branch (46:34): [True: 0, False: 747k]
  ------------------
   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|   747k|    data = reader->drv_data;
   52|   747k|    if (!data || !data->Data || data->Size < sizeof c_size) {
  ------------------
  |  Branch (52:9): [True: 0, False: 747k]
  |  Branch (52:18): [True: 0, False: 747k]
  |  Branch (52:33): [True: 404k, False: 342k]
  ------------------
   53|   404k|        sc_debug(reader->ctx, SC_LOG_DEBUG_VERBOSE_TOOL, "Invalid Arguments");
  ------------------
  |  |   70|   404k|#define sc_debug(ctx, level, format, args...)	sc_do_log(ctx, level, FILENAME, __LINE__, __FUNCTION__, format , ## args)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   54|   404k|        return;
   55|   404k|    }
   56|       |    /* parse the length of the returned data on two bytes */
   57|   342k|    c_size = *((uint16_t *) data->Data);
   58|       |    /* consume two bytes from the fuzzing data */
   59|   342k|    data->Size -= sizeof c_size;
   60|   342k|    data->Data += sizeof c_size;
   61|       |
   62|   342k|    if (data->Size < c_size) {
  ------------------
  |  Branch (62:9): [True: 3.16k, False: 339k]
  ------------------
   63|  3.16k|        c_size = data->Size;
   64|  3.16k|    }
   65|       |
   66|       |    /* consume the bytes from the fuzzing data */
   67|   342k|    c = data->Data;
   68|   342k|    data->Size -= c_size;
   69|   342k|    data->Data += c_size;
   70|       |
   71|   342k|    sc_debug_hex(reader->ctx, SC_LOG_DEBUG_VERBOSE_TOOL,
  ------------------
  |  |  127|   342k|    _sc_debug_hex(ctx, level, FILENAME, __LINE__, __FUNCTION__, label, data, len)
  |  |  ------------------
  |  |  |  |   64|       |#define FILENAME __FILE_NAME__
  |  |  ------------------
  ------------------
   72|   342k|        "Returning fuzzing chunk", c, c_size);
   73|       |
   74|   342k|    *chunk = c;
   75|   342k|    *chunk_size = c_size;
   76|   342k|}
sc_get_fuzz_driver:
  150|  3.69k|{
  151|  3.69k|    fuzz_ops.release = fuzz_reader_release;
  152|  3.69k|    fuzz_ops.connect = fuzz_reader_connect;
  153|  3.69k|    fuzz_ops.disconnect = fuzz_reader_disconnect;
  154|  3.69k|    fuzz_ops.transmit = fuzz_reader_transmit;
  155|  3.69k|    fuzz_ops.lock = fuzz_reader_lock;
  156|  3.69k|    fuzz_ops.unlock = fuzz_reader_unlock;
  157|  3.69k|    return &fuzz_drv;
  158|  3.69k|}
fuzz_add_reader:
  161|  3.69k|{
  162|  3.69k|    sc_reader_t	*reader;
  163|  3.69k|    struct driver_data *data;
  164|  3.69k|    char name[64] = {0};
  165|       |
  166|  3.69k|    if (!(reader = calloc(1, sizeof(*reader)))
  ------------------
  |  Branch (166:9): [True: 0, False: 3.69k]
  ------------------
  167|  3.69k|            || !(data = (calloc(1, sizeof(*data))))) {
  ------------------
  |  Branch (167:16): [True: 0, False: 3.69k]
  ------------------
  168|      0|        free(reader);
  169|      0|        return;
  170|      0|    }
  171|       |
  172|  3.69k|    data->Data = Data;
  173|  3.69k|    data->Size = Size;
  174|       |
  175|  3.69k|    reader->driver = &fuzz_drv;
  176|  3.69k|    reader->ops = &fuzz_ops;
  177|  3.69k|    reader->drv_data = data;
  178|  3.69k|    snprintf(name, sizeof name - 1, "%zu random byte%s reader (%p)",
  179|  3.69k|            Size, Size == 1 ? "" : "s", Data);
  ------------------
  |  Branch (179:19): [True: 0, False: 3.69k]
  ------------------
  180|  3.69k|    reader->name = strdup(name);
  181|       |
  182|  3.69k|    reader->ctx = ctx;
  183|  3.69k|    list_append(&ctx->readers, reader);
  184|  3.69k|}
fuzz_connect_card:
  188|  3.69k|{
  189|  3.69k|    struct sc_reader *reader = NULL;
  190|       |
  191|       |    /* Erase possible readers from ctx */
  192|  3.69k|    while (list_size(&ctx->readers)) {
  ------------------
  |  Branch (192:12): [True: 0, False: 3.69k]
  ------------------
  193|      0|        sc_reader_t *rdr = (sc_reader_t *) list_get_at(&ctx->readers, 0);
  194|      0|        _sc_delete_reader(ctx, rdr);
  195|      0|    }
  196|  3.69k|    if (ctx->reader_driver->ops->finish != NULL)
  ------------------
  |  Branch (196:9): [True: 3.69k, False: 0]
  ------------------
  197|  3.69k|        ctx->reader_driver->ops->finish(ctx);
  198|       |
  199|       |    /* Create virtual reader */
  200|  3.69k|    ctx->reader_driver = sc_get_fuzz_driver();
  201|  3.69k|    fuzz_add_reader(ctx, data, size);
  202|  3.69k|    reader = sc_ctx_get_reader(ctx, 0);
  203|       |
  204|       |    /* Connect card */
  205|  3.69k|    if (sc_connect_card(reader, card))
  ------------------
  |  Branch (205:9): [True: 240, False: 3.45k]
  ------------------
  206|    240|        return SC_ERROR_INTERNAL;
  ------------------
  |  |   81|    240|#define SC_ERROR_INTERNAL			-1400
  ------------------
  207|       |
  208|  3.45k|    if (reader_out)
  ------------------
  |  Branch (208:9): [True: 3.45k, False: 0]
  ------------------
  209|  3.45k|        *reader_out = reader;
  210|       |
  211|  3.45k|    return SC_SUCCESS;
  ------------------
  |  |   28|  3.45k|#define SC_SUCCESS				0
  ------------------
  212|  3.69k|}
fuzzer_reader.c:fuzz_reader_release:
   79|  3.69k|{
   80|  3.69k|    if (reader) {
  ------------------
  |  Branch (80:9): [True: 3.69k, False: 0]
  ------------------
   81|  3.69k|        free(reader->drv_data);
   82|  3.69k|        reader->drv_data = NULL;
   83|  3.69k|    }
   84|       |
   85|  3.69k|    return SC_SUCCESS;
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
   86|  3.69k|}
fuzzer_reader.c:fuzz_reader_connect:
   89|  3.69k|{
   90|  3.69k|    uint16_t chunk_size;
   91|  3.69k|    const uint8_t *chunk;
   92|       |
   93|  3.69k|    fuzz_get_chunk(reader, &chunk, &chunk_size);
   94|       |
   95|  3.69k|    if (chunk_size > SC_MAX_ATR_SIZE)
  ------------------
  |  |   41|  3.69k|#define SC_MAX_ATR_SIZE			33
  ------------------
  |  Branch (95:9): [True: 8, False: 3.68k]
  ------------------
   96|      8|        chunk_size = SC_MAX_ATR_SIZE;
  ------------------
  |  |   41|      8|#define SC_MAX_ATR_SIZE			33
  ------------------
   97|  3.68k|    else
   98|  3.68k|        reader->atr.len = chunk_size;
   99|       |
  100|  3.69k|    if (chunk_size > 0)
  ------------------
  |  Branch (100:9): [True: 3.23k, False: 461]
  ------------------
  101|  3.23k|        memcpy(reader->atr.value, chunk, chunk_size);
  102|       |
  103|  3.69k|    return SC_SUCCESS;
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
  104|  3.69k|}
fuzzer_reader.c:fuzz_reader_disconnect:
  107|  3.69k|{
  108|  3.69k|    return SC_SUCCESS;
  ------------------
  |  |   28|  3.69k|#define SC_SUCCESS				0
  ------------------
  109|  3.69k|}
fuzzer_reader.c:fuzz_reader_transmit:
  112|   744k|{
  113|   744k|    const uint8_t *chunk;
  114|   744k|    uint16_t chunk_size;
  115|       |
  116|   744k|    fuzz_get_chunk(reader, &chunk, &chunk_size);
  117|       |
  118|   744k|    if (chunk_size >= 2) {
  ------------------
  |  Branch (118:9): [True: 309k, False: 434k]
  ------------------
  119|       |        /* set the SW1 and SW2 status bytes (the last two bytes of
  120|       |         * the response */
  121|   309k|        apdu->sw1 = (unsigned int)chunk[chunk_size - 2];
  122|   309k|        apdu->sw2 = (unsigned int)chunk[chunk_size - 1];
  123|   309k|        chunk_size -= 2;
  124|       |        /* set output length and copy the returned data if necessary */
  125|   309k|        if (chunk_size <= apdu->resplen)
  ------------------
  |  Branch (125:13): [True: 168k, False: 140k]
  ------------------
  126|   168k|            apdu->resplen = chunk_size;
  127|       |
  128|   309k|        if (apdu->resplen != 0)
  ------------------
  |  Branch (128:13): [True: 226k, False: 82.6k]
  ------------------
  129|   226k|            memcpy(apdu->resp, chunk, apdu->resplen);
  130|   434k|    } else {
  131|   434k|        apdu->sw1 = 0x6D;
  132|   434k|        apdu->sw2 = 0x00;
  133|   434k|        apdu->resplen = 0;
  134|   434k|    }
  135|       |
  136|   744k|    return SC_SUCCESS;
  ------------------
  |  |   28|   744k|#define SC_SUCCESS				0
  ------------------
  137|   744k|}
fuzzer_reader.c:fuzz_reader_lock:
  140|   712k|{
  141|   712k|    return 0;
  142|   712k|}
fuzzer_reader.c:fuzz_reader_unlock:
  145|   712k|{
  146|   712k|    return 0;
  147|   712k|}

sc_notify_id:
  528|     13|		struct sc_pkcs15_card *p15card, enum ui_str id) {}

